Assigning a return value from a function to a variable. - Mailing list pgsql-novice

From Betsy Barker
Subject Assigning a return value from a function to a variable.
Date
Msg-id 20040715170701.49ebc5d4.betsy.barker@supportservicesinc.com
Whole thread Raw
Responses Re: Assigning a return value from a function to a variable.
List pgsql-novice
Hello, Even though I'm new to postgresql, I've been a programmer for 18+ years. Working mainly with Unix and databases
(Oracle,sybase, informix, db2) and languages such as C,Perl, and lately Java. I'm currently working with a J2EE system
runningon Orion working with PostgreSQL on Linux.  

I am rewriting a long running J2EE piece of the application as a PL/pgSQL stored procedure and I'm having an issue with
somethingthat is as old as programming languages themselves. I'm trying to assign a return value from a function to a
variable.Sounds simple enough, but I still do not have the syntax down - after spending a day reading and searching. I
wonderif you could help. 

The function is called calc_facility_percentiles and is defined to return a float. the fifthpct variable is a float.The
function actually has a return statement at the end of it that is returning a float. So, I do not know what the issue
is.I've tried SELECT INTO, I've tried  SELECT INTO with another SELECT. I've tried the direct assignment of :=  This is
justnuts! None of them work. See all the versions I've tried below: 



                        funcparm        := ''05'';
                         --SELECT INTO fifthpct calc_facility_percentiles(funcparm,_wagerateid);
                         --SELECT INTO fifthpct SELECT calc_facility_percentiles(''05'',_wagerateid);
                         --fifthpct :=  SELECT calc_facility_percentiles(''05'',_wagerateid);
                         --fifthpct :=  calc_facility_percentiles(''05'',_wagerateid);
                         fifthpct :=  calc_facility_percentiles(funcparm,_wagerateid);

Here is the function signature:
CREATE OR REPLACE FUNCTION calc_facility_percentiles(VARCHAR(2),INTEGER) RETURNS FLOAT AS

I'm wondering if I'm not handling the varchar(2) correctly?

The error is:
Error occurred while executing PL/pgSQL function calc_facilities
WARNING:  line 166 at assignment
ERROR:  syntax error at or near ";"

So, I guess my question is : How to I assign the returning float value from my function to a variable?

Thank you very much for any help you can give me.

Betsy Barker


pgsql-novice by date:

Previous
From: "M. Bastin"
Date:
Subject: Re: Extended query: prepared statements list?
Next
From: Julian Leyh
Date:
Subject: Re: postgres account default password