From efreyre@qnet.com.pe Wed Nov 7 16:20:47 2001 Received: from linux.qnet.com.pe ([200.37.231.132]) by postgresql.org (8.11.3/8.11.4) with SMTP id fA7GKjm11773 for ; Wed, 7 Nov 2001 11:20:47 -0500 (EST) (envelope-from efreyre@qnet.com.pe) Received: (qmail 5035 invoked from network); 7 Nov 2001 16:14:56 -0000 Received: from unknown (HELO mihost) (200.37.231.133) by 200.37.231.132 with SMTP; 7 Nov 2001 16:14:56 -0000 Message-ID: <000a01c167a8$3b430860$a164a8c0@mihost> From: "Ernesto Freyre" To: Subject: help with sintaxis of quotes on function Date: Wed, 7 Nov 2001 11:21:17 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0007_01C1677E.51C527A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200111/125 X-Sequence-Number: 5509 This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C1677E.51C527A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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=3Dnow+'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=3Dnow()+''additional seconds''; END; ' return 1; LANGUAGE 'plpgsql'; I know probably this doesn't works, justly I have doubts about how to impl= ement this since I want the funtion takes the variable additional , not the= string 'additional', What I should to consider? I read the documentation o= n pqsql language aboute using quotes but none case is resemblance to my cas= e. Can someone tell me an orientation about this? Thank you in advance. Ernesto ------=_NextPart_000_0007_01C1677E.51C527A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear Sirs:
 
Please I am attempting implement a functio= n that=20 update a column to current time + X seconds
 
So the query involved looks like:
 
update mytable set mytime=3Dnow+'X=20 seconds';
 
Here X is a integer value,
 
Now I need implement this on my function, = But I=20 have problems at implement this at quotes, e.g. my function could looks=20 like:
 
CREATE    FUNCTION=20 addtime(integer) RETURNS INTEGER AS '
DECLARE
   additional ALIAS FOR $1;
BEGIN
  update mytable set mytime=3Dnow()+'= 'additional=20 seconds'';
END;
'
return 1;
LANGUAGE 'plpgsql';
 
I know probably this doesn't  works, = justly I=20 have doubts about how to implement this since I want the funtion takes the= =20 variable additional , not the string 'additional', What I should to conside= r? I=20 read the documentation on pqsql language aboute using quotes but none case = is=20 resemblance to my case.
 
Can someone tell me an orientation about= =20 this?
 
Thank you  in advance.
 
Ernesto
 
 
 
------=_NextPart_000_0007_01C1677E.51C527A0-- From sszabo@megazone23.bigpanda.com Thu Nov 8 16:37:51 2001 Received: from megazone.bigpanda.com ([63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA8Gbpm07946 for ; Thu, 8 Nov 2001 11:37:51 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C5C3FD5DB; Thu, 8 Nov 2001 08:37:55 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id B971C5BDF; Thu, 8 Nov 2001 08:37:55 -0800 (PST) Date: Thu, 8 Nov 2001 08:37:55 -0800 (PST) From: Stephan Szabo To: Ernesto Freyre Cc: Subject: Re: help with sintaxis of quotes on function In-Reply-To: <000a01c167a8$3b430860$a164a8c0@mihost> Message-ID: <20011108083616.I53274-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200111/131 X-Sequence-Number: 5515 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);