Re: [SQL] returning values from dynamic SQL to a variable

2013-01-15 Thread Karl Grossner
Pavel - RETURN QUERY EXECUTE worked, many thanks for responding so quickly. The docs show no relevant examples, so for anyone else, something like this create or replace function getRowsE( OUT element character(1), OUT name character varying(100), OUT sum numeric ) returns setof record a

Re: [SQL] returning values from dynamic SQL to a variable

2013-01-15 Thread Pavel Stehule
Hello you can use RETURN QUERY EXECUTE statement http://www.postgresql.org/docs/9.1/interactive/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING Regards Pavel Stehule 2013/1/15 kgeographer : > I have a related problem and tried the PERFORM...EXECUTE pattern suggested > but no matte

Re: [SQL] returning values from dynamic SQL to a variable

2013-01-15 Thread kgeographer
I have a related problem and tried the PERFORM...EXECUTE pattern suggested but no matter where I put PERFORM I get 'function not found' errors. I want to loop through id values returned by a query and execute another with each i as a parameter. Each subquery will return 6-8 rows. This is a simplif

Re: [SQL] returning values from dynamic SQL to a variable

2012-09-10 Thread Sergey Konoplev
On Sat, Sep 8, 2012 at 11:39 PM, James Sharrett wrote: > Sql := 'select max(run number) into v_runnumber from ' || MySchema || > '.log_table;'; > Execute Sql; > > I get the following error message (even though the resulting value in the > text variable Sql is valid code): > > ERROR: query string a