[GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as $$ if a=1 then select * from table1; else select * from table2; end if; $$ languge sql; which would than dynamically create

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Martijn van Oosterhout
On Tue, Dec 12, 2006 at 10:30:07AM +0100, Rikard Pavelic wrote: Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as snip Just setof record will do. As for the implicit

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Shoaib Mir
On Tue, Dec 12, 2006 at 10:30:07AM +0100, Rikard Pavelic wrote: Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as You can use a SETOF function as: CREATE OR REPLACE FUNCTION

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Shoaib Mir wrote: You can use a SETOF function as: CREATE OR REPLACE FUNCTION get_test_data (numeric) RETURNS SETOF RECORD AS $$ DECLARE temp_recRECORD; BEGIN FOR temp_rec IN (SELECT ename FROM emp WHERE sal $1) LOOP RETURN NEXT temp_rec; END LOOP; RETURN;

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Matthias . Pitzl
] [mailto:[EMAIL PROTECTED] On Behalf Of Rikard Pavelic Sent: Tuesday, December 12, 2006 3:06 PM To: Shoaib Mir; pgsql-general@postgresql.org Subject: Re: [GENERAL] returning parameters from function This doesn't work. ;( I get ERROR: a column definition list is required for functions

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Martijn van Oosterhout wrote: snip Just setof record will do. As for the implicit declaration of variable names, that's harder. I don't know if you can do that without making things very ambiguous. I know setof record will do if I explicitly name OUT parameters. But I want Postgre to figure

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Richard Huxton
Rikard Pavelic wrote: Martijn van Oosterhout wrote: snip Just setof record will do. As for the implicit declaration of variable names, that's harder. I don't know if you can do that without making things very ambiguous. I know setof record will do if I explicitly name OUT parameters. But I

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Richard Huxton wrote: Rikard Pavelic wrote: I know setof record will do if I explicitly name OUT parameters. But I want Postgre to figure out for himself what parameters to return as out parameters. I don't see why it would make things very ambiguous. Think about what happens if you use

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Shoaib Mir
You can use it as: SELECT * FROM get_test_data(1000) AS t1 (emp_name VARCHAR); -- Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 12/12/06, Rikard Pavelic [EMAIL PROTECTED] wrote: Shoaib Mir wrote: You can use a SETOF function as: CREATE OR REPLACE FUNCTION get_test_data