1

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?

1
  • Remember that the PostGreSQL server is often a remote one... Commented Nov 10, 2017 at 9:12

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.