Can't delete postgresql table record using Perl

From: barry kimelman <perlmaster56(at)gmail(dot)com>
To: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Can't delete postgresql table record using Perl
Date: 2020-02-17 16:11:10
Message-ID: CAEOpmvqySeh2QML2sTNR=HEu_s51==NauxxEjC_CSL76+YpXTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

my laptop is windows 10 64-bit.
my Perl is activestate 5.28.1
my postgresql is 12.1

everything I do under psql works just fine. Now I have been writing some
Perl scripts. The Perl scripts to display data work very well. However the
Perl script I wrote to delete a record completes with no error yet when I
look at the database table the record is still in there.

1 #!C:\Perl64\bin\perl.exe -w
2
3 use strict;
4 use warnings;
5 use DBI;
6 use FindBin;
7 use lib $FindBin::Bin;
8
9 my ( $status , $dbh , $database , $username , $password , $host );
10 my ( $sql , $port , $num_rows );
11
12 $database = 'mydatabase';
13 $username = 'myusername';
14 $password = 'mypassword';
15 $host = "127.0.0.1";
16 $port = 5432;
17
18 $dbh = DBI->connect("dbi:Pg:dbname=$database;host=$host;port=$port",
19 $username,
20 $password,
21 {AutoCommit => 0, RaiseError => 1,
PrintError => 0}
22 );
23 unless ( defined $dbh ) {
24 die("Error connecting to '${database}' on '${host}'
:\n$DBI::errstr\n ");
25 } # UNLESS
26
27 $sql = "delete from laptop where name = 'Lenovo ThinkPad P71'";
28 print "SQL for delete operation is\n$sql\n";
29 $num_rows = $dbh->do($sql);
30 unless ( defined $num_rows ) {
31 print "error executing : ${sql}\n",$DBI::errstr,"\n";
32 } # UNLESS
33 else {
34 print "${num_rows} rows were successfully deleted\n";
35 } # ELSE
36
37 $dbh->disconnect; # disconnect from databse
38
39 exit 0;

Any idea as to why the record is still in the table ?

Thanks.
--

Barrry Kimelman
Winnipeg, Manitoba, Canada

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2020-02-17 16:23:56 Re: Can't delete postgresql table record using Perl
Previous Message Laurenz Albe 2020-02-10 20:28:10 Re: PITR for one database in cluster