DBI ODBC : ODBC « Database « Perl






DBI ODBC

   

#!/usr/bin/perl

use warnings;
use strict;
use DBI;
use DBD::ODBC;

my $dbh = DBI->connect( "dbi:ODBC:employeeDB", "", "", { RaiseError => 1 } );
 
my $IDdel = "1";

my $query = "DELETE FROM employee WHERE EmployeeID = '$IDdel'";
print( "$query \n\n" );
$dbh->do( $query ); 

my $sth = $dbh->prepare( q{ select * FROM employee } );

$sth->execute();

my @array;

while ( @array = $sth->fetchrow_array() ) {
   write( STDOUT );
}

# Clean up
warn( $DBI::errstr ) if $DBI::err;
$dbh->disconnect();
$sth->finish();

format STDOUT =
@<<<<<<@<<<<<<<<<@<<<<<<<<<<@<<<<<@<<<<<<<<<<<
$array[ 0 ], $array[ 1 ], $array[ 2 ], $array[ 3 ], $array[ 4 ]

.

   
    
    
  








Related examples in the same category

1.Delete a record from the database
2.Delete statement and DBI ODBC connection
3.Insert statement with DBI connection
4.Program to insert a new record into the database
5.Query a database and display the contents in a table