title: Variable as table name using Lisp/Postmodern/PostgreSQL
body: <p>Can someone please give an example of how to write a row to a table using a variable as the table name in Lisp/Postmodern/S-SQL/PostgreSQL?</p>
  
  <p>I am currently able to write to a table in PostgreSQL with <code>:insert-into</code> using the following function:</p>
  
  <pre><code>(defun save-event (table-name cost event-id)
    (defprepared insert-event
        (sql-compile `(:insert-into ,table-name :set 'cost ,cost
                                                     'event-id ,event-id)))
    (insert-event))
  </code></pre>
  
  <p>Using the input syntax:</p>
  
  <pre><code>(save-event 'table-name 33 1)
  </code></pre>
  
  <p>However, if I try and pass a string containing the desired table name to the function as follows:</p>
  
  <pre><code>(defparameter x "table-name")
  (apply #'funcall `(save-event ',x 44 2))
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>Database error 42601: syntax error at or near "E'table-name'"
  Query: INSERT INTO E'table-name' (cost, event_id) VALUES (44, 2)
     [Condition of type CL-POSTGRES-ERROR:SYNTAX-ERROR-OR-ACCESS-VIOLATION]
  </code></pre>
  
  <p>I have been stuck on this for quite a while, tried almost everything.  Got me stumped.</p>