Re: AW: [OLEDB_DEV] OLE DB Consumer Templates
Yuancai Ye <[email protected]> Thu, 9 Jan 2003 08:56:49 -0800
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
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.