[Zope-dev] Re: [Zope] Help regarding databse & variable management

Joel Burton jburton@scw.org
Sat, 7 Apr 2001 18:01:49 -0400 (EDT)


On Sat, 7 Apr 2001, [iso-8859-1] Honey George wrote:

> Hello,
>   I have a problem in database connectivity in Zope 
> with Postgres. If anybody can help me in this regard
> please reply asap.
> 
>    I want to insert a row into a tabel, get a unique
> id from the table and make another entry into another
> table.I am able to insert into the forst table and
> retrieve the unique ID. But while trying to insert
> into the next table, it says no value for the unique
> id retireved.
> 
> Expecting a solution.
> 
> Reagrds,
>   George

To reiterate:

You have two tables:

  CREATE TABLE A (id SERIAL, name TEXT);
  CREATE TABLE B (id INT, name TEXT);

You're able to insert the first table:

  ZSQL Method:  INSERT_A:

  INSERT INTO A (name) VALUES ('foo');

and retrieve the unique value:

  ZSQL Method:  GET_LAST_A:

  SELECT currval('A_id_seq');

  (or maybe you say something like SELECT max(id) FROM A, though
   the above is faster & safer)

and you want to insert into the second table with that retrieved value:

  ZSQL Method:  INSERT_B:

  INSERT INTO B (id, name)
   VALUES ( <dtml-var value_of_A >, 'foo');

and it 'says no value for the unique id retrieved' ?

Where does it say this? Are sure you're passing the retrieved last value
to your GET_LAST_A.

It would help to post your ZSQL methods and your controlling DTML method.


-- 
Joel Burton   <jburton@scw.org>
Director of Information Systems, Support Center of Washington