I have written a sample Perl program to delete data from a database table.
This is the code I have written,
use DBI;
my $dbh = DBI->connect("DBI:Pg:host=192.168.12.23;port=5432;", "adhi");
if ( $dbh ) {
print "Connected successfully\n";
my $exe = $dbh->prepare("delete from perl_test.test");
my $res = $exe->execute();
if ( $res ) {
print "deleted the table successfully of rows: $res\n";
}
}
If I have executed the above it should print successful message and then the number of rows deleted.
If the table was empty it was printing 0E0
instead of 0
.
I don't know how it is returning the value like this?
Can someone please explain me how it was working?
do
method to execute the query" but your program doesn't use thedo
method so I deleted that sentence. Please also indent your Perl code properly so that it is readable, especially before asking for help with it. – Sweatshop