Can't locate object method "fetchrow_array" Error

Hi,
I have a perl script which is interacting with Database.

I have following line of code :

sub BEGIN
{
#use Getopt::Std;
#getopt ('S');
#($STEAP)=($opt_S);

    use lib \("/home/perl_lib"\);
    use NewSybDBLib;
    use Sybase::DBlib;
    use IniFileUtil;
    use ErrMsgUtil;
    use strict;

}

sub main();
main();

    print "\\nMESSAGE:\\n";
    $dbh->SetSQLCmd\("select *  from  test "\);
    @result=$dbh->ExecSQL\(\);
    if\($dbh->\{message_text\}\) \{
            print "DB MESSAGE\\n";
            print $dbh->\{message_text\} . "\\n";
            $dbh->\{message_text\}="";
    \}
    if\($dbh->\{error_text\}\) \{
            $db\_error\_text=$dbh->\{error_text\};
            $dbh->Delete;
            die "ERROR: \\n" . $db\_error_text . "\\n";
    \}

    while \(@result = $dbh->fetchrow_array\(\)\) \{
                my $tablename   = $result[1];
                my $firstrun    = $result[2];
                my $firstsuccess = $result[3];
                print " $tablename  $firstrun  $firstsuccess \\n";
              \}

The SQL command is getting records from table test .
If i omit my while loop at the end which is using fetchrow_array then script is running perfectly but when i tried to get the records one by one using fetch_row_array() i got the Error :

Can't locate object method "fetchrow_array" via package "NewSybDBLib"

I use the package use Sybase::DBlib but it is not working.

Any idea what might be the solution.

rawat

Hey Rawat,

As far as I know, the fetchrow_array is used with the statement handle ($sth) rather than database handle ($dbh). Try to differentiate $dbh and $sth, and put $sth in the appropriate places.

Let me know if that works out!!

Regards,
Kuks