#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0

    function [POSTGRES]


    posted March 07, 2003 05:54

    --------------------------------------------------------------------------------
    tbl_prova:

    prova | prova2
    ---------------
    sma | sma2
    sma3 | sma4

    Hi,
    i'm using this function:

    create fct_prova() returns setof tbl_prova as'
    select * from tbl_prova;
    ' language sql;

    When i recall this function with:
    select fct_prova();
    I see only 2 rows with (probably) the oid.

    How can i see the real text in the cols when i use the function ftc_prova()? (i must specify more argtype? where?).
    Tnx a lot.
    Smauroz
  2. #2
  3. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    You're not telling it what to SELECT FROM in the return:
    Code:
    select * from fct_prova();
    OR
    select prova from fct_prova();
    OR 
    select prova2 from fct_prova();
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0

    ?


    if i specify select * from fct_prova();
    give me an error only ... when i recall the function with
    select fct_prova();
    return some results...probably I have not understood that you are making to see me.
    Can u specify all codes plz.
    tnx
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0
    create fct_prova() returns setof tbl_prova as'
    select * from tbl_prova;
    ' language sql;

    select * from fct_prova() ;

    parser: parse error at or near "("

    how can i do?
    tnx
  8. #5
  9. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    It's CREATE FUNCTION, not just CREATE.
    Code:
    CREATE FUNCTION function_whatever() ...
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0
    yes...sorry for the error in the post but in the real code i write CREATE FUNCTION....is'n this the problem...other idea?
    tnx a lot
    SMA
  12. #7
  13. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    Are you sure that's exactly how you created the function? And what are the details on the tables? I take it that the two columns are just varchar( ) columns?

    And what version of postgres are you using?
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0
    function was create.
    the colums are varchar but whe i select function returns the table's oid (i think).
    the database's version is the 7.2 not the last one (7.3)
    Last edited by smauroz; March 21st, 2003 at 11:27 AM.

IMN logo majestic logo threadwatch logo seochat tools logo