File: testproc.pl

package info (click to toggle)
libdbd-odbc-perl 1.13-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 544 kB
  • ctags: 287
  • sloc: perl: 3,395; ansic: 3,236; makefile: 55
file content (32 lines) | stat: -rwxr-xr-x 916 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!perl -w
# $Id: testproc.pl 93 2004-02-19 19:28:16Z jurl $

use strict;
use DBI;

# Connect to the database, and create a table and stored procedure:
my $dbh=DBI->connect("dbi:ODBC:PERL_TEST_SQLSERVER", $ENV{DBI_USER}, $ENV{DBI_PASS}, { RaiseError => 1 }) or die "Can't connect";
eval {$dbh->do("DROP TABLE table1");};
eval {$dbh->do("CREATE TABLE table1 (i INTEGER)");};
eval {$dbh->do("DROP PROCEDURE proc1");};
my $proc1 =
    "CREATE PROCEDURE proc1 AS ".
    "BEGIN".
    "    INSERT INTO table1 VALUES (100);".     # breaks fetchrow_array 
    "    SELECT 9;".
    "END";
eval {$dbh->do ($proc1);};

# Execute it:
if (-e "dbitrace.log") {
   unlink("dbitrace.log");
}
$dbh->trace(9, "dbitrace.log");
my $sth = $dbh->prepare ("exec proc1");
   $sth->execute ();
do {
   while (my $result = $sth->fetchrow_array()) {
      print "result = $result\n";
   }
} while ($sth->{odbc_more_results});
$dbh->disconnect;