@
HELLO,
I am facing an issue while executing a stored procedure using OCCI and OTT in C++.
My INPUT for the program is a list of strings and their indexes.
My Output for the program is the REFCURSOR.
For the program i wrote, while compiling there was no error but while debugging it, it gave memory crash issues.
i refered some oracle groups posts and checked back again but no replies over there.
PLEASE LET ME KNOW THE SOLUTION FOR THIS OCCI/OTT ISSUE
ORACLE PROCEDURE ---- WORKING PROPERLY (RETURNS THE OUTPUT)
SET serveroutput ON
VARIABLE outpartslist REFCURSOR;
DECLARE
in_part_list T_TBL_PART_LIST := T_TBL_PART_LIST (T_OBJ_PART_LIST('0944', 1), T_OBJ_PART_LIST('1124', 2), T_OBJ_PART_LIST('1124', 3), T_OBJ_PART_LIST('0944', 4));
BEGIN
DTC_GETTER_PKG.GET_PART_DATA(:outpartslist , in_part_list );
END;
/
PRINT :OUTPARTSLIST;
TO USE THE ABOVE PROCEDURE USING C++ OCCI PROGRAM
Below is the program i wrote:
extern void main( char argc, char *argv[] )
{
Environment *env;
Connection *conn;
Statement *stmt;
env = Environment::createEnvironment (Environment::Mode(Environment::OBJECT | Environment::THREADED_MUTEXED));//oracle::occi::Environment::DEFAULT);
conn = env->createConnection (strUser, strPass, ConnectString);
int nRowCount=0;
for (int i = 0; i < 3; i++)
{
T_OBJ_PART_LIST *Obj_Part = new T_OBJ_PART_LIST();
oracle::occi::Number nNumber = oracle::occi::Number(i+1);
(Obj_Part->PART_NUM).append("3030200-7");
Obj_Part->ORDR_NUM = nNumber;
cout<<Obj_Part->PART_NUM<<"\t";
cout<< nNumber.operator int()<<"\n";
spPartslist.push_back(Obj_Part);
delete Obj_Part;
}
cout << "\ncallproc - invoking a PL/SQL procedure with parameters" << endl;
stmt = conn->createStatement("BEGIN dtc_getter_pkg.get_part_data(:1, :2); END;");
stmt->registerOutParam(1, oracle::occi::OCCICURSOR);
cout << "\nExecuting the block :" << stmt->getSQL() << endl;
OCCI_STD_NAMESPACE::string strType("T_OBJ_PART_LIST");
setVector(stmt, 2, spPartslist, "dtc_user" , strType); /// THIS IS WHERE CRASH IS HAPPENING.............
stmt->execute();
conn->terminateStatement (stmt);
cout << "\nocciproc - done" << endl;
// delete allocated memory
for (int i=0; i<strDBPartNos.size(); i++)
{
delete spPartslist[i];
}
conn->terminateStatement(stmt);
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
}
@http://stackoverflow.com/questions/22838205/how-to-call-a-stored-procedure-with-a-parameter-of-type-table