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: JPifer at jefco dot com
Subject: Re: Error in the script execution
Date: Jan 13 2003 6:18PM

      Hehe, good catch, Mike I missed that.  I also suspect that this is
evaluating as true:

       if ( uc("$opt_o") eq "Y")
       {
            $llog .= $tdbh->ct_sql("online database $opt_d");
       }

      This means that you are taking an array ref and appending another
array ref to it and are losing the magic of the reference as it is now a
string.  You won't be able to deref it, hence the error "Can't use string
("ARRAY(0x42987c)ARRAY(0x429888)") as an ARRAY ref..."
      I'm not quite sure what you are trying to do with your ".=", but I
think you want to push onto the array not append to the string.

      --Jayson




                                                                                                                                
                      Michael Burstin                                                                                           
                                           
                      m>                         cc:                                                                            
                      Sent by:                   Subject: Re: Error in the script execution                                     
                      owner-SYBPERL-L@li                                                                                        
                      st.cren.net                                                                                               
                                                                                                                                
                                                                                                                                
                      01/13/03 01:09:12                                                                                         
                      PM                                                                                                        
                      Please respond to                                                                                         
                      SYBPERL-L                                                                                                 
                                                                                                                                
                                                                                                                                




Are you sure you are getting a valid database handle in the first
place?  I don't think your check is valid:

> ###############################################
> ## Connect to the Target Server
> ###############################################
> my $tdbh = Sybase::CTlib->ct_connect("$opt_u", "$tpwd" ,"$opt_s");
>
> if($tdbh eq undef)

I didn't think you could test something being eq undef, just as in
Sybase, NULL != NULL.  I am pretty sure you need
             unless(defined($tdbh))
for this test.   Don't know that this is your problem, but might be a
something to keep in mind.


On Mon, Jan 13, 2003 at 11:45:16AM -0500, Sabherwal, Balvinder (MBS) wrote:
> Gurus,
>
> I have a script to perform the dump and load for given database. The
section
> of the script is given below. There are 2 parts of this script. Part 1
> handles the dump of the database and part 2 handles the load of the
> database.
>
> I'm trying to debug the script as it's not loading the database. The
command
> it send to the server is working in the isql session, not from the
script.
> The dump command is working fine and the same way is used to do the load.
> Could anyone help me figure this out as why my load command would not
from
> the script?? Secondly, When I check for the errors after executing the
load
> command, I'm getting error as "Can't use string
> ("ARRAY(0x42987c)ARRAY(0x429888)") as an ARRAY ref while "strict refs" in
> use at DBDumpLoad.pl line 313.".
>
> Thanks for all your help.
>
> ###############################################
> ## Execute the Database Dump command
> ###############################################
>
>       $dlog = $sdbh->ct_sql("$dumpcmd");
>
> ###############################################
> ## Check for the errors in the dump command execution
> ###############################################
>
> ## I don't know if this is ok. I get no errors on execution ##
> if ( @$dlog =~ /Msg/m || @$dlog =~ /Error/m )
> {
>       $errmsg .= "\n\n*** ERROR *** Dump of the database $opt_D on $opt_S
> failed \n";
>           $errmsg .= @$dlog ;
>       msg_send("$opt_M","DBDumpLoad.pl FAILED for $opt_S","$errmsg");
>       exit(1);
> }
>
> ###############################################
> ## Connect to the Target Server
> ###############################################
> my $tdbh = Sybase::CTlib->ct_connect("$opt_u", "$tpwd" ,"$opt_s");
>
> if($tdbh eq undef)
> {
>        $errmsg .= "\n\n*** ERROR *** Cannot open connection to $opt_s
> dataserver. \n The user id is $opt_u The location for the pwd file
> is $tfile \n ";
>       msg_send("$opt_M","DBDumpLoad.pl FAILED for $opt_s","$errmsg");
>       exit(1);
> }
> else
> {
>       if ( uc("$opt_K") eq "Y" )
>       {
>            ###############################################
>            ## Kill the users in the database before load
>            ###############################################
>          my $killcmd = $tdbh->ct_sql("select \"kill \"+convert(char,spid)
> from master..sysprocesses where db_name(dbid) = \"$opt_d\"");
>          foreach my $cmd (@$killcmd)
>          {
>             $tdbh->ct_sql("@$cmd");
>          }
>       }
>
>
###########################################################################
> ##  LOAD DATABASE COMMAND
>
###########################################################################
>    if ( uc("$opt_t") eq "DISK" and uc("$opt_O") eq "L" and $opt_P > 1 )
>    {
>        open(FL,"< $opt_f");
>        while ( FL )
>        {
>          chomp($_);
>          $dmpfile .= "stripe  on $_";
>        }
>    }
>    my $cmd = substr($dmpfile,10);
>    $dmpfile = $cmd;
>
>    if ( uc("$opt_t") eq "DISK" and ( !$opt_G or uc("$opt_G") eq "N" ) )
>    {
>        $dmpfile = "$opt_f"."/"."$opt_D.dmp";
>    }
>
>    if ( uc("$opt_t") eq "TAPE" )
>    {
>         $dmpfile = "$opt_f";
>    }
>
>    if ( uc("$opt_T") eq "D" )
>    {
>       if ( $opt_C )
>       {
>            $dumpcmd = "Load database $opt_d from
> \"compress::"."$opt_C"."::$dmpfile\"" ;
>       }
>       else
>       {
>            $dumpcmd = "Load database $opt_D from \"$dmpfile\"" ;
>       }
>    }
>    else {
>       if ( $opt_C )
>       {
>            $dumpcmd = "Load tran $opt_D from
> \"compress::"."$opt_C"."::$dmpfile\"" ;
>       }
>       else
>       {
>            $dumpcmd = "Load tran $opt_D from \"$dmpfile\"" ;
>       }
>    }
>
>            ###############################################
>            ## Execute the Database Load command
>            ###############################################
>       $llog = $tdbh->ct_sql("$dmpfile");
>
>            ###############################################
>            ## Execute the online Database command
>            ###############################################
>       if ( uc("$opt_o") eq "Y")
>       {
>            $llog .= $tdbh->ct_sql("online database $opt_d");
>       }
>            ###############################################
>            ## Check for the errors in load and online database commands
>            ###############################################
>
> ####################################
>       foreach my $l ( @$llog )           ## This is line 313 in the
script ##
>       {
####################################
>           if ( @$l =~ /Msg/m )
>           {
>                 $errmsg .= "\n\n*** ERROR *** Load of the database $opt_d
> failed \n";
>                 $errmsg .= @$llog ;
>                 msg_send("$opt_M","DBDumpLoad.pl FAILED for
> $opt_S","$errmsg");
>                 exit(1);
>           }
>       }
>
> ############################
> ## DEBUG Screen Outputs
> ############################
> #######################################
> ## Load cmd being sent to dataserver ##
> #######################################
>   DB<8> p $dumpcmd
> Load database RepStd from "compress::3::/tmp/RepAct.dmp"
>
> #######################################
> ## value for the database handle     ##
> #######################################
>   DB<9> p $tdbh
> Sybase::CTlib=HASH(0x429894)
>

--
Michael Burstin
NPI Engineer
Concerto Software
978-952-0842
mikeb@concerto.com







--------------------------------------------------------------
Jefferies archives and reviews outgoing and incoming e-mail.  Such may be 
produced at the request of regulators. Sender accepts no liability for 
any errors or omissions arising as a result of  transmission. Use by other than 
intended recipients is prohibited. This is neither an offer nor a 
solicitation of an offer to buy or sell securities. Opinions or estimates 
constitute our best judgment at this time and are subject to change without 
notice. Information upon which this material is based was obtained from 
sources believed to be reliable but has not been verified. Additional 
information is available upon request. Jefferies its affiliates and 
respective directors officers and employees may buy or sell 
securities mentioned as agent or principal. This is for use by 
professional or institutional investors only. No investments or 
services mentioned or described are available to "private 
customers" as defined by the FSA or to anyone in Canada not a "Designated 
Institution".