Re: [GENERAL] Why is this function wrong

2005-10-24 Thread [EMAIL PROTECTED]
Johan Wehtje wrote: > This is probably obvious but I am not seeing what is going wrong with > this function definition: > > CREATE OR REPLACE FUNCTION "public"."cproc_hli" (bgtemp NUMERIC, > humidity NUMERIC, wspeed NUMERIC) RETURNS NUMERIC AS > IF ($1 < 25) > THEN > SELECT (10.66 * (0.28 * $2)+(1.

Re: [GENERAL] Why is this function wrong

2005-10-24 Thread [EMAIL PROTECTED]
slight modification to the previous post, sorry, see http://www.postgresql.org/docs/8.0/interactive/plpgsql-structure.html for the real docs. CREATE OR REPLACE FUNCTION "public"."cproc_hli" (bgtemp NUMERIC, humidity NUMERIC, wspeed NUMERIC) RETURNS NUMERIC AS $$ BEGIN IF ($1 < 25) THEN SELEC

Re: [GENERAL] Why is this function wrong

2005-10-24 Thread Johan Wehtje
Thanks for your help, I adjusted the function after a better reading of the pl/Sql chapter - and feel I posted in haste. Hopefully though it may prove useful to someone else. Cheers Johan Wehtje Thomas F. O'Connell wrote: On Oct 24, 2005, at 11:27 AM, Johan Wehtje wrote: This is probably obv

Re: [GENERAL] Why is this function wrong

2005-10-24 Thread Thomas F. O'Connell
On Oct 24, 2005, at 11:27 AM, Johan Wehtje wrote: This is probably obvious but I am not seeing what is going wrong with this function definition: CREATE OR REPLACE FUNCTION "public"."cproc_hli" (bgtemp NUMERIC, humidity NUMERIC, wspeed NUMERIC) RETURNS NUMERIC AS IF ($1 < 25) THEN SELECT

Re: [GENERAL] Why is this function wrong

2005-10-24 Thread Csaba Nagy
The variant you're showing here has absolutely no quoting for the function body. You need to quote the body, and escape the quotes you have inside the body (in this example you don't have any). Wrap the body in BEGIN ... END. Also put semicolons after each statement end. Corrected code: CREATE O