Re: INSERT WITH SELECT help - Mailing list pgsql-general

From Jurgen Defurne
Subject Re: INSERT WITH SELECT help
Date
Msg-id 392AB267.83CAE7DA@glo.be
Whole thread Raw
In response to INSERT WITH SELECT help  (Richard Smith <ozric@tampabay.rr.com>)
List pgsql-general
ozric wrote:

> I got help from one of our DBA's today here is what I was missing.  This
> in not in Bruce's Book.
>
> INSERT INTO address (per_id,street_num,city,state,zip)
> SELECT per_id,'$3','$4','$5','$6' FROM from person
> WHERE last = '$1'
> AND first = '$2';
>
> $1-6 will be supplied by user input from Zope,  I just wanted to isolate the
> per_id from person during and Insert so that end users would not need to know
> it was there.  I know I might have a problem with getting more then one return
> for
> just first and last,  I might add more WHERE statements in there. I am
> just happy to get moving on with my little project.
>
> Thanks for the help
> Richad

Your idea is good, normally you do not want to bother your user with unique
key values. However, have you thought about the fact that more than one
person could have the same first and last names ? Do not confuse the
improbable with the impossible. When names are entered, you should check
how much results you have and probably show another screen on which
the user can select the right person.

Jurgen Defurne
defurnj@glo.be



pgsql-general by date:

Previous
From: ernie cline
Date:
Subject: quick (and probably dumb) question
Next
From: Tom Lane
Date:
Subject: Re: Timezones on Tru64 (Digital Unix)