Search Postgresql Archives

Re: How can I retrieve a function result?

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

 



Hi,
 
Thanks a lot for your answer,
 
Let me give you a simple example with more detail:
 
In my postgres database I have a function called "myFunction".
 
/************************************************************************/
CREATE OR REPLACE FUNCTION myFunction(INT) RETURN INT AS '
DECLARE
  indice    ALIAS FOR $1;
BEGIN
 
  IF indice > 0 THEN
    return -900;
  ELSE
    //something to do....
    return 0;
  END IF;
 
END;
' LANGUAGE 'plpgsql';
/************************************************************************/
 
I have a program in C/C++ which call the FUNCTION 'myFunction'
 
/************************************************************************/
res = PQexecParams ( conn, "select myFunction($1)" , 1, NULL,
paramValues, paraLenghts, paramFormats, resultFormat);
/************************************************************************/
 
The program works fine, actually I can verify that it executes the FUNCTION 'myFunction', however I dont know how can I get the return value of the FUNCTION 'myFunction' (as you can see in the little example the return value can be 0 or -900).
 
 
Regards,
 
Thanks in advance!
 
 


 
On 6/12/06, Joachim Wieland <joe@xxxxxxxxxxx> wrote:
Luis,

On Mon, Jun 12, 2006 at 06:24:24PM -0500, Luis Alberto Pérez Paz wrote:
> res = PQexecParams ( conn, "select myFunction($1,$2,$3)" , 3, NULL,
> paramValues, paraLenghts, paramFormats, resultFormat);

> It's works fine, however I dont know how can I retrieve the result that
> return the FUNCTION "myFunction". "myFunction" is a postgres FUNCTION which
> returns a INT.

libpq functions for retrieving query results are described here:

http://www.postgresql.org/docs/8.1/static/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO
Have you tried them and do you have a special problem with one of those? If
so, please give more detail.

Getting the result of a function does not differ from getting the result of
a regular select of a table or view.


Joachim




--
paz, amor y comprensión
        (1967-1994)

[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