-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
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
[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);
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;
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 ,
, 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
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
@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
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
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
'
*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
11 matches
Mail list logo