[Zope-DB] Assign query result(nextval) to variable
Israel Carr
icarr@compxnet.com
Fri, 2 May 2003 11:01:40 -0400
I'm trying to grab the nextval of a sequence to write to records containing
this value into multiple tables. I can obtain the nextval using:
select nextval('project_sequence_id_key'::text);
How do I assign this obtained value to a variable that can be inserted into
columns?
Below is a of the ZSQL method I'm trying to test with and the error I
receive. Let me know if I'm out in left field or beyond!
__________________________________________________
<dtml-var projid>
projid = "select nextval('project_sequence_id_key'::text);"
<dtml-var sql_delimiter>
INSERT INTO project
(proj_leader, vend_id, vend_name, vend_leader, po_date)
VALUES
(<dtml-sqlvar proj_leader type="string">,
<dtml-sqlvar vend_id type="int">,
<dtml-sqlvar vend_name type="string">,
<dtml-sqlvar vend_leader type="string">,
<dtml-sqlvar po_date type="string">
);
<dtml-var sql_delimiter>
INSERT INTO memo
(proj_id, memo_text, memo_type)
VALUES
(<dtml-sqlvar projid type="string">,
<dtml-sqlvar memo_text type="string">,
<dtml-sqlvar memo_type type="string">
);
___________________________________
Error, exceptions.KeyError: projid
____________
SQL used:
Could not render the query template!
_______________________
Thanks for any help!