Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Starting PL/SQL Procedure via OLEDB in C++, error with oraoledb.oracle provider

Starting PL/SQL Procedure via OLEDB in C++, error with oraoledb.oracle provider

From: Andrea Greif <agreif_at_finsys-software.de>
Date: 13 May 2004 05:55:53 -0700
Message-ID: <a16d3887.0405130455.2d18b0c7@posting.google.com>


I encountered a problem when trying to start Oracle stored procedures via C++/MFC OLEDB classes. The following piece of source works perfectly with oracle oledb provider from Microsoft "MSDAORA", the stored procedure is running properly. However when the code is executed with Oracle OLEDB driver "ORAOLEDB.ORACLE" a HRESULT error is returned at the statement hr = manAcc->Open(&propset,NULL,FALSE). Does anyone have an idea why this happens?

int CDataAccess::CallStoredDimProcedure(CCommand<CManualAccessor> *manAcc,long lInput,char cProc,CString& strback,CString strMerkmatyp) {

	m_strService.MakeUpper();
	if (m_strService == "MSDAORA" || m_strService == "ORAOLEDB.ORACLE" ||
m_strService == "MSDASQL")
	{
		if (!CloseOpenSession())
			return -23;		

		typedef struct tagSPROCPARAMSDIMC

{
long IN_HIERID; char IN_MERKMATYP[15]; char OUT_MELDUNG[100]; }SPROCPARAMSDIMC; SPROCPARAMSDIMC sprocparamsdim_c; char CmdString [40]; sprocparamsdim_c.IN_HIERID = lInput; strncpy(sprocparamsdim_c.IN_MERKMATYP,strMerkmatyp,15); strcpy(sprocparamsdim_c.OUT_MELDUNG," "); /* Fill in DBPARAMS structure for the command execution. This structure specifies the parameter values in the command and is then passed to Execute. */ const ULONG nParams = 3; DBBINDING acDBBinding[nParams]; /*Describe the consumer buffer by filling in the array of DBBINDING structures. Each binding associates a single parameter to the consumer's buffer.*/ int i; for(i = 0; i < nParams; i++)
{
acDBBinding[i].obLength = 0; acDBBinding[i].obStatus = 0; acDBBinding[i].pTypeInfo = NULL; acDBBinding[i].pObject = NULL; acDBBinding[i].pBindExt = NULL; acDBBinding[i].dwPart = DBPART_VALUE; acDBBinding[i].dwMemOwner = DBMEMOWNER_CLIENTOWNED; acDBBinding[i].dwFlags = 0; acDBBinding[i].bScale = 0; } //endfor acDBBinding[0].iOrdinal = 1; acDBBinding[0].obValue = offsetof(SPROCPARAMSDIMC, IN_HIERID); acDBBinding[0].eParamIO = DBPARAMIO_INPUT; acDBBinding[0].cbMaxLen = sizeof(long); acDBBinding[0].wType = DBTYPE_I4; acDBBinding[1].iOrdinal = 2; acDBBinding[1].obValue = offsetof(SPROCPARAMSDIMC, IN_MERKMATYP); acDBBinding[1].eParamIO = DBPARAMIO_INPUT; acDBBinding[1].cbMaxLen = 15*sizeof(char); acDBBinding[1].wType = DBTYPE_STR; acDBBinding[2].iOrdinal = 3; acDBBinding[2].obValue = offsetof(SPROCPARAMSDIMC, OUT_MELDUNG); acDBBinding[2].eParamIO = DBPARAMIO_OUTPUT; acDBBinding[2].cbMaxLen = 100*sizeof(char); acDBBinding[2].wType = DBTYPE_STR; TRY
{
HRESULT hr; hr = manAcc->CreateParameterAccessor(nParams, acDBBinding, sizeof(SPROCPARAMSDIMC)); if (FAILED(hr)) { AfxThrowOLEDBException(manAcc->m_spCommand, IID_IAccessor); } manAcc->AddParameterEntry( acDBBinding[0].iOrdinal, acDBBinding[0].wType, acDBBinding[0].cbMaxLen, &sprocparamsdim_c.IN_HIERID, NULL, NULL, acDBBinding[0].eParamIO); manAcc->AddParameterEntry( acDBBinding[1].iOrdinal, acDBBinding[1].wType, acDBBinding[1].cbMaxLen, &sprocparamsdim_c.IN_MERKMATYP, NULL, NULL, acDBBinding[1].eParamIO); manAcc->AddParameterEntry( acDBBinding[2].iOrdinal, acDBBinding[2].wType, acDBBinding[2].cbMaxLen, &sprocparamsdim_c.OUT_MELDUNG, NULL, NULL,
acDBBinding[2].eParamIO);                         

                        strcpy(CmdString,"{call dim_create(?,?,?)}");                         

			if (manAcc->Create(*m_pSession, CmdString) != S_OK)
			{
				AfxThrowOLEDBException(manAcc->m_spCommand, IID_IDBCreateCommand);
			}			
		}
		CATCH(COLEDBException, e)

{
CErrorsDialog dlg; dlg.Init(e->m_lpUnk, e->m_iid,CmdString); dlg.DoModal(); m_pSession->Abort(); return -23; } END_CATCH break; CDBPropSet propset(DBPROPSET_ROWSET); propset.AddProperty(DBPROP_IRowsetChange, true); propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_INSERT | DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE); propset.AddProperty(DBPROP_IRowsetScroll, true); propset.AddProperty(DBPROP_CLIENTCURSOR, true); HRESULT hr; hr = manAcc->Open(&propset,NULL,FALSE); if (FAILED(hr))
{
m_pSession->Abort(); return -23; } manAcc->Delete(); strback = (CString)sprocparamsdim_c.OUT_MELDUNG; break; } return 0;

} Received on Thu May 13 2004 - 07:55:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US