Re: custom session variables?

Поиск
Список
Период
Сортировка
От Darren Duncan
Тема Re: custom session variables?
Дата
Msg-id 51787D28.3080006@darrenduncan.net
обсуждение исходный текст
Ответ на Re: custom session variables?  (Christian Hammers <ch@lathspell.de>)
Ответы Re: custom session variables?
Список pgsql-general
Thank you for that.

I had actually thought of this, but it seemed to me that using a temporary table
was a heavy-handed approach and that a temporary scalar variable would be more
efficient or less verbose to use.

It is *a* solution certainly, and potentially a better one than the url I
pointed to, but I was hoping for something less bulky.

Granted, I realize that sequence generators are basically small tables like this
behind the scenes, but is there any appreciable overhead of creating and
dropping a temporary table for every session?

-- Darren Duncan

On 2013.04.24 5:07 PM, Christian Hammers wrote:
> Hello
>
> You could just use temporary tables like:
>
>   BEGIN;
>   CREATE TEMPORARY TABLE csid (i int);
>     -- somehow write the ID you want into that table
>       -- and then...
>   INSERT INTO other_table (changeset_ids, msg) VALUES
>     ((SELECT i FROM csid), 'Some log message');
>   COMMIT;
>
> When inserting a new changeset, you fill the temporary table
> afterwards with curval('changeset_id_seq'). If you just want
> to add more referring lines, you seem to know the ID already
> can can just insert it. In any case, the following INSERTs into
> the "other tables" will look exactly the same, which seem to
> be your goal.
>
> bye,
>
> -christian-




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

Предыдущее
От: Christian Hammers
Дата:
Сообщение: Re: custom session variables?
Следующее
От: S H
Дата:
Сообщение: Re: Regarding template1 database