Invoke PostgreSQL Stored Procedure using C
I am referring to http://w开发者_开发问答ww.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?
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.
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
精彩评论