Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-14 Thread Gnanavel Shanmugam
-general@postgresql.org Sent: Wednesday, August 13, 2008 9:40:51 AM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi Subject: Re: [GENERAL] Need help returning record set from a dynamic sql query Murali, Tried the same method using FOR --LOOP with EXECUTE command similar function you described

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-14 Thread [EMAIL PROTECTED]
Cc: Willy-Bas Loos; pgsql-general@postgresql.org; [EMAIL PROTECTED] Subject: Re: [GENERAL] Need help returning record set from a dynamic sql query Just a thought Why can't you create a temporary table from your dynamic query and use that temp table in the for loop. Thnx, Gnanavel

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-13 Thread Klint Gore
[I'm not going to even try to work out that mess to quote it] The following works for me. You can even do it without dynamic sql (see fun_orderreport1). begin; -- dummy up some tables for self contained example create table orders (ordersid int, initiated date, company int, event int);

[GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread [EMAIL PROTECTED]
Hi, Iam new to Postgresql, now i need to create a Dynamic SQL Query for returning the record set based on my Input Parameters. I looked up some of the documents and worked out some more ... MY Postgresql Version In Local: 7.4 MY Postgresql Version In Development: 8.2 -- DROP TYPE ORDERREPORT;

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread Sathish Duraiswamy
Dear murali, We use psql for our ERP software .We found CREATE TYPE is useful in creating new data type similar to creating domain. For eg CREATE TYPE date_condition ( condition_id int, from_date date, to_datedate); Instead ,

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread [EMAIL PROTECTED]
, 2008 4:10 PM To: [EMAIL PROTECTED] Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Need help returning record set from a dynamic sql query Dear murali, We use psql for our ERP software .We found CREATE TYPE is useful in creating new data type similar to creating domain. For eg

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread Willy-Bas Loos
look and tell me if you are not clear with my query. Thanks, MuraliDharan V *From:* Sathish Duraiswamy [mailto:[EMAIL PROTECTED] *Sent:* Tuesday, August 12, 2008 4:10 PM *To:* [EMAIL PROTECTED] *Cc:* pgsql-general@postgresql.org *Subject:* Re: [GENERAL] Need help returning record set

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread [EMAIL PROTECTED]
@postgresql.org Subject: Re: [GENERAL] Need help returning record set from a dynamic sql query Iam getting just the first record from the recordset That's because you use SELECT INTO, you should use FOR rec IN query LOOP Here's sample code from http://www.postgresql.org/docs/8.1/interactive/plpgsql

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread [EMAIL PROTECTED]
line 30 at for over execute statement From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2008 6:53 PM To: 'Willy-Bas Loos' Cc: 'Sathish Duraiswamy'; 'pgsql-general@postgresql.org' Subject: RE: [GENERAL] Need help returning record set from a dynamic sql query

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread Willy-Bas Loos
so use EXECUTE: CREATE TABLE test (textcol varchar(10), intcol int); INSERT INTO test VALUES ('a', 1); INSERT INTO test VALUES ('a', 2); INSERT INTO test VALUES ('b', 5); INSERT INTO test VALUES ('b', 6); CREATE OR REPLACE FUNCTION ReturnNexting(pText Text) RETURNS SETOF test AS $$ DECLARE rec

Re: [GENERAL] Need help returning record set from a dynamic sql query

2008-08-12 Thread Sathish Duraiswamy
' *Subject:* RE: [GENERAL] Need help returning record set from a dynamic sql query Please understand… I know I have to use FOR … LOOP for my query. But it is not a normal one …I use to build that one dynamically. *From:* Willy-Bas Loos [mailto:[EMAIL PROTECTED] *Sent:* Tuesday, August