Skip site navigation (1) Skip section navigation (2)

server variables ?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: server variables ?
Date: 2007-04-12 03:33:30
Message-ID: 461DA88A.3010008@gmx.net (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,

are there something like variables on the server-side that can be set by 
the client?

e.g. I'd like to store the user-id who created or updated a record.
I've allready got a trigger that sets a timestamp whenever a record is 
updated. It was cute if I could let this triggers store the user-id, too.

I'd like to open a connection when the client application starts.
The client should set a variable  userid  within this connection and 
every trigger would know who uses this connection right now.

BTW ... How would I use this variable as a DEFAULT value when it should 
be set just at the creation time of the record?
something like a collumn:
...
created_by_fk   integer   not null   default userid,
...

How could I use such a variables value in views?


Responses

pgsql-novice by date

Next:From: Phillip SmithDate: 2007-04-12 04:35:49
Subject: Re: trying to connect to PostgreSQL
Previous:From: Oliveiros CristinaDate: 2007-04-11 15:50:17
Subject: placing position numbers on a query output

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group