[Zope] sql INSERT during query

Rob Page rob.page@digicool.com
Thu, 15 Apr 1999 17:44:16 -0400


Jay:

>  I think the problem lay in the fact that I was trying to do 
>  another query
>  inside an "in" tag or the equivalent. Reading between lines 
>  of the SQL
>  Database users guide I believe it says this can't be done. I quote
>  "It is often neccessary to execute more than one SQL 
>  statement in a single
>  HTTP REQUEST. SQL database Methods define a variable 
>  sql_delimiter that can
>  be used to divide individual SQL statements."

You should be able to do something like:

  <!--#in sqlGetAngryCustomers-->

    <!--#in sqlGetLatestComplaint-->

      <!--#var doSomething-->

    <!--#/in-->

  <!--#/in-->


The sql_delimiter thing is meant to imply that you may want to, in the
same REQUEST INSERT into one or more tables as in:

INSERT INTO customers
(
  customer_id,
  last_name, 
  first_name, 
  phone
)
VALUES
(
  <!--#sqlvar customer_id-->,
  <!--#sqlvar last_name type=string-->,
  <!--#sqlvar first_name type=string-->,
  <!--#sqlvar phone type=string-->,
)
<!--#var sql_delimiter-->
INSERT INTO orders
(
customer_id,
part_number
)
VALUES
(
  <!--#sqlvar customer_id type=string-->,
  <!--#sqlvar part_number type=string-->,
)

>  I am currently trying to use a single sql method that does 
>  everything I
>  wanted. 
>  
>  On a related note, how do I include the text of an sql 
>  method inside another
>  sql method?

<UNTESTED>I don't think you can</UNTESTED>.  You could define a few DTML
Documents and run them together in a SQLMethod as in:

sqlDoSomthing defined as:

<!--#var dtInsertNewCustomerSQLStatement-->
<!--#var sql_delimiter-->
<!--#var dtInsertNewOrderSQLStatement-->

Hope this helps!

--Rob