Re: How to fetch the RefCursor in via ODBC??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Harry Yau <harry(at)aurasound(dot)com(dot)hk>
Cc: Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to fetch the RefCursor in via ODBC??
Date: 2003-06-30 14:04:43
Message-ID: 4380.1056981883@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Harry Yau <harry(at)aurasound(dot)com(dot)hk> writes:
> I wrote a function to return a RefCursor of a temp table as below:

> CREATE FUNCTION reffunc(refcursor, varchar(10), varchar(10))
> RETURNS refcursor AS '
> BEGIN
> EXECUTE ''create local temp table tablexxx
> (repno character(15), date date)'';
> insert into tablexxx (repno, date) VALUES ( $2, now() );
> insert into tablexxx (repno, date) VALUES ( $3, now() );
> OPEN $1 for EXECUTE '' SELECT * FROM tablexxx '';
> RETURN $1;
> EXECUTE '''';
> END;
> ' LANGUAGE 'plpgsql';

I think you probably need the INSERTS to be done via EXECUTE as well,
at least if you want this to work more than once per session.

Not sure about your ODBC issue, but pgsql-odbc would be the place to
ask about that.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-06-30 14:22:46 Re: MemoryContextAlloc: invalid request size
Previous Message Andrew Gould 2003-06-30 13:39:30 Re: Cannot create unique index