Re: [SQL] Function Syntax involving pipes and ' marks?

2008-09-09 Thread Alvaro Herrera
Ruben Gouveia escribió: > No matter how many times i try, i can't seem to get the write amount of ' > marks around the date parameters in my v_where declaration. What am i doing > wrong here? Apparently you're not aware that you can nest the $$ quote marks. You could just use $a$ to assign to the

[SQL] Function Syntax involving pipes and ' marks?

2008-09-09 Thread Ruben Gouveia
No matter how many times i try, i can't seem to get the write amount of ' marks around the date parameters in my v_where declaration. What am i doing wrong here? v_stmt should look like this if done correctly: select count(distinct m.id) from (select id, greatest(max(last_p),max(last_b)) as date_

Re: [SQL] How to provide password to pg_dump command ?

2008-09-09 Thread Milen A. Radev
Emi Lu написа: > Good morning, > > Is there a way that I can pass "pwd" to pg_dump command please? > > > I tried to pg_dump in java, but do not know how to pass password. Recommended method - http://www.postgresql.org/docs/current/static/libpq-pgpass.html Not recommended method - http://www.p

[SQL] How to provide password to pg_dump command ?

2008-09-09 Thread Emi Lu
Good morning, Is there a way that I can pass "pwd" to pg_dump command please? I tried to pg_dump in java, but do not know how to pass password. Thanks a lot! -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpre

Re: [SQL] Function syntax ?

2008-09-09 Thread Ruben Gouveia
It appears there is already a greatest() and least() function available...so no need for creating this function. On Tue, Sep 9, 2008 at 11:16 AM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: > thanks pavel...that worked! I like the simplicity of your first suggestion. > > > On Tue, Sep 9, 2008 at 11:

Re: [SQL] Function syntax ?

2008-09-09 Thread Ruben Gouveia
thanks pavel...that worked! I like the simplicity of your first suggestion. On Tue, Sep 9, 2008 at 11:05 AM, Pavel Stehule <[EMAIL PROTECTED]>wrote: > try > > create or replace function fcn_max_dt(p_dt timestamp without time zone, > p_dt2 timestamp without ti

Re: [SQL] Function syntax ?

2008-09-09 Thread Richard Huxton
Scott Marlowe wrote: > On Tue, Sep 9, 2008 at 11:55 AM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: >> Does this syntax look correct? Can anyone think of a better way to write >> this? >> >> This function will accept two timestamp parameters and determine the highest >> of the two? [snip] > It certain

Re: [SQL] Function syntax ?

2008-09-09 Thread Scott Marlowe
That's not what I copied and pasted in. Leave out the v_dt := p_dt; > v_dt2 := p_dt2; lines and turn the v into p in the rest of the function. On Tue, Sep 9, 2008 at 12:11 PM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: > When i tried that, i got the following error: > > create or replace fu

Re: [SQL] Function syntax ?

2008-09-09 Thread Pavel Stehule
try create or replace function fcn_max_dt(p_dt timestamp without time zone, p_dt2 timestamp without time zone) returns imestamp without time zone as $$ select greatest($1,$2); $$ language sql; or begin return greatest(p_dt, p_dt2); end; $$ language plpgsq

Re: [SQL] Function syntax ?

2008-09-09 Thread Ruben Gouveia
When i tried that, i got the following error: create or replace function fcn_max_dt(p_dt timestamp without time zone, p_dt2 timestamp without time zone) returns timestamp without time zone as $$ BEGIN v_dt := p_dt; v_dt2 := p_dt2; if v_dt >= v_

Re: [SQL] Function syntax ?

2008-09-09 Thread Scott Marlowe
On Tue, Sep 9, 2008 at 11:55 AM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: > Does this syntax look correct? Can anyone think of a better way to write > this? > > This function will accept two timestamp parameters and determine the highest > of the two? > > create or replace function fcn_max_dt(p_dt

[SQL] Function syntax ?

2008-09-09 Thread Ruben Gouveia
Does this syntax look correct? Can anyone think of a better way to write this? This function will accept two timestamp parameters and determine the highest of the two? create or replace function fcn_max_dt(p_dt timestamp without time zone, p_dt2 timestamp wit

Re: [SQL] PL/pgSQL function syntax question?

2008-09-09 Thread Lennin Caro
--- On Mon, 9/8/08, Ruben Gouveia <[EMAIL PROTECTED]> wrote: > From: Ruben Gouveia <[EMAIL PROTECTED]> > Subject: [SQL] PL/pgSQL function syntax question? > To: "pgsql-sql" > Date: Monday, September 8, 2008, 9:40 PM > i get the following error when i try and create the > following function: >