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: CTlib: Binary as Char?
Date: Dec 28 2007 9:17AM

I don't have access to a dataserver right now (up in the mountains
skiing :-), but IIRC you have to pass a real binary value - you can
use pack() to generate this from the 0xabcd form.

I suppose that Sybase::CTlib could do this for you... though that will
require some changes to the code.

Take a look at the t/...blk.t file for some examples of using BLK to
insert binary data.

Michael

On Dec 27, 2007 6:31 PM,   wrote:
>
> I'm converting an older program for use on Sybase 15.  In this process there
> is a routine that used DBlib's BCP routines which I'm dutifully converting
> to CTlib's BLK routines.  The conversion has gone well except for the
> insertion into the BINARY(16) fields.  Using the BLK routines and the
> ct_dyn* routines seem to insert the values as strings rather than their hex
> equivalents.
>
> For example, a simple insert like the following yields the expected results:
>
> $hex_value = "0x2a";
> $dbh->ct_sql( q{INSERT INTO #bin_test VALUES ( $hex_value ) } );
>
> returns 0x2a000, while using the following:
>
> $dbh->ct_dyn_prepare( qq{INSERT INTO #bin_test VALUES ( ? )} );
> $dbh->ct_dyn_execute( [ $hex_value ] );
>
> returns 0x30783261.  Basically treating it like a string because I get the
> same value if I insert like so:
>
> $dbh->ct_sql( q{INSERT INTO #bin_test VALUES ( "$hex_value" ) } );
>
> The bulk routines have the identical issue.  Reading the archives to try to
> solve this revealed a similar issue some time ago
> (http://www.peppler.org/archive/sybperl-l/2001/8/6517.html), however, this
> file doesn't seem to exist any more in the package.  What am I missing here?
> Thanks in advance!
>
> Jayson Pifer
>
>
> ________________________________
>
>
>  This communication is for informational purposes only. It is not intended
> as an offer or solicitation for the purchase or sale of any financial
> instrument or as an official confirmation of any transaction. All market
> prices, data and other information are not warranted as to completeness or
> accuracy and are subject to change without notice. Any comments or
> statements made herein do not necessarily reflect those of JPMorgan Chase &
> Co., its subsidiaries and affiliates. This transmission may contain
> information that is privileged, confidential, legally privileged, and/or
> exempt from disclosure under applicable law. If you are not the intended
> recipient, you are hereby notified that any disclosure, copying,
> distribution, or use of the information contained herein (including any
> reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any
> attachments are believed to be free of any virus or other defect that might
> affect any computer system into which it is received and opened, it is the
> responsibility of the recipient to ensure that it is virus free and no
> responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and
> affiliates, as applicable, for any loss or damage arising in any way from
> its use. If you received this transmission in error, please immediately
> contact the sender and destroy the material in its entirety, whether in
> electronic or hard copy format. Thank you. Please refer to
> http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK
> legal entities.