Re: [SQL] Dynamic Query

2009-10-19 Thread Tom Lane
Andrew Hall writes: > Is there a recommended way to translate this function into plpgSQL which > would protect me from SQL Injection (most important for me) and use bind > variables (of secondary importance? See quote_literal() and/or quote_nullable(). On the whole though I think you'd be best

[SQL] Dynamic Query

2009-10-19 Thread Andrew Hall
Hi, I'm a novice PostgreSQL developer from an Oracle background and am trying to replicate some Oracle functionality in PostgreSQL / plpgSQL. I'm trying to write a stored function to implement a search: the function has several parameters - the value of any could be 'null' on any given invocat

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Gaetano Mendola
Kumar wrote: Dear Friends, I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to generate a dynamic query to fetch the next month interval. select now()+ interval'1 month'; -- This is working fine. I wanna dynamically assign the interval number. i,e --> select now()+ interval

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Stephan Szabo
On Mon, 10 Nov 2003, Kumar wrote: > select now()+ interval'1 month'; -- This is working fine. > > I wanna dynamically assign the interval number. i,e --> select now()+ > interval'n month'; If n is an integer, I'd suggest something like select now() + n * interval '1 month'; rather than messing

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread George Weaver
ect now(); > now > --- > 2003-11-10 17:06:36.783779+00 > (1 row) > > test=> execute 'select now()'; > ERROR: parser: parse error at or near "'select now()'" at character 9 > test=> > > > Rega

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Christoph Haller
3779+00 > > (1 row) > > > > test=> execute 'select now()'; > > ERROR: parser: parse error at or near "'select now()'" at character 9 > > test=> > > > > > > Regards > > kumar > > > > ---

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Achilleus Mantzios
x27;" at character 9 > test=> > > > Regards > kumar > > ----- Original Message - > From: "Christoph Haller" <[EMAIL PROTECTED]> > To: ""Kumar"" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Mon

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Kumar
or near "'select now()'" at character 9 test=> Regards kumar - Original Message - From: "Christoph Haller" <[EMAIL PROTECTED]> To: ""Kumar"" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, November 10, 2003

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Christoph Haller
> > Dear Friends, > > I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to generate= > a dynamic query to fetch the next month interval. > > select now()+ interval'1 month'; -- This is working fine. > > I wanna dynamically assign the interval number. i,e --> select now()+ inter=

[SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Kumar
Dear Friends,   I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to generate a dynamic query to fetch the next month interval.   select now()+ interval'1 month';  -- This is working fine.   I wanna dynamically assign the interval number. i,e --> select now()+ interval'n month'