From: | Ehsan Haq <ehsan_haq98(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Getting Out Parameter in the application using libpq |
Date: | 2009-09-11 04:31:26 |
Message-ID: | 683436.52587.qm@web31813.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I am looking for a way to get the OUT parameters of a FUNCTION/PROCEDURE in my application (C++) using C libpq library. I can get the result set of an OUT parameter having REFCURSOR data type through an explicit FETCH ALL from "YYYY" but for OUT parameter of type integer/varchar I dont have a clue. Can anyone tell me how it is done or suggest any work around for this?
Using the following code I can get the refcursor.
CREATE OR REPLACE
Function getAddresses
(
pName IN varchar2, outCursor refcursor
) RETURN NUMBER
IS
BEGIN
OPEN outCursor FOR SELECT * FROM "dummyTable" WHERE "name"=pName;
return 1;
END getAddresses;
strcat(statement, "SELECT getAddresses('abc', 'outcursor'); FETCH ALL IN outcursor");
res = PQexec(conn, statement);
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
throw Exception(PQresultErrorMessage(res));
}
cout << "Number of Rows: " << PQntuples(res) << " Number of Columns: " << PQnfields(res) << endl;
PQclear(res);
Thanks
Ehsan
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-09-11 04:37:37 | Re: "show all" command crashes server |
Previous Message | rr04 | 2009-09-11 03:05:19 | quick survey on schema less database usage |