DELETE IN PERL WITH MYSQL --- CODING
delete:
use DBI;
use DBD::mysql;
$platform = "mysql";
$database = "testdb007";
$host = "localhost";
$port = "3306";
$tablename = "Writers";
$user = "2910007";
$pw = "cse007";
#DATA SOURCE NAME
$dsn =
"dbi:mysql:$database:localhost:3306";
# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user,
$pw);
print "\n sucessfully
connected\n";
print"\nEnter ID u want to
delete";
$id=<>;
$query = "DELETE from Writers
WHERE id='$id'";
# PREPARE THE QUERY
$query1="select * from Writers
ORDER by Id";
$query_handle =
$connect->prepare($query);
$query_handle1 =
$connect->prepare($query1);
# EXECUTE THE QUERY
$query_handle->execute();
$query_handle1->execute();
# BIND TABLE COLUMNS TO VARIABLES
$query_handle1->bind_columns(undef,
\$Id,\$Name);
# LOOP THROUGH RESULTS
print "ID \t NAME\n " ;
while($query_handle1->fetch())
{
print " $Id \t $Name \n>";
}
No comments:
Post a Comment