Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    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


  3. #3
    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

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    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
    Last edited by loquin; 12-14-07 at 01:46.
    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


  5. #5
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    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.

  6. #6
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    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.
    Last edited by loquin; 12-14-07 at 20:58.
    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •