File: testproc.pl

package info (click to toggle)
libdbd-odbc-perl 1.37-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,272 kB
  • sloc: perl: 7,932; ansic: 5,991; makefile: 33; sql: 8
file content (32 lines) | stat: -rwxr-xr-x 922 bytes parent folder | download | duplicates (2)
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 11680 2008-08-28 08:23:27Z mjevans $

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;