[Orclib-users] Simple insert with in variables to procedure
Open source C and C++ library for accessing Oracle Databases
Brought to you by:
vince_del_paris
From: Miguel V. <pag...@gm...> - 2015-01-13 17:15:17
|
Hi, I cant a simple insert to work using a procedure and ocilib. The procedure: CREATE OR REPLACE PROCEDURE criasistema(idout OUT NUMBER, nm IN VARCHAR2) AS BEGIN insert into sistemas(NOME) values(nm) returning id_sistema into idout; END; Heres the c++ code: Environment::Initialize(Environment::Default | Environment::Threaded); string sql = "declare ids NUMBER begin criasistema(:ids,:nm); end;"; try{ con.Open(connectString, user, passw); Statement st(con); Statement st2(con); st.Prepare(sql); st.Bind(":ids", st2, BindInfo::Out); st.Bind(":nm", nome, 255, BindInfo::In); st.Execute(); con.Commit(); con.Close(); } catch (Exception &ex){ cout << ex.what() << endl; } Environment::Cleanup(); It compiles but breaks at st.Bind(":nm", nome, 255, BindInfo::In); What am i doing wrong? I assumed it would be simply a matter of binding in and out variables and it shuld work, but not so easy.. :-P I am really not at easy with the binds. Next step will be to send a full object (int,string,...) array, but if i cant solve this simple string issue, i am not going anywahere. Thanks. MV |