tags:

views:

172

answers:

2

I am referring to http://www.postgresql.org/docs/8.1/static/libpq.html

I try to find an example of C/C++ to call PostgreSQL stored procedure. However, I cannot find one. Can anyone point me the right direction?

+2  A: 

You just need to execute a SQL statement like this one:

SELECT myStoredProcedure(1,2,3);

This can for example be done using PQexec(), just like with any other SQL statement. An example program that sends SQL statements to a database can be found in section 28.17. of the documentation

sth
+3  A: 

As as previously been answered, the easiest way is to use SELECT myStoredProcedure(1,2,3). You can also use the fast-path call interface to call a function directly. See http://www.postgresql.org/docs/current/static/libpq-fastpath.html for reference. But note that if you are working on modern versions of PostgreSQL, you're likely better off using the regular interface and a prepared statement.

Magnus Hagander