Custom Field for a table row returned from stored procedure

From: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Custom Field for a table row returned from stored procedure
Date: 2010-01-11 08:41:32
Message-ID: 599603.71427.qm@web65713.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a "lot" table with 2 columns, with one of the column is current timestamp.

I try to return another custom fields, which its calculation is based on timestamp.

(For simplicity, I include only 1 field in following example)

CREATE OR REPLACE FUNCTION create_lot(text)
RETURNS lot AS
$BODY$DECLARE
configurationFile ALIAS FOR $1;
_lot lot;
BEGIN
INSERT INTO lot(configuration_file)
VALUES(configurationFile) RETURNING *, extract(epoch from timestamp) as timestampex INTO _lot;
return _lot;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION create_lot(text) OWNER TO postgres;

I expect the table returns two field for a single row. 1 is configuration_file, 2nd is timestamp, 3rd is timestampex.

However, I only able to retrieve configuration_file and timestamp. How can I obtain timestampex too?

Thanks and Regards
Yan Cheng CHEOK

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif Biberg Kristensen 2010-01-11 08:43:36 Re: How to get DATE in server locale format
Previous Message Craig Ringer 2010-01-11 08:20:23 Re: Get Unix timestamp from SQL timestamp through libpq