Re: [Zope] Zope Pgsql 7.0/SQL Schema HeLp!
Lindell Alderman wrote:
I have Zope all set, and I can run all your standard SELECT, INSERT, UPDATE stuff. But I have one hitch, I can't seem to figure out how to make it so an end user could add a name and email address without knowing about the PKEY number. This is no problem for a DBA but I want to make it easy for anyone to INSERT and UPDATE records. Did I make a bad design choice in use unique numbers to glue all the tables together. Is this an interface problem. Am I missing something. I need some help. Can someone point me in the right direction please?
Richard You can either use postgresql's serial type or create a sequence and then use select nextval('sequence_name') and select currval('sequence_name') to get and set the value of the key field.
Check out the user's guide on www.postgresql for exact information on this.
-L
I have the SERIAL type set up already. What is holding me up it that I need to make it possible to INSERT and UPDATE records base on the persons name and not the id number. somthing along the lines of this. 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; I can't seem to figure out the SQL statment to use. I need to use a SELECT as a VALUE in an INSERT statment some how. can that be done, or should I use a View with an UPDATE and INSERT rule ? Richard
----- 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
participants (2)
-
Evan Simpson -
Richard Smith