Hi everyone ... this is my first post in this forums, so please correct me if i'm doing anything wrong.
There are some problem when i want to migrate some function that i make in c++ with executing some query (SELECT, INSERT, UPDATE) and take the resultset and use them for the main program. The problem is:
1. how to execute or call a postgre's procedure (with output and input parameter) and function from c++ ?
2. how to make a procedure in postgre with input and output parameter ? (some example please)
3. how to break the composite type in postgre when the result already sent to c++ ? (how to break the result set to the base type)
my_type = (int2,int4,varchar) --> i want to break the result to : int2 variable, int4 variable, and varchar variable.
That's all i have to ask ... I'm really really hopes for your helps ....
-People always find a way for better live, why don't people want some bad live, so what is good what is bad ??? ----
I'm not a c++ user, but here's some examples of user defined functions returning values... 33.4.1, 33.4.2, 33.4.3
I haven't tried this, but you may be able to create a type in SQL that's analgous to your c++ type and use it in your SQL function... There's an example in the link above of using a created type as an output of a function. Give it a try to see if you can use a created type as an input parameter...
CREATE TYPE your_cpp_type as (i2 int2, i4 as int4, vc as varchar);
CREATE FUNCTION YourFunction (your_cpp_type) RETURNS ...
You may have to declare the input parameters separately. (or add a custom data type to postgreSQL, which, from what little I've read about, is not trivial)
Last edited by loquin; 03-06-07 at 13:19.
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert