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

    Join Date
    May 2001
    Location
    Nashville
    Posts
    50
    Rep Power
    13

    Functions And PostgreSQL


    I was wondering if It is possible to return a whole recordset from a function. I managed to return one column, but what if I want to select several columns from a table.
    This works fine with a view, but I have not found a way to pass parameters into a view...I need a little of both..
    Any help anybody?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    15
    I think functions, by nature, will only allow you to return one value. What are you trying to return that can't be done with a view?
  4. #3
  5. No Profile Picture
    hmm...
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Nashville
    Posts
    50
    Rep Power
    13

    Just trying to store the procedures in postgres


    I would just like to store my SQL statements in postgres so I can re-use them. Like a stored procedure in MS SQL (don't want to go there..). Call a function in the database and pass my parameters to it. In return I get the recordset.
    For ex.
    I pass a userid to a function and have it return all the users data to me in a recordset.
    Sorry for not replying sooner...Have not been in here for a while.
  6. #4
  7. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Visit the PostgreSQL Cookbook. It is a website where they are starting a library of example functions for PostgreSQL: http://www.brasileiro.net/postgres/cookbook/

    You might find some helpful examples there.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com
  8. #5
  9. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    From Bruce Momjiam's book PostrgreSQL Introduction and Concepts:

    "Although most functions return only one value, SQL functions can return multiple values using SETOF."

    See http://www.ca.postgresql.org/docs/aw...k/node164.html
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com
  10. #6
  11. No Profile Picture
    hmm...
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Nashville
    Posts
    50
    Rep Power
    13
    Thanks. I will check those things out.

IMN logo majestic logo threadwatch logo seochat tools logo