[SQL] problem with overloading the "coalesce" function

2006-03-06 Thread Emil Rachovsky
Hi, I am trying to overload the "coalesce" function to accept an integer and a string. Here it is : CREATE OR REPLACE FUNCTION "coalesce"(a int4, b "varchar") RETURNS "varchar" AS $BODY$ begin if (a is null ) then return b; else return cast(a as varchar(15)); end if; end $BODY$ LAN

Re: [SQL] [GENERAL] problem with overloading the "coalesce" function

2006-03-06 Thread Richard Huxton
Emil Rachovsky wrote: Hi, I am trying to overload the "coalesce" function to accept an integer and a string. Here it is : CREATE OR REPLACE FUNCTION "coalesce"(a int4, b "varchar") RETURNS "varchar" AS ... I have added it to pg_catalog, but still I cant't use it, I get an error on the seco

Re: [SQL] [GENERAL] problem with overloading the "coalesce" function

2006-03-06 Thread Emil Rachovsky
--- Richard Huxton wrote: > Emil Rachovsky wrote: > > > > Hi, > > I am trying to overload the "coalesce" function to > > accept an integer and a string. Here it is : > > > > CREATE OR REPLACE FUNCTION "coalesce"(a int4, b > > "varchar") > > RETURNS "varchar" AS > ... > > I have added it to

Re: [SQL] [GENERAL] problem with overloading the "coalesce" function

2006-03-06 Thread Richard Huxton
Emil Rachovsky wrote: --- Richard Huxton wrote: Emil Rachovsky wrote: Hi, I am trying to overload the "coalesce" function to accept an integer and a string. Here it is : CREATE OR REPLACE FUNCTION "coalesce"(a int4, b "varchar") RETURNS "varchar" AS ... I have added it to pg_catalog, b

[SQL] Help with "missing FROM clause" needed

2006-03-06 Thread Thomas Beutin
Hi, to be compatible with the postgres standard syntax in 8.1.x i need some help for rewriting my "delete" statements ("select" is not a problem). I use the following statement: DELETE FROM partner_zu WHERE partner_zu.pa_id = partner.id AND partner_zu.m_id = '25' AND partner.open = 'm' AND pa

Re: [SQL] Help with "missing FROM clause" needed

2006-03-06 Thread A. Kretschmer
am 06.03.2006, um 14:25:52 +0100 mailte Thomas Beutin folgendes: > Hi, > > to be compatible with the postgres standard syntax in 8.1.x i need some > help for rewriting my "delete" statements ("select" is not a problem). I > use the following statement: > > DELETE FROM partner_zu > WHERE partne

Re: [SQL] Help with "missing FROM clause" needed

2006-03-06 Thread Richard Huxton
Thomas Beutin wrote: Hi, to be compatible with the postgres standard syntax in 8.1.x i need some help for rewriting my "delete" statements ("select" is not a problem). I use the following statement: DELETE FROM partner_zu WHERE partner_zu.pa_id = partner.id AND partner_zu.m_id = '25' AND par

Re: [SQL] Help with "missing FROM clause" needed

2006-03-06 Thread Thomas Beutin
Richard Huxton wrote: Thomas Beutin wrote: Hi, to be compatible with the postgres standard syntax in 8.1.x i need some help for rewriting my "delete" statements ("select" is not a problem). I use the following statement: DELETE FROM partner_zu WHERE partner_zu.pa_id = partner.id AND partne

Re: [SQL] Help with "missing FROM clause" needed

2006-03-06 Thread A. Kretschmer
am 06.03.2006, um 15:27:54 +0100 mailte Thomas Beutin folgendes: > >>DELETE FROM partner_zu > >>WHERE partner_zu.pa_id = partner.id > >>AND partner_zu.m_id = '25' > >>AND partner.open = 'm' > >>AND partner.a_id = partner_zu.a_id > >>AND partner_zu.a_id = '104335887112347'; > >DELETE FROM partner_z

[SQL] Syntax error in Execute statement

2006-03-06 Thread Emil Rachovsky
Hello, I created a function "coalescec" which behaves the same as coalesce, but uses an integer and a string. Now I'm getting an error in the folowing statements : query := 'select "UID" from S_Users_To_Connection where ConnID = ' || coalescec(conn_id,'null'); execute query into nUID; ERROR:

Re: [SQL] Help with "missing FROM clause" needed

2006-03-06 Thread Greg Stark
"A. Kretschmer" <[EMAIL PROTECTED]> writes: > *untested* > DELETE FROM partner_zu using partner > WHERE partner_zu.pa_id = partner.id > ... > The point is the 'using ...' You can also just set the add_missing_from to true for that one session if you prefer. I don't think there's any plans to remo

Re: [SQL] [GENERAL] Syntax error in Execute statement

2006-03-06 Thread Michael Fuhr
On Mon, Mar 06, 2006 at 07:21:58AM -0800, Emil Rachovsky wrote: > I created a function "coalescec" which behaves the > same as coalesce, but uses an integer and a string. Is there a reason you can't use the standard COALESCE and cast the integer value to text/varchar? > Now I'm getting an error i

Re: [SQL] [GENERAL] problem with overloading the "coalesce" function

2006-03-06 Thread Tom Lane
Richard Huxton writes: > Hmm - looking at the source (and \df in psql) it seems the basic problem > is that COALESCE() isn't a function. If it were an ordinary function, it couldn't satisfy the property of not evaluating "unused" arguments ... regards, tom lane