Plpgsql function and variable substitute - Mailing list pgsql-general

From Jiří Němec
Subject Plpgsql function and variable substitute
Date
Msg-id 1128273205.20070516151117@menea.cz
Whole thread Raw
Responses Re: Plpgsql function and variable substitute
Re: Plpgsql function and variable substitute
List 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/


pgsql-general by date:

Previous
From: marcelo Cortez
Date:
Subject: Re: dns less connection
Next
From: "Ian Harding"
Date:
Subject: Re: Postgres Printed Manuals