1

I have a very simple stored procedure which is below:

CREATE OR REPLACE PROCEDURE rc_name (id IN NUMBER, name OUT VARCHAR)
IS
BEGIN
   SELECT receivable_class_name INTO name
   FROM receivableclass WHERE receivable_class_id = id;
END;
/

I execute it in sqlplus using below:

DECLARE
B VARCHAR(100);
BEGIN
RC_NAME(99,B);
dbms_output.put_line('The rc class is ' ||B);
END;
/

This is executing perfectly and printing the value on console.

Now using otl I would like to call this stored procedure. below is the function.

void stored_proc(void)
{ 

int a=99;
char b[51];

try{

       static otl_stream* mpOtltestProc;

       static string testproc =  "BEGIN"
                                  "RC_NAME(:a<int>,:b<char[51]>)"
                                  "END;";
       if (mDbConnection == NULL)
       mDbConnection = dbCxnManager::getConnection();
       mpOtltestProc = new otl_stream(1, testproc.c_str(), *mDbConnection);


  *mpOtltestProc<<a;
  *mpOtltestProc>>b;
}
catch(otl_exception &p) 
{ 
ORACLE_ERROR; 
}

cout<<"B="<<b<<endl;

}

The problem I am facing is I am not getting this cout print the correct value. Its printing garbage.

Can anybody help me identify the wrong thing that I am doing here.

Jsandesu
  • 105
  • 12
user1939168
  • 547
  • 5
  • 20
  • Seems the `in`,`out`,`inout` parameters' qualifiers are missing. Should be something like `RC_NAME(:a,:b)`. The documentation is [here](http://otl.sourceforge.net/otl3_ex23.htm) and [here](http://otl.sourceforge.net/otl3_bind_variables.htm) – megabyte1024 Nov 13 '17 at 15:25

0 Answers0