On Windows, using Visual C++ I wrote a COM object that has 3 methods. Each calls a Oracle stored procedure. It was previously working but after rebuilding and with using the latest Oracle Provider for OLE DB it stopped working.
For example, one method calls the following stored procedure ;
CREATE OR REPLACE PACKAGE BODY PK_TEST AS
PROCEDURE SP_GET_CLOB (ID IN VARCHAR2,
DATA OUT CLOB)
IS
BEGIN
SELECT CT.CLOB_DATA.GETCLOBVAL() INTO DATA
FROM CLOB_TABLE CT
WHERE CLOB_ID = ID;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END SP_GET_CLOB;
The code edited down to try to keep it short is:
#define SHOPPER_ID_SIZE 64
#define SHOPPING_BASKET_SIZE 98304
typedef struct tagSP_GET_BASKET
{
wchar_t shopper_id[SHOPPER_ID_SIZE];
wchar_t shopping_basket[SHOPPING_BASKET_SIZE];
}SP_GET_BASKET_PROCPARAMS;
STDMETHODIMP CShoppingCart::getbasket(BSTR shopperid, VARIANT shoppingbasket, VARIANTresult)
{
//...
//Set the ORAPROP_SPPrmsLOB property to true to indicate the provider
// that a LOB parameter is being passed to stored procedure
//...omitted to shorten
//...
for (int i = 0; i < nParams; i++)
{
dbbinding.obLength = 0;
dbbinding[i].obStatus = 0;
dbbinding[i].pTypeInfo = NULL;
dbbinding[i].pObject = NULL;
dbbinding[i].pBindExt = NULL;
dbbinding[i].dwPart = DBPART_VALUE;
dbbinding[i].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
dbbinding[i].dwFlags = 0;
dbbinding[i].bScale = 0;
}
//binding for shopperid parameter - a string "1"
dbbinding[0].iOrdinal = 1;
dbbinding[0].obValue = offsetof(SP_GET_BASKET_PROCPARAMS,shopper_id);
dbbinding[0].eParamIO = DBPARAMIO_INPUT;
dbbinding[0].cbMaxLen = SHOPPER_ID_SIZE * sizeof( wchar_t);
dbbinding[0].wType = DBTYPE_WSTR;
dbbinding[0].bPrecision = 0;
//Parameter binding for CLOB
dbbinding[1].iOrdinal = 2;
dbbinding[1].obValue = offsetof(SP_GET_BASKET_PROCPARAMS, shopping_basket);
dbbinding[1].eParamIO = DBPARAMIO_OUTPUT;
dbbinding[1].cbMaxLen = SHOPPING_BASKET_SIZE * sizeof( wchar_t);
dbbinding[1].wType = DBTYPE_WSTR;
SP_GET_BASKET_PROCPARAMS sprocparams;
wcscpy(sprocparams.shopper_id,shopperid);
DBPARAMS myparams;
myparams.pData = (void *)&sprocparams;
myparams.cParamSets = 1;
myparams.hAccessor = hAccessor;
long cNumRows;
//Execute the command.
IRowset *pIRowset;
if(FAILED(hr = pICommandText->Execute(NULL, IID_NULL,myparams, &cNumRows,(IUnknown **)&pIRowset)))
{
// ORA-06502:numeric or value error: character string buffer too small
// ORA-24811: less data provided for writing than indicated
}
//...
}
I think it must have something to do with the binding information I use for the OUT CLOB parameter. Does anyone have experience with setting up the binding for a CLOB OUT parameter??
Does anyone know exactly how I can make some headway in figuring out the ORA-6502 or ORA-24811 errors??
Am I setting up the cbMaxLen correctly?????