Search Postgresql Archives

Re: Record with a field consisting of table rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> No, of course not. A function cannot return different
> amounts of different return-values in any language I know
> of.

Come on, you make it sound like it's something inconceivable or exotic,
even though pretty much any strongly-typed language with a post-1970s
type-system will allow a function to return tuples of arbitrary values.
Have you never come across Ocaml, Haskell, Scala, and so forth?


> You don't seem to grasp the essence of what a set-returning
> function does; they are similar to Iterators in Java or
> functions that yield a result (as opposed to returning one)
> in Python or cursors in SQL.
>
> You can't mix that with returning a single value, unless
> you do that each time the function is called for the next
> iteration (which happens to be what I did in my earlier
> example).
> 
> You could do something ugly by collecting the results in
> memory until you eventually return them in an array, but
> that would hardly be practical if your data sets get a
> little large.
> 
> You probably can return a tuple consisting of an int and a
> refcursor though. You'll need another function to loop
> through the refcursor to fetch the results, but you would
> sort of get what you apparently want. I can't see why you'd
> want that though.

Yes, the alternatives are indeed more cumbersome than they're worth.
I might as well split the original function into two separate functions...

Cheers,
Jon



      

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux