Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2010
    Posts
    6

    Question Unanswered: Which is the preferred way to call a function?

    Hi,

    I'm migrating some procs from Sybase. That's a treat in itself. I've finally got the proc to return the same data.

    What I'm now wondering (and don't know the answer to) is: What is the preferred way to call the proc?

    In sybase, you'd do:

    Code:
    exec sp_procNameHere 'foo', 'bar'
    For postgresql, I can do this:

    Code:
    select sp_procNameHere('foo', 'bar')
    or

    Code:
    select * FROM sp_procNameHere('foo', 'bar')
    which is correct/best (and why?)

    Thanks.

  2. #2
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    Both will work. The second format was designed for functions that return records or sets of records. I generally use the first format. And if you want to explode the tuple returned from a function you can also do this

    SELECT (tupleReturningFunction('foo','bar')).*

  3. #3
    Join Date
    Aug 2010
    Posts
    6
    my proc from sybase returns a table of data. I think in postgreSQL (PG?) this is referred to generally as 'sets' ?

    What does "explode the tuple" mean?

Posting Permissions

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