Hi,
I searched everywhere for a solution to this apparently simple question,
but i couldnt find it anywhere. All the solutions i find are for C using
OCI_* way.
I have a stored procedure on an oracle db (12) and i simply want to call
it, retrieve the resulting resultset and display it on my c++ application
(using visual studio 2013).
My stored procedure:
CREATE OR REPLACE
procedure listatipos(p_recordset OUT SYS_REFCURSOR) as
BEGIN
open p_recordset FOR
select id_ctipo,nome from corpostipos cpt order by id_ctipo asc;
END listatipos;
My c++ code:
string sql = "declare rc SYS_REFCURSOR; begin listatipos(rc); end;";
con.Open(connectString, user, passw);
Statement st(con);
st.Execute(sql);
// something missing to bind the oracle variable "rc"?
Resultset rs = st.GetResultset();
int total_colunas = int(rs.GetColumnCount());
cout << "Tabela com " << total_colunas << " colunas." << endl;
while (rs.Next())
{
for (int i = 1; i <= total_colunas; i++){
cout << rs.Get<string>(i) << "\t";
}
cout << std::endl;
}
con.Close();
This results in "A null Resultset handle has been provided". If i use a
simple query like "select * from table1", the records are listed perfectly.
>From comparing my code to the previous version ones i find online, i can
see its probably something with a bind(?)? Is it something with my
procedure?
Please help, i find the ocilib a very straightforward library to work with
but this simple problem is driving me crazy. there are no references online
as to how to call and retrieve procedure results using it.
Should i use the other code? I mean, use OCI_ etc? Shouldnt the c++ api be
complete?
Thanks!
best regards,
MV
NOTE: i also posted this question on the forums, please forgive the
duplication.
|