[Zope-DB] Multi table update from one input form

Norman Khine norman@khine.net
Tue, 24 Sep 2002 09:31:21 +0100


I know, too long winded -- anyhow I found from the psql list that, as you
suggested previously to use a subselect sql statement, so here what the
final statement looks:
id: sql_INSERT_business_address
arguments: street_name town county postcode county_id

INSERT INTO business_address (street_name, town, county, postcode,
county_id, business_name_id) values (<dtml-sqlvar street_name
type="string">, <dtml-sqlvar town type="string">, <dtml-sqlvar county
type="string">, <dtml-sqlvar postcode
type="string">, <dtml-sqlvar county_id type="int">,
business_name_business_name_seq.last_value);

thanks for all your help

Norm

----- Original Message -----
From: "Dieter Maurer" <dieter@handshake.de>
To: "Norman Khine" <norman@khine.net>
Cc: <zope-db@zope.org>
Sent: Monday, September 23, 2002 6:10 PM
Subject: Re: [Zope-DB] Multi table update from one input form


> Norman Khine writes:
>  > 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_id_business_name>
>  > <dtml-in sequence-item >
>  > <dtml-var sequence-item>
>  > </dtml-in-->
>  > </dtml-in>
> Wow! A bit indirect:
>
>   The result of a Z SQL Method call behaves like a sequence of rows.
>   The colums in the row can be either accessed by their name or by
>   their index.
>
>   Thus,
>
> <dtml-var expr="sequence_id_business_name()[0][0]">
>
>   does the same, you do with your nested "dtml-in"
>   (when you know that you get a single row with a single column).
>
>
> Dieter
>