Program Listings

Listing 3-1 contains the complete and uninterrupted code from this chapter's program example.

Listing 3-1: Table Add

start example
01: #!/usr/bin/perl -w   02: # add_table.pl 03: # Chapter 3 04: # Listing 1 05: use strict; 06: use DBI; 07: my $dbh = DBI->connect("DBI:mysql:widgets",       "bookuser","testpass")  08:     or die("Cannot connect: $DBI::errstr\n"); 09: my $sql = qq{CREATE TABLE products ( 10:               Pid   INT NOT NULL, 11:               Item  VARCHAR(255), 12:               Descr VARCHAR(255), 13:               Price REAL, 14:               Vid   INT NOT NULL)}; 15: my $return = $dbh->do($sql); 16: if($return) { 17:     print "Table addition successful!\n"; 18: } 19: else { 20:     print "\n\nERROR! $DBI::errstr\n"; 21: }
end example



Perl Database Programming
Perl Database Programming
ISBN: 0764549561
EAN: 2147483647
Year: 2001
Pages: 175

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net