[23660] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5867 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 28 00:05:49 2003

Date: Thu, 27 Nov 2003 21:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 27 Nov 2003     Volume: 10 Number: 5867

Today's topics:
        Could not allocate enough memory ( Fetch a Blob column  <itjobs@sympatico.ca>
    Re: Could not allocate enough memory ( Fetch a Blob col (Sam Holden)
    Re: Curses %$#@! <nobull@mail.com>
    Re: Curses %$#@! Default@IO_Error_1011101.xyz [JDM]
    Re: Curses %$#@! <uri@stemsystems.com>
    Re: Curses %$#@! Default@IO_Error_1011101.xyz [JDM]
    Re: Curses %$#@! Default@IO_Error_1011101.xyz [JDM]
    Re: Curses %$#@! <uri@stemsystems.com>
    Re: DBI error handling ctcgag@hotmail.com
    Re: DBI error handling <mb@uq.net.au.invalid>
    Re: Does alarm work on w2k? Default@IO_Error_1011101.xyz [JDM]
        Does gethostbyname return a number or a string or ... <someone@microsoft.com>
    Re: Does gethostbyname return a number or a string or . <noreply@gunnar.cc>
    Re: Does gethostbyname return a number or a string or . <someone@microsoft.com>
    Re: Does gethostbyname return a number or a string or . <usenet@morrow.me.uk>
    Re: floating point <eddhig22@yahool.com>
        Here is the Code <itjobs@sympatico.ca>
    Re: Here is the Code (Sam Holden)
    Re: How to create a DBM database in Perl (Topher)
    Re: How to create a DBM database in Perl <syscjm@gwu.edu>
    Re: Packages and returning errors <usenet@morrow.me.uk>
    Re: Packages and returning errors (Sam Holden)
        Perl SSL Variable (Josh Harlan)
    Re: Perl SSL Variable <nobody@dev.null>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 27 Nov 2003 18:46:14 -0500
From: "Steve" <itjobs@sympatico.ca>
Subject: Could not allocate enough memory ( Fetch a Blob column from a MS-SQL(7) table. SQL)
Message-Id: <j0wxb.15446$Eq1.1617446@news20.bellglobal.com>

I am trying to fetch a Blob column from a MS-SQL(7) table. SQL
Select terminates with and error:

"SQL ERR on: Select viewcontent  from NewProfile where  ID='Prof2' and
CUSTID='sandy'"

SQL-Err:[911] [4] [0] "Could not allocate enough memory (-1 bytes) for
column 1.

'viewcontent' is a Blob (Image) field in MS-SQL (ver 7.0)
can anyone Help?

B.Ghassemlou




------------------------------

Date: 28 Nov 2003 00:49:28 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Could not allocate enough memory ( Fetch a Blob column from a MS-SQL(7) table. SQL)
Message-Id: <slrnbsd6so.9lq.sholden@flexal.cs.usyd.edu.au>

On Thu, 27 Nov 2003 18:46:14 -0500, Steve <itjobs@sympatico.ca> wrote:
> I am trying to fetch a Blob column from a MS-SQL(7) table. SQL
> Select terminates with and error:
> 
> "SQL ERR on: Select viewcontent  from NewProfile where  ID='Prof2' and
> CUSTID='sandy'"
> 
> SQL-Err:[911] [4] [0] "Could not allocate enough memory (-1 bytes) for
> column 1.
> 
> 'viewcontent' is a Blob (Image) field in MS-SQL (ver 7.0)
> can anyone Help?

That's not a perl error message, and I see no Perl code.

-- 
Sam Holden


------------------------------

Date: 27 Nov 2003 19:17:39 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Curses %$#@!
Message-Id: <u9smk9boz0.fsf@wcl-l.bham.ac.uk>

Default@IO_Error_1011101.xyz [JDM] writes:

> > Default@IO_Error_1011101.xyz writes:
> > 
> > > Subject: Re: Curses %$#@! 
> > 
> > Your question  has nothing to do with Curses.
>    Grin
> > Perl module names are case sensative.
> 
> I've altered the code... same results

If the "same results" means you still get errors saying stuff about
"Strict.pm" then you've not altered all the code.

If the "same results" means something else then this must be some
unusual use of "same" I'm not familar with.

Since you don't say what the program does and why this is wrong I'm
just going make some general observations.

> #!
> use strict;
> use warnings;
> use diagnostics;
> use Curses;
> use Socket;

Don't use the low-level Socket module directly to implement IP sockets
unless you are a masochist.  Use IO::Socket::INET.

> $| = 1;
> 
> my ($internet_addr, $paddr, $remote_port, $remote_host, $kidpid1,
>     $kidpid2, $kidpid3, @ports_even1, @ports_odd1, @ports_even2,
>     @ports_odd2,);

If you find youself declaring a series of variables  $foo1, $foo2,
$foo3 you should see the word "array" float before your eyes and glow
so brightly it causes pain.

Do not declare all your variables up top.  It defeats half the point
of using explicit declaration in the first place.  Always declare all
variables as lexically scoped in the smallest applicable scope unless
there is a reson to do otherwise.  This is not perculliar to Perl it
applies in all languages in which the concept of lexical variable
scope exists. 

> my $counter = 1;
> my $p_e_loader1 = 2;
> my $p_o_loader1 = 1;
> my $p_e_loader2 = 514;
> my $p_o_loader2 = 513;
> print "\n" . ' ' . '='x78 . "\n";
> print "\t\t\t\tPort Scanner\n";
> print ' ' . '='x78 . "\n\n";
> 
> initscr;
> while ($counter <= 256)
> {
>     push (@ports_even1, $p_e_loader1);
>     $p_e_loader1++;$p_e_loader1++;
>     $counter++;
>     if ($counter >= 250) {print "\n@ports_even1\n";my $pause = <STDIN>;}
> }

Using C-style for in Perl is usually poor style.  But avoiding a
C-style for by simulating it with while() is worse.

What you did was:

> my $counter = 1;
> while ($counter <= 256)
> { 
      # Do stuff
>     $counter++;
> }

As a C-style for this is:

for ( my $counter = 1; $counter <= 256; $counter++ ) {
    # Do stuff
}

As a Perl-style for it is 

for my $counter ( 1 .. 256 ) {
   # Do stuff
}

Both of these also declare $counter in the correct scope.

Actually since you aren't using $counter, and are not using $_ for
anything already it would just be

for ( 1 .. 256 ) {
   # Do stuff
}

> $counter = 1;
> while ($counter <= 256)
> {
>     push (@ports_even2, $p_e_loader2);
>     $p_e_loader2++;$p_e_loader2++;

Any particular reason you didn't use +=2 ?

>     $counter++;
> }

A more conventional way to get even numbers say 2 to 20 would be:

my @even_numbers = map { $_ * 2 } 1 .. 10;

> $counter = 1;
> while ($counter <= 256)
> {
>     push (@ports_odd2, $p_o_loader2);
>     $p_o_loader2++;$p_o_loader2++;
>     $counter++;
> }

If you find youself writing the same code over using a series of
variables $foo1, $foo2, $foo3 you should see the word "array" float
before your eyes and glow so brightly that you can actually smell the
skin on your face start to smoulder.

> undef $counter;

Don't try to work-round the fact that you've declared a variable in
the wrong scope.  Just do the right thing in the first place.
 
> #resolve targets address
> $remote_host = shift || 'localhost';
> $internet_addr = inet_aton($remote_host) ||
>     die "Couldn't resolve $remote_host"."'s address\n($!)\n($^E)*";
> 
> #create two processes
> die "can't fork\n($!)\n($^E)\n*" unless defined($kidpid1 = fork());

Eeek!  You are using $^E.  That means Win32. ISTR that forking and
sockets and Win32 don't mix too well.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Thu, 27 Nov 2003 19:49:36 GMT
From: Default@IO_Error_1011101.xyz [JDM]
Subject: Re: Curses %$#@!
Message-Id: <kzsxb.1846$i81.1300@nwrdny02.gnilink.net>

> Default@IO_Error_1011101.xyz [JDM] writes:
> 
> > > Default@IO_Error_1011101.xyz writes:
> > > 
> > > > Subject: Re: Curses %$#@! 
> > > 
> > > Your question  has nothing to do with Curses.
> >    Grin
> > > Perl module names are case sensative.
> > 
> > I've altered the code... same results
> 
> If the "same results" means you still get errors saying stuff about
> "Strict.pm" then you've not altered all the code.
> 
> If the "same results" means something else then this must be some
> unusual use of "same" I'm not familar with.
> 
> Since you don't say what the program does and why this is wrong I'm
> just going make some general observations.

ok, the script works fine... untill i add use curses.. without curses all is well
with it the script simply ends with no errors.


------------------------------

Date: Thu, 27 Nov 2003 22:48:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Curses %$#@!
Message-Id: <x7wu9lo2br.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull@mail.com> writes:

  BM> If you find youself writing the same code over using a series of
  BM> variables $foo1, $foo2, $foo3 you should see the word "array" float
  BM> before your eyes and glow so brightly that you can actually smell the
  BM> skin on your face start to smoulder.

i was wondering what that smell was. i thought it was the code! :)

  BM> Eeek!  You are using $^E.  That means Win32. ISTR that forking and
  BM> sockets and Win32 don't mix too well.

i just did a test with socketpair and fork on win32 and it works
fine. but caveat coder.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Fri, 28 Nov 2003 01:11:58 GMT
From: Default@IO_Error_1011101.xyz [JDM]
Subject: Re: Curses %$#@!
Message-Id: <yhxxb.4436$UG2.1004@nwrdny03.gnilink.net>

> >>>>> "BM" == Brian McCauley <nobull@mail.com> writes:
> 
>   BM> If you find youself writing the same code over using a series of
>   BM> variables $foo1, $foo2, $foo3 you should see the word "array" float
>   BM> before your eyes and glow so brightly that you can actually smell the
>   BM> skin on your face start to smoulder.
> 
> i was wondering what that smell was. i thought it was the code! :)
> 

hehe, hey i just started programming four weeks ago.
perl is my first programming language.

so, forget the ip stuff, thats not very important.. what im mostly curious
about is what going on with the curses module.  any ideas?

cheers.


------------------------------

Date: Fri, 28 Nov 2003 01:56:04 GMT
From: Default@IO_Error_1011101.xyz [JDM]
Subject: Re: Curses %$#@!
Message-Id: <UWxxb.7867$lF6.4841@nwrdny01.gnilink.net>

> >>>>> "BM" == Brian McCauley <nobull@mail.com> writes:
> 
>   BM> If you find youself writing the same code over using a series of
>   BM> variables $foo1, $foo2, $foo3 you should see the word "array" float
>   BM> before your eyes and glow so brightly that you can actually smell the
>   BM> skin on your face start to smoulder.
> 
> i was wondering what that smell was. i thought it was the code! :)
> 
>   BM> Eeek!  You are using $^E.  That means Win32. ISTR that forking and
>   BM> sockets and Win32 don't mix too well.
> 
> i just did a test with socketpair and fork on win32 and it works
> fine. but caveat coder.
> 
> uri
> 
> -- 
> Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
> 

btw what you just posted is completly useless and mean uri or norman or
whoever you are. :p


------------------------------

Date: Fri, 28 Nov 2003 04:32:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Curses %$#@!
Message-Id: <x7he0pnme8.fsf@mail.sysarch.com>

>>>>> "D" == Default  <Default@IO_Error_1011101.xyz> writes:

  >> 
  >> i was wondering what that smell was. i thought it was the code! :)
  >> 
  BM> Eeek!  You are using $^E.  That means Win32. ISTR that forking and
  BM> sockets and Win32 don't mix too well.
  >> 
  >> i just did a test with socketpair and fork on win32 and it works
  >> fine. but caveat coder.

  D> btw what you just posted is completly useless and mean uri or
  D> norman or whoever you are. :p

hmm, you followed up to brian's email and respond to mine. and my name
is right here in plain sight. so you must have looked up the domain and
saw the name of my late father. how brilliant.

as for my comment, it was a joke but you can't seem to figure that
out. i don't think i will be offering much help in your direction.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: 27 Nov 2003 21:22:50 GMT
From: ctcgag@hotmail.com
Subject: Re: DBI error handling
Message-Id: <20031127162250.379$Bu@newsreader.com>

Lars Purschke <purschke@uni-muenster.de> wrote:
> Hi!
>
> I've a perl script which inserts data to a database. Sometime I get an
> error on the execute() statement. Now I want the script not to die but
> to exit the loop and to try again with the next record.

If it exits the loop, then it is NOT going to try again with the next
record, is it?

> Does anyone know
> how to realize that?

I would think that the code you show below would
to about what you want, because if $rs->execute causes an error, the
fetchrow_array in the next loop iteration should reset the err variable, so
you shouldn't find $sth->err to be inheriting $rs's errors, but I might be
wrong on that (I never use RaiseError=>0).  I would do this:

(don't unset RaiseError),

while( my(@row) = $sth->fetchrow_array ) {
   # no need to die here, RaisErroe does it for you
   #  die $sth->errstr if $sth->err;

        $stmt = "Insert into .... ";
        $rs = $dbh->prepare($stmt);
        eval {$rs->execute()};
}

On an unrelated issue, you probably shouldn't be doing the prepare
inside the loop.  If you need to do so, you may as well just use $dbh->do.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


------------------------------

Date: Fri, 28 Nov 2003 10:54:48 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: DBI error handling
Message-Id: <bq66co$jcp$1@bunyip.cc.uq.edu.au>

Lars Purschke wrote:

> Hi!
> 
> I've a perl script which inserts data to a database. Sometime I get an 
> error on the execute() statement. Now I want the script not to die but 
> to exit the loop and to try again with the next record. Does anyone know 
> how to realize that?
> 
> 
> my $dbh = DBI->connect("dbi:ODBC:$dsn", "xyz", "xyz",
>                 { PrintError => 0,
>                   RaiseError => 0}) or die "$DBI::errstr\n";
> 
> while( my(@row) = $sth->fetchrow_array ) {
>     die $sth->errstr if $sth->err;                   
> 
>     $stmt = "Insert into .... ";
> 
>     $rs = $dbh->prepare($stmt);
>     
>     $rs->execute();
> }
> 
> thanks
> lars
> 

I always make the connection options set to { PrintError => 0, 
RaiseError => 1} and then wrap all prepare/execute calls in an eval.

So your code would become:

my $dbh = DBI->connect("dbi:ODBC:$dsn", "xyz", "xyz",
                 { PrintError => 0,
                   RaiseError => 1}) or die "$DBI::errstr\n";

while( my(@row) = $sth->fetchrow_array ) {
     die $sth->errstr if $sth->err;

     $stmt = "Insert into .... ";

     eval {$rs = $dbh->prepare($stmt)};
     if ($@) {
        # Do something to handle error
     }
     eval {$rs->execute()};
     if ($@) {
        # Do something to handle error
     }
}


You could even shrink the evals down to:
     eval {$rs = $dbh->prepare($stmt); $rs->execute};
if you don't really need to distinguish between prepare and execute errors.

MB



------------------------------

Date: Thu, 27 Nov 2003 19:55:38 GMT
From: Default@IO_Error_1011101.xyz [JDM]
Subject: Re: Does alarm work on w2k?
Message-Id: <_Esxb.3378$UG2.1176@nwrdny03.gnilink.net>


> > any ideas about the display issues?
> 
> You posted 150 lines of code with nothing but a leading comment about alarm.
> What display issues?
> 
> Anno
> 
Well the currently scanned port is printing in all four threads and they are
copying over eachother this looks messy, ive been trying to get it work better
with curses but when i add curses the program simply ends with no errors at all.
therefore i would like to use simple print statements in a similar fasion to this version
of the script but im not sure how to make the currently scanned port print in one x,y 
coord.  please note i've started a new thread with the curses version of the script
with the subject Curses %$#@!

Thank You -  very much for replying your help is very appreciated.


------------------------------

Date: Fri, 28 Nov 2003 02:15:40 GMT
From: "John Smith" <someone@microsoft.com>
Subject: Does gethostbyname return a number or a string or ...
Message-Id: <gdyxb.175$Ms1.9708@ursa-nb00s0.nbnet.nb.ca>

I am trying to use the following code but I am not familiar enough with
network commands.

  $ipad=gethostbyname($msvr);    # the msvr scalar is the domain name of a
mailserver ex: smtp.domain.com
  print"ipad = $ipad \n";

The result of the above commands is a bunch of odd characters, as shown
below.

  ipad = ƤÈ

I also found the following code on the Internet, and I sorta assumed it was
good code, but of course I could be wrong!

  $ip = gethostbyname($Domain);
  if($ip == "64.94.110.11") {

First of all, the second line of code is using == instead of eq to compare
the contents of $ip with characters.
I thought you could use if($a == 1) , or maybe if($a eq "hello"), but not
if($a == "hello").
Second, why is this code assuming that the contents of $ip may be an ip
address while my result is just odd characters.

In my example, am I able to print the result as an IP address instead of odd
characters?
Any and all information greatly appreciated as always.

G. Doucet




------------------------------

Date: Fri, 28 Nov 2003 03:46:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Does gethostbyname return a number or a string or ...
Message-Id: <bq6d0c$1u4uiu$1@ID-184292.news.uni-berlin.de>

John Smith wrote:
> I am trying to use the following code but I am not familiar enough
> with network commands.
> 
>   $ipad=gethostbyname($msvr);    # the msvr scalar is the domain name
> of a mailserver ex: smtp.domain.com
>   print"ipad = $ipad \n";
> 
> The result of the above commands is a bunch of odd characters, as
> shown below.
> 
>   ipad = ƤÈ

So, if you wonder about what a Perl function returns, you should check
the documentation for the function.

     http://www.perldoc.com/perl5.8.0/pod/func/getpwnam.html

> I also found the following code on the Internet, and I sorta
> assumed it was good code, but of course I could be wrong!
> 
>   $ip = gethostbyname($Domain);
>   if($ip == "64.94.110.11") {

To me it appears as if you were wrong. :)

> In my example, am I able to print the result as an IP address
> instead of odd characters?

Yes, if you unpack them as is explained in the docs:

     $ipad = join '.', unpack('C4', gethostbyname $msvr);

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



------------------------------

Date: Fri, 28 Nov 2003 03:55:52 GMT
From: "John Smith" <someone@microsoft.com>
Subject: Re: Does gethostbyname return a number or a string or ...
Message-Id: <cHzxb.264$Ms1.12089@ursa-nb00s0.nbnet.nb.ca>

Thanks for the info, I think I have it under control now. :-)

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bq6d0c$1u4uiu$1@ID-184292.news.uni-berlin.de...
> John Smith wrote:
> > I am trying to use the following code but I am not familiar enough
> > with network commands.
> >
> >   $ipad=gethostbyname($msvr);    # the msvr scalar is the domain name
> > of a mailserver ex: smtp.domain.com
> >   print"ipad = $ipad \n";
> >
> > The result of the above commands is a bunch of odd characters, as
> > shown below.
> >
> >   ipad = ƤÈ
>
> So, if you wonder about what a Perl function returns, you should check
> the documentation for the function.
>
>      http://www.perldoc.com/perl5.8.0/pod/func/getpwnam.html
>
> > I also found the following code on the Internet, and I sorta
> > assumed it was good code, but of course I could be wrong!
> >
> >   $ip = gethostbyname($Domain);
> >   if($ip == "64.94.110.11") {
>
> To me it appears as if you were wrong. :)
>
> > In my example, am I able to print the result as an IP address
> > instead of odd characters?
>
> Yes, if you unpack them as is explained in the docs:
>
>      $ipad = join '.', unpack('C4', gethostbyname $msvr);
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>




------------------------------

Date: Fri, 28 Nov 2003 04:06:42 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Does gethostbyname return a number or a string or ...
Message-Id: <bq6hki$bla$2@wisteria.csv.warwick.ac.uk>


Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Yes, if you unpack them as is explained in the docs:
> 
>      $ipad = join '.', unpack('C4', gethostbyname $msvr);

Better (because both shorter and clearer):

use Socket qw/inet_ntoa/;
$ipad = inet_ntoa gethostbyname $msvr;

There is also inet_aton for going the other way.

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


------------------------------

Date: Fri, 28 Nov 2003 06:55:48 +1100
From: Edo <eddhig22@yahool.com>
Subject: Re: floating point
Message-Id: <3FC656C4.7060804@yahool.com>

Jay Tilton wrote:
> Edo <eddhig22@yahool.com> wrote:
> 
> : why my sub cal which is suppose to return 0.879222 when it is
> : my $ca = cal (\@abc, \@xyz);
> : $ca returns 1.
> : 
> : how can I get it to return whatever the exact value the sub calculates?
> 
> How do you expect anybody to figure out what is wrong with the code unless
> they can see the code?  Show that cal() subroutine.
> 
> This is certainly not a problem with floats.  Perl treats all numbers as
> floats.  Perl doesn't just arbitrarily convert 0.879222 to 1 .
> 
> For a blind guess, cal() is probably trying to return an array, but you're
> using it in scalar context, e.g.
> 
>     sub cal {
>         my @stuff = 0.879222;
>         return @stuff;
>     }
>     my $ca = cal();
>     print $ca;
> 

the cal sub returns a scalar and not an array context. after few hours 
working on this, I found where the problem is, the sub is in a loop, and 
at one instant of the loop, one of the sub argument is undef which is 
another porblem I need to work out.

sorry for an un-nessasary thread which could have been avoided if I 
spent those few hours debugging the code. I have a long way to go with perl.

thanks



------------------------------

Date: Thu, 27 Nov 2003 20:21:00 -0500
From: "Steve" <itjobs@sympatico.ca>
Subject: Here is the Code
Message-Id: <dpxxb.16142$Eq1.1659667@news20.bellglobal.com>

Well I thought Memory allocation was by perl.
anyway here is the code, it fails on line 2 and dies on line 6

$SqlString ="Select viewcontent  from NewProfile where  ID='Prof2' and
CUSTID='sandy' ";
if(($dbh->Sql( $SqlString )))
   {
     $ErrMsg = 'SQL-Err:'.$dbh->Error();
     print "SQL ERR on: $SqlString $ErrMsg <BR>";
    die
   };
   $dbh->FetchRow();
   {
      undef %Data;
      %Data       = $dbh->DataHash();
      $FldContent=$Data{$_[1]};


"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbsd6so.9lq.sholden@flexal.cs.usyd.edu.au...
> On Thu, 27 Nov 2003 18:46:14 -0500, Steve <itjobs@sympatico.ca> wrote:
> > I am trying to fetch a Blob column from a MS-SQL(7) table. SQL
> > Select terminates with and error:
> >
> > "SQL ERR on: Select viewcontent  from NewProfile where  ID='Prof2' and
> > CUSTID='sandy'"
> >
> > SQL-Err:[911] [4] [0] "Could not allocate enough memory (-1 bytes) for
> > column 1.
> >
> > 'viewcontent' is a Blob (Image) field in MS-SQL (ver 7.0)
> > can anyone Help?
>
> That's not a perl error message, and I see no Perl code.
>
> -- 
> Sam Holden




------------------------------

Date: 28 Nov 2003 01:44:26 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Here is the Code
Message-Id: <slrnbsda3q.ahi.sholden@flexal.cs.usyd.edu.au>

On Thu, 27 Nov 2003 20:21:00 -0500, Steve <itjobs@sympatico.ca> wrote:
> Well I thought Memory allocation was by perl.
> anyway here is the code, it fails on line 2 and dies on line 6
> 
> $SqlString ="Select viewcontent  from NewProfile where  ID='Prof2' and
> CUSTID='sandy' ";
> if(($dbh->Sql( $SqlString )))
>    {
>      $ErrMsg = 'SQL-Err:'.$dbh->Error();
>      print "SQL ERR on: $SqlString $ErrMsg <BR>";
>     die
>    };
>    $dbh->FetchRow();
>    {
>       undef %Data;
>       %Data       = $dbh->DataHash();
>       $FldContent=$Data{$_[1]};

I don't know what type of object $dbh is, and DBI certainly doesn't
use the methods you use above (and that's the only one I have experience with).

So check the documentation of the module to see what it says about it.

One thing I do note, is that you are doing error handling when the Sql() method
returns a true value. That seems like a very badly designed module if that is
how it's meant to be done. If it isn't then of course you will get random error 
messages when you retrieve error messages when no error has occurred.

[snip full quote, including sig]

Please don't do that, quote the parts you are replying to and put
your reply below them.

-- 
Sam Holden


------------------------------

Date: 27 Nov 2003 16:20:21 -0800
From: chris@mkttl.co.uk (Topher)
Subject: Re: How to create a DBM database in Perl
Message-Id: <f4487ccf.0311271620.5003b2f1@posting.google.com>

ineverlookatthis@yahoo.com (Steve) wrote in message news:<f0d57f86.0311270655.16d571d9@posting.google.com>...
> chris@mkttl.co.uk (Topher) wrote in message news:<f4487ccf.0311270246.5a82a5c@posting.google.com>...
> > Hi,
>  ...........
> > I'm not too hot on this Perl business and am basically winging it with
> ....
> 
> Well I am not playing, but I have to say I find this game very
> entertaining. It seems to be happening quite often that someone posts
> a merest tease of a hint of what they are trying to do and some
> incomprehensible garbled code and everyone tries to guess the task and
> the existing errors and then write the code that they think might
> address the problem.
> 
> I am quite genuinely in awe of the skilled players.
> 
> Steve

Thanks people who have tried to help.  I feel stupid to have forgotten
the die statement now!

Steve, you will notice at the bottom of my post 'Thanks very much, if
you need any more info please ask', since I wasn't sure what other
information I should give.


------------------------------

Date: Thu, 27 Nov 2003 19:52:26 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: How to create a DBM database in Perl
Message-Id: <3FC69C4A.7040000@gwu.edu>

Topher wrote:
> ineverlookatthis@yahoo.com (Steve) wrote in message news:<f0d57f86.0311270655.16d571d9@posting.google.com>...
> 
>>chris@mkttl.co.uk (Topher) wrote in message news:<f4487ccf.0311270246.5a82a5c@posting.google.com>...
>>
>>>Hi,
>>
>> ...........
>>
>>>I'm not too hot on this Perl business and am basically winging it with
>>
>>....
>>
>>Well I am not playing, but I have to say I find this game very
>>entertaining. It seems to be happening quite often that someone posts
>>a merest tease of a hint of what they are trying to do and some
>>incomprehensible garbled code and everyone tries to guess the task and
>>the existing errors and then write the code that they think might
>>address the problem.
>>
>>I am quite genuinely in awe of the skilled players.
>>
>>Steve
> 
> 
> Thanks people who have tried to help.  I feel stupid to have forgotten
> the die statement now!
> 
> Steve, you will notice at the bottom of my post 'Thanks very much, if
> you need any more info please ask', since I wasn't sure what other
> information I should give.

If you read the guidelines, you'd *know* what info to give.  Generally, you
should give an example Perl program that is as small as you can make it but
still produces the problem, what you expect this program to do, and what is
*does* do instead.

                   Chris Mattern



------------------------------

Date: Thu, 27 Nov 2003 20:33:55 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Packages and returning errors
Message-Id: <bq5n3j$nqq$2@wisteria.csv.warwick.ac.uk>


Brian McCauley <nobull@mail.com> wrote:
<snip lots of stuff>
> "Chalk and cheese".  (Actually I hate that metaphor - cheese and chalk
> are both roughly hologeneous solids.  They have a lot in common.  I
> think "Chalk and chastisement" would be a better metaphor). 

Thank you for that... I like :).

<snip more useful stuff>
> > $im = new GD::MyMod(20,20);
> 
> It's probably bese not to get into the habit of using the indirect
> ibject syntax.  Oh, and you forgot to declare $im. 
> 
>  my $im = GD::MyMod->new(20,20);

Might I ask why you say this? I use it all the time, as a matter of
style, because I prefer to be able to avoid parenthesising function
calls where possible (so I would use
  my $im = new GD::MyMod 20, 20;
rather than with the parens): is there some gotcha with this I've not
realised?

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


------------------------------

Date: 27 Nov 2003 22:05:21 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Packages and returning errors
Message-Id: <slrnbsct91.7ig.sholden@flexal.cs.usyd.edu.au>

On Thu, 27 Nov 2003 20:33:55 +0000 (UTC),
	Ben Morrow <usenet@morrow.me.uk> wrote:
> 
> Brian McCauley <nobull@mail.com> wrote:
><snip lots of stuff>
>> "Chalk and cheese".  (Actually I hate that metaphor - cheese and chalk
>> are both roughly hologeneous solids.  They have a lot in common.  I
>> think "Chalk and chastisement" would be a better metaphor). 
> 
> Thank you for that... I like :).
> 
><snip more useful stuff>
>> > $im = new GD::MyMod(20,20);
>> 
>> It's probably bese not to get into the habit of using the indirect
>> ibject syntax.  Oh, and you forgot to declare $im. 
>> 
>>  my $im = GD::MyMod->new(20,20);
> 
> Might I ask why you say this? I use it all the time, as a matter of
> style, because I prefer to be able to avoid parenthesising function
> calls where possible (so I would use
>   my $im = new GD::MyMod 20, 20;
> rather than with the parens): is there some gotcha with this I've not
> realised?

perldoc perlobj

The section headed: "Indirect Object Syntax"

The phrase "the grief when it messes up just isn't worth the years of
debugging it will take you to track down such subtle bugs." might prompt
you to reconsider your choice of style.

The docs explain the problem better than I could, so I won't try
and do so.

-- 
Sam Holden


------------------------------

Date: 27 Nov 2003 18:56:01 -0800
From: josh@jsimports.com (Josh Harlan)
Subject: Perl SSL Variable
Message-Id: <3ac220b2.0311271856.49345636@posting.google.com>

Hello,

I am running a perl program in an unsecure directory and I would like
to know if there is an environmental variable or equivalent that will
display the SSL path (e.g. "https://ssl.website.com" or
"ssl.website.com").  Unfortunately, "https://ssl.$ENV{'SERVER_NAME'}"
will not work as the website domain and the SSL domain are not related
since I have a shared SSL.  I know how to determine the SSL path while
in a secure directory by using $ENV{'HTTP_X_FORWARDED_SERVER'}, but
not when in a unsecure directory.


Thanks for any help,
Josh


------------------------------

Date: Fri, 28 Nov 2003 03:21:09 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Perl SSL Variable
Message-Id: <3fc6bf23$1@bandit2.georgetown.edu>



Josh Harlan wrote:
> Hello,
> 
> I am running a perl program in an unsecure directory and I would like
> to know if there is an environmental variable or equivalent that will
> display the SSL path (e.g. "https://ssl.website.com" or
> "ssl.website.com").  

This really has nothing to do with Perl and everything to do with your 
web server.



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5867
***************************************


home help back first fref pref prev next nref lref last post