File: proctest3.pl

package info (click to toggle)
libdbd-odbc-perl 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,012 kB
  • ctags: 398
  • sloc: perl: 6,314; ansic: 4,875; makefile: 29; sql: 8
file content (57 lines) | stat: -rwxr-xr-x 1,058 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!perl -w
# $Id: proctest3.pl 11680 2008-08-28 08:23:27Z mjevans $


use DBI;
use strict;

my $dbh = DBI->connect();
$dbh->{LongReadLen} = 8000;

eval {
   local $dbh->{PrintError} = 0;
   $dbh->do("drop procedure PERL_DBD_TESTPRC");
};

$dbh->do("CREATE PROCEDURE  PERL_DBD_TESTPRC
\@parameter1 int = 0
AS
	if (\@parameter1 >= 0)
	    select * from systypes
        RETURN(\@parameter1)
	");

sub test()
{
   my $sth = $dbh->prepare("{call PERL_DBD_TESTPRC(?)}");
	
   $sth->bind_param(1, -1, { TYPE => 4 });
   $sth->execute();

   print '$sth->{NUM_OF_FIELDS}: ', $sth->{NUM_OF_FIELDS}, " expected: 0\n";
   if($sth->{NUM_OF_FIELDS}) {
      my @row;
      while (@row = $sth->fetchrow_array()) {
	 print join(', ', @row), "\n";
      }
   }
}

	

##########################################
### Test
##########################################

unlink("dbitrace.log") if (-e "dbitrace.log");
$dbh->trace(9, "dbitrace.log");

test();

##########################################
### Cleanup...
##########################################


$dbh->disconnect;