#include <iostream> #include "ocilib.hpp" using namespace std; using namespace ocilib; #pragma comment(lib,"ociliba.lib") #pragma comment(lib,"ocilibw.lib") int main() { try { int ncout = 0, iin = 11; string sout,sin = "输入的参数值"; Environment::Initialize(); Connection con("server", "id", "password"); Statement st(con); st.Prepare("begin 存储过程名(:nout, :sout, :iin, :sin); end;"); st.Bind(OTEXT(":nout"), nout, BindInfo::Out); st.Bind(OTEXT(":sout"), sout, 256, BindInfo::Out); st.Bind(OTEXT(":iin"), iin, BindInfo::In); st.Bind(OTEXT(":sin"), sin, static_cast<unsigned int>(sin.size()), BindInfo::In); st.ExecutePrepared(); cout<< nout << sout <<endl; } catch (std::exception &ex) { } Environment::Cleanup(); return 0; }
其中nout, :sout, :iin, :sin,分别代表存储过程中int型的输出,string型的输出;int型的输入和string型的输入; 需注意要在projict 的最后一个工程属性的C/C++和链接器的第一个常规,分别加上include和lib库。
本文出自 “学习记录” 博客,请务必保留此出处http://6941523.blog.51cto.com/6931523/1672116
原文地址:http://6941523.blog.51cto.com/6931523/1672116