Search Postgresql Archives

Getting Out Parameter in the application using libpq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux