[Zope-DB] Assign query result(nextval) to variable

Israel Carr icarr@compxnet.com
Fri, 2 May 2003 13:10:14 -0400


I have since come up with the following.  Is there a way to group all
queries into one transaction in a ZSQL method?  If I put a BEGIN; and
COMMIT; it doesn't perform them all as one transaction.  What is the
drawback of having multiple queries in one method?  

Thanks for previous help.
--------------
INSERT INTO project (proj_id)
  SELECT nextval('project_sequence_id_key'::text);

INSERT INTO memo (proj_id)
  SELECT nextval('project_sequence_id_key'::text);

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">
);

-----Original Message-----
From: Andrew Veitch [mailto:andrew@logicalprogression.net] 
Sent: Friday, May 02, 2003 12:11 PM
To: icarr@compxnet.com
Subject: Re: [Zope-DB] Assign query result(nextval) to variable


> select nextval('project_sequence_id_key'::text);
> 
> How do I assign this obtained value to a variable that can be inserted 
> into columns?

What you want to do is use currval('project_sequence_id_key') which will
give you the current value.

A

-- 
Logical Progression Ltd, 20 Forth Street, Edinburgh EH1 3LH, UK
Tel: +44 (0)131 550 3733 Web: http://www.logicalprogression.net/