On Fri, 27 Jul 2001, John Oakes wrote:

> Can anyone tell me why this always return 1?  Thanks!
> 
> CREATE FUNCTION passrate(date, date, text) RETURNS float AS '
> 
> DECLARE
>  begindate ALIAS FOR $1;
>  enddate ALIAS FOR $2;
>  passfail ALIAS FOR $3; 
>  ret float;
>  countp float;
>  counttotal float;
>  
> 
> BEGIN
> 
>  SELECT INTO countp COUNT(*)
>  FROM benchmark
>  WHERE passfail = passfail;

Ehhh? Were you expecting that to substitue
for *one* of those passfails and not the
other? ;)

Rename the alias variable to something else.

> 
>  SELECT INTO counttotal COUNT(*)
>  FROM benchmark;
> 
>  ret := countp / counttotal;
>  RETURN ret;
> END;'
> LANGUAGE 'plpgsql';


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to