Search Postgresql Archives

Re: custom session variables?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-




--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux