Re: AW: [OLEDB_DEV] OLE DB Consumer Templates
Erik Valdes <[email protected]> Thu, 9 Jan 2003 11:17:07 -0700
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2B80B.51AA46E0 Content-Type: text/plain Hi, I see what you mean about MS recommending the storage object way. I've found a lot of articles describing that. However, I'm having trouble finding anything that gives an example of how to do the in-memory way. Perhaps someone could point me to an example or a how-to document? I'd really appreciate it. Thanks, Erik -----Original Message----- From: Yuancai Ye [mailto:[email protected]] Sent: Thursday, January 09, 2003 9:57 AM To: [email protected] Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates Hi, MS recommends us to use storage object for sending a BLOB into a data source. However, as I tested, this way is bad in many cases since your code needs to create a store object and database needs to recover binnary data from the store object. You'd better use in-memory way to send BLOB for faster speed. With use of in-memory way, the previous two extra steps are avoided. Therefore, in-memory way is faster. That is my guess. Test it yourself. Regards, Yuancai (Charlie) Ye --- Rudolf Wiener <[email protected]> wrote: > Erik, > > For reading and writing blobs, which is what you're > in fact using, I use the > technologies recommended and stream the data with a > storage object. The > macro I use in the accessor is > BLOB_ENTRY_LENGTH_STATUS. I'm not sure if > this is the best way to do it because I have the > impression it slows things > down a bit. But I haven't had the time yet to look > into faster alternatives. > > If you like I can send you excerpts from my app's > code. > > Regards > Rudi > > -----Urspr黱gliche Nachricht----- > Von: OLEDB_DEV > [mailto:[email protected]]Im Auftrag von > Erik > Valdes > Gesendet: Donnerstag, 09. J鋘ner 2003 17:22 > An: [email protected] > Betreff: Re: [OLEDB_DEV] OLE DB Consumer Templates > > > The reason I can't allocate on the stack is that > my variable can be any > length. It essentially boils down to the string > representation of an xml > file. That file can be any size. When I pass it to > my SP, the sp's > parameter is ntext (to allow for any size). What > do people do when they > want to pass XML of unknown length to a SQL Server > stored procedure? > > > > -----Original Message----- > From: Peter Moss [mailto:[email protected]] > Sent: Thursday, January 09, 2003 7:58 AM > To: [email protected] > Subject: Re: [OLEDB_DEV] OLE DB Consumer Templates > > > > If I remember right, you can't use the macros for > heap-allocated > variables. If you dig into the macro definitions, I > believe you will find > that pointers offset from the beginning of 'this' > are used. Thus, a > heap-allocated variable like m_WorkRequest will not > work. > > > > Why can't you just allocate a TCHAR on the stack > frame of the object, ie, > > > > TCHAR m_WorkRequest[257]; // Or 1 + the size > of your SP parameter size > > > > Then you can just use COLUMN_ENTRY. > > > > HTH, > > Peter > > -----Original Message----- > From: OLEDB_DEV > [mailto:[email protected]]On Behalf Of > Erik > Valdes > Sent: Wednesday, January 08, 2003 5:22 PM > To: [email protected] > Subject: [OLEDB_DEV] OLE DB Consumer Templates > > I'm having trouble implementing an accessor. > I'm trying to use a > variable (m_WorkRequest) that's dynamically > allocated as the variable that's > bound to a parameter in my accessor (commented line > below). The reason I > need it to be dynamic is that it is XML and can be > any length. The stored > proc's parameter is of ntext type to handle the > variable length. However, I > don't know at compile time how big to make the > buffer for my parameter in my > accessor. What's the proper way to do this? I've > tried COLUMN_ENTRY > (access violation), COLUMN_ENTRY_LENGTH (different > variations produce > different errors, but basically I can't set the > length), > COLUMN_ENTRY_TYPE_SIZE (similar problems as the > previous). I'm running out > of ideas now. The code below is just one of many, > many variations I've > tried. > > > > > > class CAddWorkRequest > > { > > public: > > CAddWorkRequest() STD_INIT > > ~CAddWorkRequest() > > { > > if (m_WorkRequest) > > delete [] m_WorkRequest; > > } > > LONG m_RETURNVALUE; > > LPTSTR m_WorkRequest; > > LONG m_lLength; > > > > void SetStringParam(LPCTSTR szString,int > cBytes) > > { > > m_WorkRequest = (LPTSTR) new > TCHAR[cBytes]; > > _tcsncpy(m_WorkRequest,szString,cBytes); > > m_lLength = _tcslen(m_WorkRequest); > > }) > > > > BEGIN_PARAM_MAP(CAddWorkRequest) > > SET_PARAM_TYPE(DBPARAMIO_OUTPUT) > > COLUMN_ENTRY(1, m_RETURNVALUE) > > SET_PARAM_TYPE(DBPARAMIO_INPUT) > > // > COLUMN_ENTRY_TYPE_SIZE(2,DBTYPE_STR,_tcslen(m_WorkRequest), > m_WorkRequest) > > > > > > END_PARAM_MAP() > > > > DEFINE_COMMAND(CAddWorkRequest, _T("{ ? = CALL > dbo.AddWorkRequest;1 > (?) }")) > > > > }; > > > > class CAddWorkRequestCommand : public > CBsDbCommand<CAddWorkRequest> > > { > > }; > > > > foo (LPTSTR szWor) > > { > > === message truncated === __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists at http://discuss.develop.com. ------_=_NextPart_001_01C2B80B.51AA46E0 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2653.12"> <TITLE>RE: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer = Templates</TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2>Hi,</FONT> </P> <P><FONT SIZE=3D2>I see what you mean about MS recommending the storage = object way. I've found a lot of articles describing that. = However, I'm having trouble finding anything that gives an example of = how to do the in-memory way. Perhaps someone could point me to an = example or a how-to document? I'd really appreciate it. = </FONT></P> <P><FONT SIZE=3D2>Thanks,</FONT> <BR><FONT SIZE=3D2>Erik</FONT> </P> <P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: Yuancai Ye [<A = HREF=3D"mailto:[email protected]">mailto:[email protected]</A>] </FONT> <BR><FONT SIZE=3D2>Sent: Thursday, January 09, 2003 9:57 AM</FONT> <BR><FONT SIZE=3D2>To: [email protected]</FONT> <BR><FONT SIZE=3D2>Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB = Consumer Templates</FONT> </P> <P><FONT SIZE=3D2>Hi,</FONT> <BR><FONT SIZE=3D2> MS recommends us to use storage = object for sending</FONT> <BR><FONT SIZE=3D2>a BLOB into a data source. However, as I tested, = this</FONT> <BR><FONT SIZE=3D2>way is bad in many cases since your code needs = to</FONT> <BR><FONT SIZE=3D2>create a store object and database needs to = recover</FONT> <BR><FONT SIZE=3D2>binnary data from the store object. You'd better = use</FONT> <BR><FONT SIZE=3D2>in-memory way to send BLOB for faster speed. With = use</FONT> <BR><FONT SIZE=3D2>of in-memory way, the previous two extra steps = are</FONT> <BR><FONT SIZE=3D2>avoided. Therefore, in-memory way is faster. That = is</FONT> <BR><FONT SIZE=3D2>my guess. Test it yourself.</FONT> </P> <P><FONT SIZE=3D2>Regards,</FONT> </P> <P><FONT SIZE=3D2>Yuancai (Charlie) Ye</FONT> </P> <P><FONT SIZE=3D2>--- Rudolf Wiener <[email protected]> = wrote:</FONT> <BR><FONT SIZE=3D2>> Erik,</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> For reading and writing blobs, which is what = you're</FONT> <BR><FONT SIZE=3D2>> in fact using, I use the</FONT> <BR><FONT SIZE=3D2>> technologies recommended and stream the data = with a</FONT> <BR><FONT SIZE=3D2>> storage object. The</FONT> <BR><FONT SIZE=3D2>> macro I use in the accessor is</FONT> <BR><FONT SIZE=3D2>> BLOB_ENTRY_LENGTH_STATUS. I'm not sure = if</FONT> <BR><FONT SIZE=3D2>> this is the best way to do it because I have = the</FONT> <BR><FONT SIZE=3D2>> impression it slows things</FONT> <BR><FONT SIZE=3D2>> down a bit. But I haven't had the time yet to = look</FONT> <BR><FONT SIZE=3D2>> into faster alternatives.</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> If you like I can send you excerpts from my = app's</FONT> <BR><FONT SIZE=3D2>> code.</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> Regards</FONT> <BR><FONT SIZE=3D2>> Rudi</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> -----Urspr&#40689;gliche = Nachricht-----</FONT> <BR><FONT SIZE=3D2>> Von: OLEDB_DEV</FONT> <BR><FONT SIZE=3D2>> [<A = HREF=3D"mailto:[email protected]">mailto:[email protected]= evelop.com</A>]Im Auftrag von</FONT> <BR><FONT SIZE=3D2>> Erik</FONT> <BR><FONT SIZE=3D2>> Valdes</FONT> <BR><FONT SIZE=3D2>> Gesendet: Donnerstag, 09. = J&#37592;ner 2003 17:22</FONT> <BR><FONT SIZE=3D2>> An: = [email protected]</FONT> <BR><FONT SIZE=3D2>> Betreff: Re: [OLEDB_DEV] OLE DB = Consumer Templates</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> The reason I can't allocate on the = stack is that</FONT> <BR><FONT SIZE=3D2>> my variable can be any</FONT> <BR><FONT SIZE=3D2>> length. It essentially boils down to the = string</FONT> <BR><FONT SIZE=3D2>> representation of an xml</FONT> <BR><FONT SIZE=3D2>> file. That file can be any size. = When I pass it to</FONT> <BR><FONT SIZE=3D2>> my SP, the sp's</FONT> <BR><FONT SIZE=3D2>> parameter is ntext (to allow for any = size). What</FONT> <BR><FONT SIZE=3D2>> do people do when they</FONT> <BR><FONT SIZE=3D2>> want to pass XML of unknown length to a SQL = Server</FONT> <BR><FONT SIZE=3D2>> stored procedure?</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> -----Original Message-----</FONT> <BR><FONT SIZE=3D2>> From: Peter Moss [<A = HREF=3D"mailto:[email protected]">mailto:[email protected]</A>]</FONT> <BR><FONT SIZE=3D2>> Sent: Thursday, January 09, 2003 = 7:58 AM</FONT> <BR><FONT SIZE=3D2>> To: = [email protected]</FONT> <BR><FONT SIZE=3D2>> Subject: Re: [OLEDB_DEV] OLE DB = Consumer Templates</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> If I remember right, you can't use = the macros for</FONT> <BR><FONT SIZE=3D2>> heap-allocated</FONT> <BR><FONT SIZE=3D2>> variables. If you dig into the macro = definitions, I</FONT> <BR><FONT SIZE=3D2>> believe you will find</FONT> <BR><FONT SIZE=3D2>> that pointers offset from the beginning of = 'this'</FONT> <BR><FONT SIZE=3D2>> are used. Thus, a</FONT> <BR><FONT SIZE=3D2>> heap-allocated variable like m_WorkRequest will = not</FONT> <BR><FONT SIZE=3D2>> work.</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> Why can't you just allocate a TCHAR = on the stack</FONT> <BR><FONT SIZE=3D2>> frame of the object, ie,</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> TCHAR = m_WorkRequest[257]; // Or 1 + the size</FONT> <BR><FONT SIZE=3D2>> of your SP parameter size</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> Then you can just use = COLUMN_ENTRY.</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> HTH,</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> Peter</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> -----Original = Message-----</FONT> <BR><FONT SIZE=3D2>> From: OLEDB_DEV</FONT> <BR><FONT SIZE=3D2>> [<A = HREF=3D"mailto:[email protected]">mailto:[email protected]= EVELOP.COM</A>]On Behalf Of</FONT> <BR><FONT SIZE=3D2>> Erik</FONT> <BR><FONT SIZE=3D2>> Valdes</FONT> <BR><FONT SIZE=3D2>> Sent: Wednesday, = January 08, 2003 5:22 PM</FONT> <BR><FONT SIZE=3D2>> To: = [email protected]</FONT> <BR><FONT SIZE=3D2>> Subject: [OLEDB_DEV] = OLE DB Consumer Templates</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> I'm having trouble = implementing an accessor.</FONT> <BR><FONT SIZE=3D2>> I'm trying to use a</FONT> <BR><FONT SIZE=3D2>> variable (m_WorkRequest) that's = dynamically</FONT> <BR><FONT SIZE=3D2>> allocated as the variable that's</FONT> <BR><FONT SIZE=3D2>> bound to a parameter in my accessor (commented = line</FONT> <BR><FONT SIZE=3D2>> below). The reason I</FONT> <BR><FONT SIZE=3D2>> need it to be dynamic is that it is XML and can = be</FONT> <BR><FONT SIZE=3D2>> any length. The stored</FONT> <BR><FONT SIZE=3D2>> proc's parameter is of ntext type to handle = the</FONT> <BR><FONT SIZE=3D2>> variable length. However, I</FONT> <BR><FONT SIZE=3D2>> don't know at compile time how big to make = the</FONT> <BR><FONT SIZE=3D2>> buffer for my parameter in my</FONT> <BR><FONT SIZE=3D2>> accessor. What's the proper way to do = this? I've</FONT> <BR><FONT SIZE=3D2>> tried COLUMN_ENTRY</FONT> <BR><FONT SIZE=3D2>> (access violation), COLUMN_ENTRY_LENGTH = (different</FONT> <BR><FONT SIZE=3D2>> variations produce</FONT> <BR><FONT SIZE=3D2>> different errors, but basically I can't set = the</FONT> <BR><FONT SIZE=3D2>> length),</FONT> <BR><FONT SIZE=3D2>> COLUMN_ENTRY_TYPE_SIZE (similar problems as = the</FONT> <BR><FONT SIZE=3D2>> previous). I'm running out</FONT> <BR><FONT SIZE=3D2>> of ideas now. The code below is just one = of many,</FONT> <BR><FONT SIZE=3D2>> many variations I've</FONT> <BR><FONT SIZE=3D2>> tried.</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> class = CAddWorkRequest</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> {</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> public:</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = CAddWorkRequest() STD_INIT</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = ~CAddWorkRequest()</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = {</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT = SIZE=3D2>>  = ; if (m_WorkRequest)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT = SIZE=3D2>>  = ; delete [] m_WorkRequest;</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = }</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> LONG = m_RETURNVALUE;</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = LPTSTR m_WorkRequest;</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> LONG = m_lLength;</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> void = SetStringParam(LPCTSTR szString,int</FONT> <BR><FONT SIZE=3D2>> cBytes)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = {</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT = SIZE=3D2>>  = ; m_WorkRequest =3D (LPTSTR) new</FONT> <BR><FONT SIZE=3D2>> TCHAR[cBytes];</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT = SIZE=3D2>>  = ; _tcsncpy(m_WorkRequest,szString,cBytes);</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT = SIZE=3D2>>  = ; m_lLength =3D _tcslen(m_WorkRequest);</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = })</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = BEGIN_PARAM_MAP(CAddWorkRequest)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = SET_PARAM_TYPE(DBPARAMIO_OUTPUT)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = COLUMN_ENTRY(1, m_RETURNVALUE)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = SET_PARAM_TYPE(DBPARAMIO_INPUT)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> //</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>COLUMN_ENTRY_TYPE_SIZE(2,DBTYPE_STR,_tcslen(m_WorkReq= uest),</FONT> <BR><FONT SIZE=3D2>> m_WorkRequest)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> END_PARAM_MAP()</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> = DEFINE_COMMAND(CAddWorkRequest, _T("{ ? =3D CALL</FONT> <BR><FONT SIZE=3D2>> dbo.AddWorkRequest;1</FONT> <BR><FONT SIZE=3D2>> (?) }"))</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> };</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> class = CAddWorkRequestCommand : public</FONT> <BR><FONT SIZE=3D2>> CBsDbCommand<CAddWorkRequest></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> {</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> };</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> foo (LPTSTR = szWor)</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>> {</FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>></FONT> <BR><FONT SIZE=3D2>=3D=3D=3D message truncated =3D=3D=3D</FONT> </P> <BR> <P><FONT = SIZE=3D2>__________________________________________________</FONT> <BR><FONT SIZE=3D2>Do you Yahoo!?</FONT> <BR><FONT SIZE=3D2>Yahoo! Mail Plus - Powerful. Affordable. Sign up = now.</FONT> <BR><FONT SIZE=3D2><A HREF=3D"http://mailplus.yahoo.com" = TARGET=3D"_blank">http://mailplus.yahoo.com</A></FONT> </P> <P><FONT SIZE=3D2>You can read messages from the OLEDB_DEV archive, = unsubscribe from OLEDB_DEV,</FONT> <BR><FONT SIZE=3D2>or subscribe to other DevelopMentor lists at <A = HREF=3D"http://discuss.develop.com" = TARGET=3D"_blank">http://discuss.develop.com</A>.</FONT> </P> </BODY> You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists at http://discuss.develop.com. </HTML> ------_=_NextPart_001_01C2B80B.51AA46E0--