Re: function and passing the table name to be used with SQL stmnt

Поиск
Список
Период
Сортировка
От kamiseq
Тема Re: function and passing the table name to be used with SQL stmnt
Дата
Msg-id 1193693003.126162.324220@z9g2000hsf.googlegroups.com
обсуждение исходный текст
Ответ на function and passing the table name to be used with SQL stmnt  (kamiseq <kamiseq@gmail.com>)
Ответы Re: function and passing the table name to be used with SQL stmnt
Список pgsql-general
some other question I dont like to make a new topic so I will add it
here.

I ve modified my function to
CREATE OR REPLACE FUNCTION bookid(_tabela varchar) RETURNS integer AS $
$
DECLARE
    _id integer := 0;
BEGIN
    --insert bez id wyzwala nextwal na tabela_columna_seq
    EXECUTE 'insert into '|| quote_ident(_tabela) || '(idjm, waga,
stawka_vat) values(0, 0, '''')';
    select into _id lastval();

    RETURN _id;
END;
$$ LANGUAGE plpgsql;

and is that safe operation, can I rely on lastval() that it will
return value of id that was inserted before?
can it happened that other user will insert something between my
insert and select?


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

Предыдущее
От: davidrboyer@gmail.com
Дата:
Сообщение: postgresql in PHP
Следующее
От: kamiseq
Дата:
Сообщение: Re: function and passing the table name to be used with SQL stmnt