Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: sql2008 Filestream

by ksublondie (Friar)
on Mar 01, 2011 at 19:48 UTC ( #890805=note: print w/replies, xml ) Need Help??


in reply to Re: sql2008 Filestream
in thread sql2008 Filestream

Well, after using placeholders I'm not getting any errors anymore, but I'm not sure if the data is getting there properly. When I retrieve the binary data from the db (still have to figure out how to convert it back to ps), I'm only getting 161 characters out of the database when my original ps content was 1.3M. Can that be right???

...Oh, and the memory error is no longer showing up either...

Replies are listed 'Best First'.
Re^3: sql2008 Filestream
by Eliya (Vicar) on Mar 01, 2011 at 20:07 UTC
      Slowly making progress...

      FINALLY retrieved my ps content from the db, however, I have discovered that I'm also concatenating the data inserted into the table. Selecting is fixed...back to working on getting the data in there. I've applied the blob update code from the DBD::Sybase documentation you linked, but now I'm getting:

      DBD::Sybase::st syb_ct_send_data failed: Server message number=102 sev +erity=15 state=1 line=1 server=SQL2008\SQL2008 text=Incorrect syntax near '0x00000000000000000000000000000000'.
      My previous insert was letting sql convert the binary for me. But, now I'm not sure if I'm converting the binary data correctly in this method or not.
      sub printTransaction{ ... my $statement ="insert into PrintedChecks (Checkid,[datetime],id,print +edby,data) values (?,?,?,?,cast(? as varbinary(MAX))) "; my $sth=$db->prepare($statement); eval{ $sth->execute(($checkid,$now,$id,$userid,'')); }; if ($@){ $db->rollback; return 0; } $db->commit; $sth = $db->prepare("select data from printedchecks where id = '$id'") +; $sth->execute; while($sth->fetch) {$sth->syb_ct_data_info('CS_GET', 1);} $sth->syb_ct_prepare_send(); my $binary = pack("b*", $print); #Is this right??? $sth->syb_ct_data_info('CS_SET', 1, {total_txtlen => length($binary), +log_on_update => 0}); $sth->syb_ct_send_data($binary, length($binary)); $sth->syb_ct_finish_send(); ... }
        my $binary = pack("b*", $print); #Is this right???

        pack("b*",...) packs a "bit string", i.e. a string consisting of "0" and "1" (ASCII 48 and 49), e.g.

        print pack("b*", "011001101111011011110110") # --> "foo"

        but Postscript content doesn't consist of solely ASCII zeros and ones, so this is most likely not correct.

        My guess would be that you don't need to do anything with $print.  Just treat it as binary data (any string is "binary" in the wider sense, even if it's ASCII/7-bit only), i.e. use $print where you now have $binary.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://890805]
help
Chatterbox?
[shmem]: Discipulus: while (readdir DIR) works fine
[Discipulus]: Eataly vs World(coffe) ;=)
[Discipulus]: shemem i wrote it directly.. but when i tested it i got a lot of 'undefined value..'
[Corion]: Oh, poor Trump can't get a break. Even the Vatican only sends the second in command to greet him...
[shmem]: Discipulus: readdir has the same semantics as readline (a.k.a <>). Have another coffee ☕ ;-)
[Discipulus]: ah! just with my old system perl (5.8.8) was needed
[Corion]: Has anybody toyed around with Mastodon? There is a Perl module for it, but I'm not sure that it's a yak worth chasing
[Corion]: On the upside, maybe running that for my family would be interesting, or at least for myself
[Corion]: I'm not fond of using a server hosted by other people, even if they claim to be GNU ;)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2017-05-26 07:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?