[Zope-DB] Multi table update from one input form
Sun, 22 Sep 2002 21:40:08 +0100
I am using PostgreSQL for the database.
Not sure if I understand your solution, as this is what I thought was doing,
i.e. calling sequence_id_business_name as the DTML which calls the last
value added to this sequence_table, BUT I get an error, as the output of
this method is "Shared.DC.ZRDB.Results.Results instance at 141d744", which I
guess is what is causing the error as it is trying to put this into the
fk_business_name field; as this is the default way for Python to provide the
representation of an object, so to return the last value, I did this:
<dtml-in sequence-item >
Which returned the last value as required and added it to the database.
How would this be done with a python script?
----- Original Message -----
From: "Dieter Maurer" <firstname.lastname@example.org>
To: "Norman Khine" <email@example.com>
Sent: Sunday, September 22, 2002 6:12 PM
Subject: Re: [Zope-DB] Multi table update from one input form
> Norman Khine writes:
> > ...
> > select last_value from business_name_business_name_seq as
> > <dtml-var sql_delimiter>
> > INSERT INTO business_address (street_name, town, county, postcode,
> > ...
> > <dtml-var fk_business_id>);
> > But this does not work, and I get the following error:
> > KeyError: fk_business_id
> As you found out, there is no magic connection between the results
> of a previous SQL command and the DTML variables of a current one.
> You need to use either SQL features or work with separate Z SQL Methods
> with gluing code in DTML (or, better, Python Script).
> You do not told us what database you used. Depending on the system,
> you might access "fk_business_id" either with a nested "select" (will not
> work with MySQL) or with an SQL function that directly accesses
> the "last_value" of "business_name_business_name_seq", e.g.