How to print the names of tables of database using Perl scripting using unix. Connected to DB using DBI module.
I tried scripting using
my $driver= "Oracle";
my $dsn = "DBI:$driver:sid=as;host=asdsa";
my $dbh = DBI->connect($dsn, "a", "b") || die( $DBI::errstr . "\n" );
my $notables = $dbh->tables();
print "No of tables : $notables" ;
Getting error:
Can't call method "tables" on an undefined value at hello.pl line 16.
Please help.
$dbhobject is undefined. Are you sure you connected to the database? Pleae edit your question and include the part that doesmy $dbh = DBI->connect. Or better, include the full program. Also take a look at How to Ask to learn how to format code in your question.connect()will return either a database handle orundef. Returningundefwould trigger yourdie()call, so you must be getting a defined database handle back fromconnect(). I suspect there is something else going in parts of the code that you have removed to simplify your example.