| timbo@cvs.perl.org 2005-06-03, 8:27 pm |
| Author: timbo
Date: Fri Oct 22 01:35:18 2004
New Revision: 514
Modified:
dbd-oracle/trunk/Oracle.pm
dbd-oracle/trunk/t/25plsql.t
Log:
Disable nvarchar2 arg passing to functions test if client or server <9.0
Add another code sample for INSERT ... RETURNING ...
Modified: dbd-oracle/trunk/Oracle.pm
====================
====================
====================
==================
--- dbd-oracle/trunk/Oracle.pm (original)
+++ dbd-oracle/trunk/Oracle.pm Fri Oct 22 01:35:18 2004
@@ -2464,6 +2464,13 @@
$sth->execute;
print "The id of the new record is $new_id\n";
+If you have many columns to bind you can use code like this:
+
+ @params = (... column values for record to be inserted ...);
+ $sth->bind_param($_, $params[$_-1]) for (1..@params);
+ $sth-> bind_param_inout(@pa
rams+1, \my $new_id, 99);
+ $sth->execute;
+
=head1 Returning A Recordset
DBD::Oracle does not currently support binding a PL/SQL table (aka array)
Modified: dbd-oracle/trunk/t/25plsql.t
====================
====================
====================
==================
--- dbd-oracle/trunk/t/25plsql.t (original)
+++ dbd-oracle/trunk/t/25plsql.t Fri Oct 22 01:35:18 2004
@@ -302,6 +302,9 @@
print "test nvarchar2 arg passing to functions\n";
# http://www.nntp.perl.org/group/perl.dbi.users/24217
+ my $ora_server_version = $dbh->func("ora_server_version");
+ skip "Client/server version < 9.0", 15
+ if DBD::Oracle::ORA_OCI
() < 9.0 || $ora_server_version < 9.8;
my $func_name = "dbd_oracle_nvctest".($ENV& #123;DBD_ORACLE_SEQ}
||'');
$dbh->do(qq{
CREATE OR REPLACE FUNCTION $func_name(arg nvarchar2, arg2 nvarchar2)
@@ -313,23 +316,22 @@
return 1;
end if;
END;
- }) or skip("Can't create a function ($DBI::errstr)", 16);
+ }) or skip("Can't create a function ($DBI::errstr)", 15);
my $sth = $dbh->prepare(qq{SELECT $func_name(?, ?) FROM DUAL}, {
# Oracle 8 describe fails with ORA-06553: PLS-561: charset mismatch
ora_check_sql => 0,
});
- ok(0, $sth, "Can't prepare select from function ($DBI::errstr)");
- skip("Can't select from function ($DBI::errstr)", 15) unless $sth;
- ok(0, $sth->bind_columns(\my $returnVal));
+ ok(0, $sth, sprintf("Can't prepare select from function (%s)" ,$DBI::errstr||''));
+ skip("Can't select from function ($DBI::errstr)", 14) unless $sth;
for (1..2) {
ok(0, $sth->bind_param(1, "foo", { ora_csform => SQLCS_NCHAR }));
ok(0, $sth->bind_param(2, "bar", { ora_csform => SQLCS_NCHAR }));
ok(0, $sth->execute());
- ok(0, $sth->fetch);
+ ok(0, my($returnVal) = $sth->fetchrow_array);
ok(0, $returnVal eq "1");
}
ok(0, $sth->execute("baz",undef));
- ok(0, $sth->fetch);
+ ok(0, my($returnVal) = $sth->fetchrow_array);
ok(0, $returnVal eq "-1");
ok(0, $dbh->do(qq{drop function $func_name}));
}
@@ -348,7 +350,7 @@
ok(0, !$dbh->ping);
exit 0;
-BEGIN { $tests = 83 }
+BEGIN { $tests = 82 }
# end.
__END__
|