#include
#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(sin.size()), BindInfo::In);
st.ExecutePrepared();
cout<< nout << sout <其中nout, :sout, :iin, :sin,分别代表存储过程中int型的输出,string型的输出;int型的输入和string型的输入;
需注意要在projict 的最后一个工程属性的C/C++和链接器的第一个常规,分别加上include和lib库。
附件:http://down.51cto.com/data/2365892
网站名称:通过OCILIB连接oracle执行存储过程
网页路径:http://cdxtjz.cn/article/jcdidd.html