| From: | Betsy Barker <betsy(dot)barker(at)supportservicesinc(dot)com> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Assigning a return value from a function to a variable. |
| Date: | 2004-07-15 23:07:01 |
| Message-ID: | 20040715170701.49ebc5d4.betsy.barker@supportservicesinc.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 running on 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 something that 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 wonder if 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 just nuts! 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2004-07-16 03:35:31 | Re: Assigning a return value from a function to a variable. |
| Previous Message | Julian Leyh | 2004-07-15 22:30:55 | Re: postgres account default password |