Skip to Content.
Sympa Menu

freetds - RE: [freetds] Problem with dbrpcparam

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Problem with dbrpcparam
  • Date: Sat, 23 Apr 2005 17:21:38 +0200

Il giorno gio, 21-04-2005 alle 12:09 -0400, Lowden, James K ha scritto:
> > From: Michael Peppler
> > Sent: Thursday, April 21, 2005 11:53 AM
> >
> > On Thu, 2005-04-21 at 15:54, martin martin wrote:
> > > Hello, I have some problems passing binary data to stored procedures
> using
> > > db-lib. The parameter is a SYBIMAGE(IMAGE TYPE IN SQLSERVER)
> >
> > I don't know about MS-SQL, but for Sybase you can't pass IMAGE types
> as
> > parameters to a stored proc, and this may be reflected in the
> DB-Library
> > API.
>
> That was my initial reaction, and I probably relied on the Sybase docs.
> At some point along the way, though Microsoft lifted that restriction.
> On our 2000 server, I wrote a procedure that accepts a TEXT parameter.
> And the dbrpcparam Books Online entry includes this:
>
> ===
> maxlen
>
> For variable-length return parameters (when type is SQLCHAR, SQLBINARY,
> SQLTEXT, or SQLIMAGE), maxlen is the maximum desired byte length for the
> value parameter returned from a stored procedure.
> ===
>
> It's a little hard to imagine managing image data as a parameter in the
> general case. Parameters (as we implement them) reside in virtual
> memory, which a single TEXT parameter could potentially exhaust on a
> 32-bit machine. But I can see how in the non-general case it would be
> convenient. A varchar can be 8000 bytes; if your document is 15,000
> bytes, it would be nice to be able to treat as a "supervarchar".
>

I think this could work

diff -u -r1.41 rpc.c
--- src/dblib/rpc.c 3 Apr 2005 13:37:27 -0000 1.41
+++ src/dblib/rpc.c 23 Apr 2005 15:18:49 -0000
@@ -297,7 +297,15 @@
tdsdump_log(TDS_DBG_FUNC, "param_row_alloc(): doing data from
value\n");
if (size > 0 && value) {
tdsdump_log(TDS_DBG_FUNC, "param_row_alloc(): copying %d
bytes of data to parameter #%d\n", size, param_num);
- memcpy(&params->current_row[curcol->column_offset], value,
size);
+ if (is_blob_type(curcol->column_type)) {
+ TDSBLOB *blob = (TDSBLOB *)
&params->current_row[curcol->column_offset];
+ blob->textvalue = malloc(size);
+ if (!blob->textvalue)
+ return NULL;
+ memcpy(blob->textvalue, value, size);
+ } else {
+ memcpy(&params->current_row[curcol->column_offset],
value, size);
+ }
}
else {
tdsdump_log(TDS_DBG_FUNC, "param_row_alloc(): setting
parameter #%d to NULL\n", param_num);

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page