Re: Simulating sequences

Поиск
Список
Период
Сортировка
От Dustin Sallings
Тема Re: Simulating sequences
Дата
Msg-id 7D1A49CF-D1FB-11D7-B6C2-000393DC8AE4@spy.net
обсуждение исходный текст
Ответ на Re: Simulating sequences  (<btober@seaworthysys.com>)
Ответы Re: Simulating sequences  (<btober@seaworthysys.com>)
Re: Simulating sequences  (Jan Wieck <JanWieck@Yahoo.com>)
Список pgsql-general
On Monday, Aug 18, 2003, at 09:01 US/Pacific, <btober@seaworthysys.com>
wrote:

> With those items in mind, your function could become:
>
> CREATE FUNCTION key_generation(integer, varchar(20)) RETURNS integer
> AS'
> DECLARE
>   the_department ALIAS FOR $1;
>   the_table_name ALIAS FOR $2;
> BEGIN
>   IF NOT EXISTS(SELECT 1 FROM cnfg_key_generation
>     WHERE the_department = department AND the_table_name = table_name)
> THEN
>    INSERT INTO cnfg_key_generation VALUES
> (the_department,the_table_name,0);
>   END IF;

    I would get the insert out of there, too.  If it doesn't exist, throw
an exception.  I don't believe sequences should automatically create
themselves (the tables and columns don't).

--
SPY                      My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________


В списке pgsql-general по дате отправления:

Предыдущее
От: Dustin Sallings
Дата:
Сообщение: Re: Simulating sequences
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why lower's not accept an AS declaration ?