Re: INSERT WITH SELECT help

Поиск
Список
Период
Сортировка
От Jurgen Defurne
Тема Re: INSERT WITH SELECT help
Дата
Msg-id 392AB267.83CAE7DA@glo.be
обсуждение исходный текст
Ответ на INSERT WITH SELECT help  (Richard Smith <ozric@tampabay.rr.com>)
Список 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 по дате отправления:

Предыдущее
От: ernie cline
Дата:
Сообщение: quick (and probably dumb) question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Timezones on Tru64 (Digital Unix)