pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedhelp with function and quotes
2+ messages / 2 participants
[nested] [flat]
* help with function and quotes
@ 2001-11-07 17:37 qradius@qnet.com.pe
0 siblings, 1 reply; 2+ messages in thread
From: qradius@qnet.com.pe @ 2001-11-07 17:37 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
---------------------------------------------
Este mensaje fue enviado a través de Qnet
http://www.qnet.com.pe
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: help with function and quotes
@ 2001-11-08 16:44 Josh Berkus <josh@agliodbs.com>
parent: qradius@qnet.com.pe
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2001-11-08 16:44 UTC (permalink / raw)
To: pgsql-sql
Ernesto,
> 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';
Please go to techdocs (http://techdocs.postgresql.org/) and read Roberto
Mello's revised PL/pgSQL documentation (Roberto, is this part of the
main docs, yet?). There's several mistakes in this simple procedure, in
addition to the one you asked about. Or you could read the first 2-3
chapters of any book on PL/SQL for Oracle.
Then, try this:
CREATE FUNCTION addtime(integer) RETURNS INTEGER AS '
DECLARE
additional ALIAS FOR $1;
BEGIN
update mytable set mytime=now()+ INTERVAL( to_char(additional,
''9999'') || '' seconds'');
RETURN additional;
END;'
LANGUAGE 'plpgsql';
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-11-08 16:44 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 17:37 help with function and quotes qradius@qnet.com.pe
2001-11-08 16:44 ` Josh Berkus <josh@agliodbs.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