PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Insertion of BINARY/VARBINARY values with DBD::Sybase?
Date: Aug 3 2001 3:53PM

Michael Peppler writes:
 > Steve Sabljak writes:
 >  >      $rawstr = pack("H*", "110011");
 >  >      $sth = $dbh->prepare("insert into sometable (bin) values (?)");
 >  >      $sth->execute($rawstr);
 >  > 
 >  >      The value 0x11 is inserted when what I want is 0x110011.
 >  >      It's truncated at the first nul byte.
 >  > 
 >  > Does the current version of DBD::Sybase support insertion of BINARY/VARBINARY
 >  > values using placeholders?
 > 
 > It's a bug in DBD::Sybase. I'll have a fix for you in a bit.

Here's a patch - apply to dbdimp.c

I should have a new version of DBD::Sybase out soon.

Michael
-- 
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
mpeppler@peppler.org - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com


Index: dbdimp.c
===================================================================
RCS file: /usr/local/cvsroot/DBD-Sybase/dbdimp.c,v
retrieving revision 1.25
diff -c -r1.25 dbdimp.c
*** dbdimp.c	2001/07/03 15:51:39	1.25
--- dbdimp.c	2001/08/03 15:48:33
***************
*** 3194,3199 ****
--- 3201,3210 ----
  	    d_value = atof(phs->sv_buf);
  	    value = &d_value;
  	    value_len = sizeof(double);
+ 	    break;
+ 	  case CS_BINARY_TYPE:
+ 	    phs->datafmt.datatype = CS_BINARY_TYPE;
+ 	    value = phs->sv_buf;
  	    break;
  	  default:
  	    phs->datafmt.datatype = CS_CHAR_TYPE;