Re: [SQL] functions are returns columns

2007-11-10 Thread Michele Petrazzo - Unipex srl
Pavel Stehule wrote: CREATE FUNCTION getfoo(int) RETURNS foo AS $$ SELECT fooid, foosubid FROM foo WHERE fooid = $1 LIMIT 1; $$ LANGUAGE SQL; this return only one value, I need all the values that return the query or CREATE FUNCTION getfoo(int) RETURNS SETOF foo AS $$ SELECT fooid, foosubi

Re: [SQL] functions are returns columns

2007-11-10 Thread Gregory Stark
"Michele Petrazzo - Unipex srl" <[EMAIL PROTECTED]> writes: > I try with: > CREATE FUNCTION getfoo (IN int, OUT int, OUT int) AS $$ >SELECT fooid, foosubid FROM foo WHERE fooid = $1; > $$ LANGUAGE SQL; > > but only one row returned... You're almost there: CREATE FUNCTION getfoo (IN int, OUT

Re: [SQL] functions are returns columns

2007-11-10 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > You're almost there: > CREATE FUNCTION getfoo (IN int, OUT int, OUT int) returns setof > record(int,int) AS $$ > SELECT fooid, foosubid FROM foo WHERE fooid = $1; > $$ LANGUAGE SQL; Not quite --- it's just "returns setof record". The output column t

Re: [SQL] functions are returns columns

2007-11-10 Thread Gregory Stark
"Tom Lane" <[EMAIL PROTECTED]> writes: > Gregory Stark <[EMAIL PROTECTED]> writes: >> You're almost there: > >> CREATE FUNCTION getfoo (IN int, OUT int, OUT int) returns setof >> record(int,int) AS $$ >> SELECT fooid, foosubid FROM foo WHERE fooid = $1; >> $$ LANGUAGE SQL; > > Not quite --- it'

Re: [SQL] functions are returns columns

2007-11-10 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > "Tom Lane" <[EMAIL PROTECTED]> writes: >> Not quite --- it's just "returns setof record". > I did test my example before posting it: > postgres=# postgres=# CREATE or replace FUNCTION getfoo (IN int, OUT int, OUT > int) returns setof record(int,int)AS

[SQL] general question on optimizer

2007-11-10 Thread chester c young
I have found that in many complex queries left join is exponentially faster than a (not) exists clause. I don't understand why, generally speaking, this is so frequently so effective. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam