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

Norman Khine norman@khine.net
Sat, 21 Sep 2002 21:08:12 +0100


Hello,
I am not sure if this is the right way to do this, but I am having real
problems in figuring it out, here is my z sql method:
id: sql_INSERT_business_address
arguments:business_name, business_url, street_name town county postcode
county_id

INSERT INTO business_name (business_name, business_url)
  values (<dtml-sqlvar business_name type="string" >, <dtml-sqlvar
business_url type="string">);

<dtml-var sql_delimiter>

select last_value from business_name_business_name_seq as fk_business_id

<dtml-var sql_delimiter>

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="string">, <dtml-var
fk_business_id>);

But this does not work, and I get the following error:

KeyError: fk_business_id

I then added another sql method which called the last value
id: sequence_id_business_name
arguments:
select last_value from business_name_business_name_seq

and this gave me the following error:

ProgrammingError: ERROR:  parser: parse error at or near "<"

INSERT INTO business_address (street_name, town, county, postcode,
county_id, business_name_id)
  values ('dsfds', 'dfs', 'sdfsd', 'sdfsdf', 2,
<Shared.DC.ZRDB.Results.Results instance at 141d744>);

If I have a dtml method
<dtml-var sequence_id_business_name>

this will return Shared.DC.ZRDB.Results.Results instance at 141d744 - so I
guess this is where the problem is ;^(

So how do I get to select the last sequence id from and added as a value
into my second query.

many thanks

Norman