Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > PostgreSQL > help in function returning numeric data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-07, 06:11
guillermoariast guillermoariast is offline
Registered User
 
Join Date: Dec 2007
Posts: 1
help in function returning numeric data

Hi, i would like to return a numeric data from this function. I want to modify the nature of the function by a parameter.

see line:
sql:= ' res:= select (4+5.2)';

This is where i would like to modify by parameter


CREATE OR REPLACE FUNCTION modelo.test2()
RETURNS numeric AS
$BODY$
declare
res numeric; sql text;
begin
sql:= ' res:= select (4+5.2)';
execute sql;
return res;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;


This function does not work. ¿Why?.
I receive comments or solutions.
Thanks
Reply With Quote
  #2 (permalink)  
Old 12-13-07, 02:13
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,359
I don't understand. You want to pass parameters to the function? So that it sums the two numbers, and returns the result?
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #3 (permalink)  
Old 12-13-07, 13:11
amthomas amthomas is offline
Registered User
 
Join Date: May 2005
Location: San Antonio, Texas
Posts: 134
yeah.. I am not sure either.

you should post the error you get too.

as a side note, I don't believe you need to use volatile on this function since you aren't really doing anything to tables.
__________________
Vi veri veniversum vivus vici
By the power of truth, I, a living man, have conquered the universe
Reply With Quote
  #4 (permalink)  
Old 12-14-07, 01:40
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,359
By the way - Have you installed pl/pgsql? (using a CREATE LANGUAGE statement?) It doesn't come installed by default, even though you selected it during an install. That only makes it AVAILABLE to install.

ref http://www.postgresql.org/docs/8.2/s...g-install.html
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Last edited by loquin : 12-14-07 at 01:46.
Reply With Quote
  #5 (permalink)  
Old 12-14-07, 04:22
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 654
Quote:
Originally Posted by loquin
It doesn't come installed by default, even though you selected it during an install. That only makes it AVAILABLE to install.
At least on windows this is not true. After installer was finished I could use the installed languages right away.
Reply With Quote
  #6 (permalink)  
Old 12-14-07, 20:54
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,359
Actually, I had to, on a windows install. That was on v8.1 POSSIBLY, that is not the case on v8.2. When I upgraded to 8.2, I didn't have to reinstall the language, but, I thought that the language the language got carried along as a part of the upgrade process.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Last edited by loquin : 12-14-07 at 20:58.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On