How do I execute Oracle stored procedures from ADO in Visual C++?
-
I am trying to execute some stored procedures that have parameters but I keep getting errors. Simple stored procedures with no parameters I have no problem with. Here is my sample test code which keeps triggering user exceptions: strProcedure = "Hojo_Test_Fun"; strQuote = strProcedure; pCmd->CommandType = adCmdStoredProc; pCmd->CommandText = _bstr_t(strQuote); pCmd->Parameters->Append ( pCmd->CreateParameter ( _bstr_t("some_name"), adChar, adParamInput, 30, _variant_t(_bstr_t("ALKFO")) ) ); pBs = pCmd->Execute(&vNull,&vNull,adCmdUnknown); What am I doing wrong? Help! X| Hojo
-
I am trying to execute some stored procedures that have parameters but I keep getting errors. Simple stored procedures with no parameters I have no problem with. Here is my sample test code which keeps triggering user exceptions: strProcedure = "Hojo_Test_Fun"; strQuote = strProcedure; pCmd->CommandType = adCmdStoredProc; pCmd->CommandText = _bstr_t(strQuote); pCmd->Parameters->Append ( pCmd->CreateParameter ( _bstr_t("some_name"), adChar, adParamInput, 30, _variant_t(_bstr_t("ALKFO")) ) ); pBs = pCmd->Execute(&vNull,&vNull,adCmdUnknown); What am I doing wrong? Help! X| Hojo
I tend to leave the first parameter of CreateParameter as "" rather than passing some data in. What is the error message you are getting and where is it occuring. It might be useful if you could post the stored procedure too. Below is the kind of code I use. I have a set of wrapper classes that I use, so this code isn't exactly what I use but covers everything I call and how I call it.
hr = m_pCommand->put_CommandText(_bstr_t("cti.CALLTRACK_ADD"));
m_pCommand->CommandType = adCmdStoredProc;
_ParameterPtr pParam;
variant_t vtCallID("CAllIDData");
pParam = m_pCommand->CreateParameter("", adChar, adParamInput, 64, vtCallID);
m_pCommand->Parameters->Append(pParam);
pParam->Value = vtCallID;
m_pCommand->Execute(NULL, NULL, adCmdStoredProc);
Michael :-)
-
I am trying to execute some stored procedures that have parameters but I keep getting errors. Simple stored procedures with no parameters I have no problem with. Here is my sample test code which keeps triggering user exceptions: strProcedure = "Hojo_Test_Fun"; strQuote = strProcedure; pCmd->CommandType = adCmdStoredProc; pCmd->CommandText = _bstr_t(strQuote); pCmd->Parameters->Append ( pCmd->CreateParameter ( _bstr_t("some_name"), adChar, adParamInput, 30, _variant_t(_bstr_t("ALKFO")) ) ); pBs = pCmd->Execute(&vNull,&vNull,adCmdUnknown); What am I doing wrong? Help! X| Hojo