Plpgsql function and variable substitute

From: Jiří Němec <konference(at)menea(dot)cz>
To: pgsql-general(at)postgresql(dot)org
Subject: Plpgsql function and variable substitute
Date: 2007-05-16 13:11:17
Message-ID: 1128273205.20070516151117@menea.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have searched the Internet for an answer but nothing works for me.

There is a plpgsql function which is used in a trigger. I need to
substitute a value "7" for "lifetime" (integer) SELECTed in a previous
query.

DECLARE
lifetime integer;

BEGIN

SELECT foo INTO lifetime FROM tblname;

UPDATE ....
SET expiretime = expiretime + interval '7 days'
WHERE .....

RETURN NEW;

END;

This doesn't work for me:

SET expiretime = expiretime + interval 'lifetime days'
SET expiretime = expiretime + interval || lifetime || 'days'

Thank you for your help or for a some useful link.

--
Jiri Nemec
http://www.meneashop.cz/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message marcelo Cortez 2007-05-16 13:19:44 Re: dns less connection
Previous Message Richard Huxton 2007-05-16 10:00:11 Re: [GENERAL] OIDs - file objects, are damaged by PostgreSQL.