Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: John_Erjavec at cargill dot com
Subject: Re: confused with error while using ct_sql
Date: Nov 10 1998 4:20PM

     The problem appears to have been with my dereferencing.  I got some 
     help from one of the guys here (Mark Conty, who is also on the list), 
     and we (mostly he *g*) figured out that the call should have been 
     more like this:
     ====================GOOD CODE CALL======================= 
     foreach $r (@$rows) {
         if (($r->{'Name'} =~ /^DSI\s*$/) &&
             ($r->{'Info'} =~ /.+\..+/)) {
             printf STDOUT "Name: %s -- Info: %s\n",
               $r->{'Name'}, $r->{'Info'};
     ====================GOOD CODE CALL=======================
     and not like this, which is how it was:
     ====================BAD CODE CALL======================== 
     foreach $row_ref (@rows) {
        printf ("$$row_ref{'Name'}\n");
        if (($$row_ref{'Name'} eq "DSI") &&
            ($$row_ref{'Info'} =~ /.+\..+/)) {
            print "Name: ", $$row_ref{'Name'}, "\n"; 
            print "Info: ", $$row_ref{'Info'}, "\n";
     ====================BAD CODE CALL========================
     Anyway, this works, but is there a better way?  I would hate to be 
     jumping around when I didn't have to.  Also, I have the feeling that 
     I should be doing CTLib, since Sybase has said that they aren't going 
     to be updating DBLib anymore, but what are the opinions out there?  
     Just wondering what I should be doing.  Thanks for the help.
     John Erjavec V
     Sybase DBA
     Cargill, Inc.
______________________________ Reply Separator _________________________________
Subject: Re: confused with error while using ct_sql
Author:  mpeppler ( at mtka-unix-mime 
Date:    11/9/98 7:07 PM
I really don't know what the problem is here.
I suggest the following:
use Data::Dumper;
print Dumper(\@rows), "\n";
to see what the real structure of the @rows array is...
Michael writes:
 >      All-
 >      I am building an app that is going to ensure that our DSI threads are 
 >      down for as little time as possible.  (OK, I am rewriting an app...)  
 >      I am trying to take example code from the docs, and modify it, since 
 >      I am new to writing sybperl apps.  The following is the main chunk of 
 >      code that is causing the error:
 >      =================CODE CHUNK======================
 >      $X = Sybase::CTlib->ct_connect($uid, $pwd, $srv, $app); 
 >      @rows = $X->ct_sql("admin who", undef, 1) || die "execute failed!"; 
 >      foreach $row_ref (@rows) {
 >              if (($$row_ref{'Name'} eq "DSI") &&
 >                      ($$row_ref{'Info'} =~ /.+\..+/)) {
 >                      print "Name: ", $$row_ref{'Name'}, "\n"; 
 >                      print "Info: ", $$row_ref{'Info'}, "\n"; 
 >              }
 >      }
 >      =================CODE CHUNK====================== 
 >      It is giving me the following error (under -w and use diagnostics): 
 >      =================ERROR===========================
 >      Argument "DSI EXEC  " isn't numeric in helem at ./who_test line 18 
 >      (#1)
 >          (W) The indicated string was fed as an argument to an operator 
 >      that
 >          expected a numeric value instead.  If you're fortunate the 
 >      message
 >          will identify which operator was so unfortunate. 
 >      Bad index while coercing array into hash at ./who_test line 18 (#2) 
 >          (F) The index looked up in the hash found as the 0'th element of 
 >      a
 >          pseudo-hash is not legal.  Index values must be at 1 or greater. 
 >          See perlref.
 >      Uncaught exception from user code:
 >              Bad index while coercing array into hash at ./who_test line 
 >      18.
 >      =================ERROR=========================== 
 >      Now, I'm not sure where the problem is, since I am not doing any 
 >      numeric tests, and I know that the keys 'Name' and 'Info' do exist 
 >      since I checked under perl -d.  Anyone have an idea what I am doing 
 >      wrong here?  Also, if you have a better way of doing what I am trying 
 >      to do, I would appreciate it.  Right now, I am spawning an isql 
 >      process, feeding it the SQL, and parsing the output.  The parsing is 
 >      done with regular expressions, and they can get pretty nasty for some 
 >      people.  I am specifically checking to see if any of the DSI threads 
 >      are down or suspended, and then I will take the appropriate action, 
 >      depending.  (The code above does not check for 'Down' or 'Suspended', 
 >      but this is just a first pass to make sure that this part is working, 
 >      which it is not. :( )
 >      Anyway, any help is appreciated. 
 >      -JEV
 >      John Erjavec V
 >      Sybase DBA
 >      Cargill, Inc.
Michael Peppler         -||-  Data Migrations Inc.       -||- 
Int. Sybase User Group  -||-
Sybase on Linux mailing list: