[Zope] Zope Pgsql 7.0/SQL Schema HeLp!

Evan Simpson evan@digicool.com
Sun, 21 May 2000 12:41:24 -0400


----- Original Message -----
From: Richard Smith <ozric@tampabay.rr.com>
> INSERT INTO address (per_id,street,city,state,zip)
> VALUES ('SELECT per_id FROM person WHERE first = '<dtml-var first>'
> AND last = '<dtml-var last>'','<dtml-var street>','<dtml-var city>
> ...etc;

You are allowed to place literal values in a select list, so the following
often works:

INSERT INTO address (per_id, street, city, state, zip)
SELECT per_id, <dtml-sqlvar street type=string>, ...
FROM person WHERE <dmlt-sqltest first> AND <dtml-sqltest last>

This is somewhat fragile since it may insert zero, one, or more records,
depending on how many matches there are in 'person'.  If you are confident
that the SELECT will always match one record, it's fine.

Cheers,

Evan @ digicool & 4-am