session_user id

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: session_user id
Date: 2005-02-24 18:35:21
Message-ID: 20050224182645.M35953@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi All,

I have the following table that is used to log the receipt of an item. As you
can see the receipt_timestamp uses a default of now. I would like to add a
column with a default of the session user. In order to avoid column length
sizing issues and keep the table small I thought that I could store the
session_user id ( int4 ) instead of the text name ( varchar(?) ). How can
this be done?

CREATE TABLE purchase_order.tbl_receiving
(
po_number int4 NOT NULL,
po_line int2 NOT NULL,
receipt_number serial NOT NULL,
quantity float4 NOT NULL,
receipt_timestamp timestamp NOT NULL DEFAULT ('now'::text)::timestamp(6)
with time zone,
CONSTRAINT tbl_receiving_pkey PRIMARY KEY (po_number, po_line, receipt_number),
CONSTRAINT tbl_receiving_fkey1 FOREIGN KEY (po_number, po_line) REFERENCES
purchase_order.tbl_line_item (po_number, po_line) ON UPDATE CASCADE ON DELETE
RESTRICT
)

Kind Regards,
Keith

Browse pgsql-novice by date

  From Date Subject
Next Message George Weaver 2005-02-24 19:44:24 Re: shutdown postmaster question
Previous Message operationsengineer1 2005-02-24 18:27:10 Re: shutdown postmaster question