Re: custom session variables? - Mailing list pgsql-general

From Darren Duncan
Subject Re: custom session variables?
Date
Msg-id 51787D28.3080006@darrenduncan.net
Whole thread Raw
In response to Re: custom session variables?  (Christian Hammers <ch@lathspell.de>)
Responses Re: custom session variables?
List 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 by date:

Previous
From: Christian Hammers
Date:
Subject: Re: custom session variables?
Next
From: S H
Date:
Subject: Re: Regarding template1 database