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: mpeppler at itf dot ch (Michael Peppler)
Subject: Re: Problems with writing text
Date: Jan 25 1996 9:18AM

From: mpeppler@itf.ch (Michael Peppler)
> I just ran some tests here, and I got some pretty weird results...

I found the problem - it is the same with both Sybperl 1.x (that you
have Rob) and 2.x (for use with Perl 5) - and the problem is indeed
with &dbwritetext().

What happens is this:
When sybperl calls dbwritetext() internally, it asks the Perl
interpreter for the size of the data buffer that it must write. This
'size' variable returns the internally allocated size, not necessarilly
the actual length of the buffer, so when a variable holding a text
buffer shrinks the &dbwritetext() call doesn't see it.

The work-around: undefine the $text variable before assigning the
buffer to it.

> #!/usr/local/bin/sybperl.old
> # I used the 1.012 version...
> require 'sybperl.pl';
> 
> $d1 = &dblogin('mpeppler', 'guess-what', 'TROLL');
> 
> while(<*>) {
>     open(IN, $_) || die "Can't open $_: $!\n";
>     @lines = ;
###
      undef($text);	#### "KILL" the variable!!!
###
>     $text = "@lines";
>     close(IN);
>     print "Processing $_\n";
>     &dbcmd($d1, "insert story values('$_', '')");
>     &dbsqlexec($d1);
>     while(&dbresults($d1) != $NO_MORE_RESULTS) {
> 	while(@dat = &dbnextrow($d1)) {
> 	    print "@dat\n";
> 	}
>     }
>     &dbcmd($d1, "select name, data from story where name = '$_'");
>     &dbsqlexec($d1);
>     &dbresults($d1);
>     @dat = &dbnextrow($d1);
>     &dbwritetext($d1, "story.data", $d1, 2, $text);
> }

I'll see if I can find a better solution (internally to the C code) for
a future release.

Michael