pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
help with sintaxis of quotes on function
2+ messages / 2 participants
[nested] [flat]

* help with sintaxis of quotes on function
@ 2001-11-07 16:21  Ernesto Freyre <efreyre@qnet.com.pe>
  0 siblings, 1 reply; 2+ messages in thread

From: Ernesto Freyre @ 2001-11-07 16:21 UTC (permalink / raw)
  To: pgsql-sql

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';

I know probably this doesn't  works, justly I have doubts about how to implement this since I want the funtion takes the variable additional , not the string 'additional', What I should to consider? I read the documentation on pqsql language aboute using quotes but none case is resemblance to my case.

Can someone tell me an orientation about this?

Thank you  in advance.

Ernesto

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: help with sintaxis of quotes on function
@ 2001-11-08 16:37  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Ernesto Freyre <efreyre@qnet.com.pe>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2001-11-08 16:37 UTC (permalink / raw)
  To: Ernesto Freyre <efreyre@qnet.com.pe>; +Cc: pgsql-sql

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);





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-11-08 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07 16:21 help with sintaxis of quotes on function Ernesto Freyre <efreyre@qnet.com.pe>
2001-11-08 16:37 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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