| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | # Copyright (c) 1998 Göran Thyni | ||
| 4 | # $Id: test1.pl,v 1.2 1998/08/11 15:50:38 goran Exp $ | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use PgSQL; | ||
| 8 | |||
| 9 | my $res; | ||
| 10 | my $dbh = new PgSQL(DBName => 'goran', Host => 'localhost'); | ||
| 11 | $res = $dbh->do("DROP TABLE y"); | ||
| 12 | $res = $dbh->do("CREATE TABLE y (i integer, s varchar(21))"); | ||
| 13 | print "## CREATE: $res\n"; | ||
| 14 | $res = $dbh->begin; | ||
| 15 | print "## BEGIN: $res\n"; | ||
| 16 | $res = $dbh->do("INSERT INTO y VALUES(1, 'ABCD')"); | ||
| 17 | print "## INSERT 1: $res\n"; | ||
| 18 | $res = $dbh->do("INSERT INTO y VALUES(2, 'B')"); | ||
| 19 | print "## INSERT 2: $res\n"; | ||
| 20 | $res = $dbh->do("INSERT INTO y VALUES(88, NULL)"); | ||
| 21 | print "## INSERT 3: $res\n"; | ||
| 22 | $res = $dbh->commit; | ||
| 23 | print "## COMMIT: $res\n"; | ||
| 24 | my $sth = $dbh->do("SELECT * FROM y"); | ||
| 25 | print "## SELECT: $sth\n"; | ||
| 26 | while ($res = $sth->fetch) | ||
| 27 | { | ||
| 28 | print "## FETCH: @$res\n"; | ||
| 29 | } | ||
| 30 | $sth->finish; | ||
| 31 | $res = $dbh->do("DROP TABLE y"); | ||
| 32 | print "## DROP: $res\n"; | ||
| 33 | $res = $dbh->close; | ||
| 34 | print "## CLOSE: $res\n"; | ||
| 35 | |||
| 36 | 1; |