// in SQL: create procedure getCustomer @custId int as select * from
customer where custid = @custId
// usual CDataSource & CSession initialization ......................
CCommand<CDynamicParameterAccessor,CRowset,CMultipleResults> cmd;
const ULONG nParams = 1;
DBPARAMBINDINFO dbParamBindInfo[nParams] =
{
L"DBTYPE_I4", L"@custId", sizeof(int), DBPARAMFLAGS_ISINPUT, 10, 0
};
ULONG ParamOrdinals[nParams] = {1};
void *pDummy;
typedef struct tagGetParams
{
int lCustId;
} SGetParams;
hr = cmd.Create(session,"{ CALL getCustomer (?) }");
hr = cmd.SetParameterInfo(nParams,ParamOrdinals,dbParamBindInfo);
dbBinding[0].obLength = 0;
dbBinding[0].obStatus = 0;
dbBinding[0].pTypeInfo = NULL;
dbBinding[0].pObject = NULL;
dbBinding[0].pBindExt = NULL;
dbBinding[0].dwPart = DBPART_VALUE;
dbBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
dbBinding[0].dwFlags = 0;
dbBinding[0].bScale = 0;
dbBinding[0].iOrdinal = 1;
dbBinding[0].obValue = offsetof(SGetParams,lCustId);
dbBinding[0].eParamIO = DBPARAMIO_INPUT;
dbBinding[0].cbMaxLen = sizeof(int);
dbBinding[0].wType = DBTYPE_I4;
dbBinding[0].bPrecision = 10;
// ????? NEED HELP IN SETTING UP PARAMETER ACCESSOR
hr =
cmd.BindParameters(&cmd.m_hParameterAccessor,cmd.m_spCommand,&pDummy);
cmd.SetParam((ULONG)1,&custId);
hr = cmd.Open(NULL,NULL,0);
//--------------------------------------------------------------------------
-----
I'm basically stuck at steps 3 & 4 of "Calling a stored procedure (OLE DB)"
at
http://msdn.microsoft.com/library/psdk/dasdk/9_ol3ewp.htm
And I don't want to call cmd.Prepare() in order to save a roundtrip. Also,
is
there a macro that can make life easier here?
Thanks for any help.
Iwan
CCommand<CDynamicParameterAccessor,CRowset,CMultipleResults> *prs;
prs = new CCommand<CDynamicParameterAccessor,CRowset,CMultipleResults>;
hr = prs->Create( m_Session, bstrCommandText );
void* pParamBuf;
if( SUCCEEDED(hr) )
hr = prs->Prepare( 100 );
// Bind the parameters.
if( SUCCEEDED(hr) )
hr = prs->BindParameters( &prs->m_hParameterAccessor,
prs->m_spCommand, &pParamBuf );
_________________________________
This assumes that their are no parameterized sub-queries in the stored
procedure. I'm hoping that if you don't call SetParam(...) for a
particular parameter that it will treat that parameter as NULL, but I
haven't tried it yet.
On the other hand if you *need* to build the parameters by hand I've
done that before (it's more efficient), so repost with your needs if
so. Good luck, and I'll be paying sporatic attention to this group for
a week or two more.
Ivo Roper
Senior C++ Consultant
MemeHive, LLP
In article <#6Mlb$z#$GA....@cppssbbsa02.microsoft.com>,
Sent via Deja.com http://www.deja.com/
Before you buy.
In article <8mpt1t$gvb$1...@nnrp1.deja.com>,