From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Ernesto Freyre <efreyre@qnet.com.pe>
Cc: pgsql-sql@postgresql.org
Subject: Re: help with sintaxis of quotes on function
Date: Thu, 8 Nov 2001 08:37:55 -0800 (PST)
Message-ID: <20011108083616.I53274-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <000a01c167a8$3b430860$a164a8c0@mihost>
On Wed, 7 Nov 2001, Ernesto Freyre wrote:
> Dear Sirs:
>
> Please I am attempting implement a function that update a column to current time + X seconds
>
> So the query involved looks like:
>
> update mytable set mytime=now+'X seconds';
>
> Here X is a integer value,
>
> Now I need implement this on my function, But I have problems at
> implement this at quotes, e.g. my function could looks like:
>
> CREATE FUNCTION addtime(integer) RETURNS INTEGER AS '
> DECLARE
> additional ALIAS FOR $1;
> BEGIN
> update mytable set mytime=now()+''additional seconds'';
> END;
> '
> return 1;
> LANGUAGE 'plpgsql';
This may work as the update:
update mytable set mytime=now()+CAST((additional || '' seconds'')
AS INTERVAL);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, efreyre@qnet.com.pe
Subject: Re: help with sintaxis of quotes on function
In-Reply-To: <20011108083616.I53274-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox