S-SQL Examples V
Variable Parameters
You can use variables in s-sql statements. For example:
(let ((column 'latitude) (table 'countries)) (query (:select column :from table))) (let ((select 'countries.name)) (query (:select select :from 'countries 'regions :where (:and (:or (:= 'regions.name '$1) (:= 'regions.name '$2)) (:= 'regions.id 'countries.region-id)))))
Notice that the variable values were quoted. If you used strings, the string would be escaped and Postgresql would give you a syntax error.
View (:create-view)
Create-view will accept quoted values, strings or keywords for the name of the view you are creating. Hyphens will be automatically be converted to underscores.
(query (:create-view 'quagmire (:select 'id 'name :from 'employee))) (query (:create-view :quagmire (:select 'id 'name :from 'employee))) (query (:create-view "quagmire" (:select 'id 'name :from 'employee))) (query (:create-view 'quagmire-hollow (:select 'id 'name :from 'employee))) (query (:create-view "quagmire-hollow" (:select 'id 'name :from 'employee)))