DBD-DB2
view release on metacpan or search on metacpan
asynchronous access is working properly. Other options appear to
be working.....so I'm assuming that asynchronous access is.
=head2 Changes in DBD::DB2, Aug 16, 1996
Fixed the following:
1. Prototype warnings from xsub.
2. Invalidated cursor messages when exiting after finishing the
cursors.
=head2 Changes in DBD::DB2, June 21, 1996
Fixed the following:
1. Fixed a package naming problem with the Constants package.
Screwed up the package name change which caused the tests
to fail on a clean build system. Unfortunately, on my test
systems I was picking up an old copy....
$pict_sth->bind_param(2,$row[1]);
$pict_sth->execute();
# do a fetch to get the blob
@row = $pict_sth->fetchrow;
print OUTPUT $row[0];
@row = "";
close(OUTPUT);
# close the blob cursor
$pict_sth->finish();
}
# redundantly close the blob cursor -- should be harmless
$pict_sth->finish();
# close selection criteria cursor
$sth->finish();
$dbh->disconnect();
=head1 Connection Attributes
The following DB2 connection attributes are supported. (For
information on setting and querying connection attributes see the
DBI guide.) Supported values are also shown: boolean refers to Perl
true or false, tokens listed in uppercase are DB2 constants (be sure
to include 'use DBD::DB2::Constants').
The following DB2 statement attributes are supported. (For
information on setting and querying statement attributes see the
DBI guide.) Supported values are also shown: boolean refers to Perl
true or false.
db2_concurrency One of:
SQL_CONCUR_READ_ONLY
SQL_CONCUR_LOCK
SQL_CONCUR_VALUES
db2_cursor_hold Boolean
db2_deferred_prepare Boolean
db2_earlyclose Boolean
db2_max_length Integer
db2_call_return Integer
db2_max_rows Integer
db2_more_results Boolean (read only, see the section
below: Multiple Result Sets)
db2_noscan Boolean
db2_optimize_for_nrows Integer
db2_prefetch Boolean
}
/* pre-disconnect checks and tidy-ups */
if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) {
hv_clear((HV*)SvRV(dbh));
}
if (DBIc_CACHED_KIDS(imp_dbh)) {
SvREFCNT_dec(DBIc_CACHED_KIDS(imp_dbh)); /* cast them to the winds */
DBIc_CACHED_KIDS(imp_dbh) = Nullhv;
}
/* Check for disconnect() being called whilst refs to cursors */
/* still exists. This possibly needs some more thought. */
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !PL_dirty) {
STRLEN lna;
char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
warn("%s->disconnect invalidates %d active statement handle%s %s",
SvPV(dbh,lna), (int)DBIc_ACTIVE_KIDS(imp_dbh), plural,
"(either destroy statement handles or call finish on them before disconnecting)");
}
ST(0) = dbd_db_disconnect(dbh, imp_dbh) ? &PL_sv_yes : &PL_sv_no;
/* The connection will not be deactivated if there is an invalid */
asynchronous access is working properly. Other options appear to
be working.....so I'm assuming that asynchronous access is.
Aug 16, 1996
Fixed the following:
1. Prototype warnings from xsub.
2. Invalidated cursor messages when exiting after finishing the
cursors.
June 21, 1996
Fixed the following:
1. Fixed a package naming problem with the Constants package.
Screwed up the package name change which caused the tests
to fail on a clean build system. Unfortunately, on my test
systems I was picking up an old copy....
}
DBIc_ACTIVE_off(imp_sth);
return TRUE;
}
int dbd_st_finish( SV *sth,
imp_sth_t *imp_sth ) {
D_imp_dbh_from_sth;
SQLRETURN ret;
/* Cancel further fetches from this cursor. We don't */
/* close the cursor (SQLFreeHandle) 'til DESTROY (dbd_st_destroy).*/
/* The application may call execute(...) again on the same */
/* statement handle. */
if (DBIc_ACTIVE(imp_sth) ) {
ret = SQLFreeStmt(imp_sth->phstmt,SQL_CLOSE);
CHECK_ERROR(sth, SQL_HANDLE_STMT, imp_sth->phstmt, ret, "SQLFreeStmt Failed");
EOI(ret);
}
DBIc_ACTIVE_off(imp_sth);
return TRUE;
else if( strEQ( key, "db2_row_number" ) )
return SQL_ATTR_ROW_NUMBER;
return SQL_ERROR;
#endif
case 15:
if( strEQ( key, "db2_call_return" ) )
return SQL_ATTR_CALL_RETURN;
else if( strEQ( key, "db2_concurrency" ) )
return SQL_ATTR_CONCURRENCY;
else if( strEQ( key, "db2_cursor_hold" ) )
return SQL_ATTR_CURSOR_HOLD;
return SQL_ERROR;
#ifndef AS400
case 17:
if( strEQ( key, "db2_query_timeout" ) )
return SQL_ATTR_QUERY_TIMEOUT;
else if( strEQ( key, "db2_retrieve_data" ) )
return SQL_ATTR_RETRIEVE_DATA;
else if( strEQ( key, "db2_txn_isolation" ) )
av_store(av, i, newSVpv((char *)imp_sth->fbh[i].cbuf,0));
}
else if( kl == 8 && strEQ( key, "NULLABLE" ) ) {
av = newAV();
retsv = sv_2mortal( newRV_inc( sv_2mortal((SV*)av) ) );
while(--i >= 0)
av_store(av, i,
(imp_sth->fbh[i].nullok == 1) ? &PL_sv_yes : &PL_sv_no);
}
else if( kl == 10 && strEQ( key, "CursorName" ) ) {
char cursor_name[256];
SQLSMALLINT cursor_name_len;
ret = SQLGetCursorName(imp_sth->phstmt, (SQLCHAR *)cursor_name,
sizeof(cursor_name), &cursor_name_len);
CHECK_ERROR(sth, SQL_HANDLE_STMT, imp_sth->phstmt, ret, "SQLNGetCursorName Failed");
if (ret < 0)
return Nullsv;
else
retsv = sv_2mortal( newSVpv(cursor_name, cursor_name_len) );
}
else if( kl == 4 && strEQ( key, "TYPE" ) ) {
av = newAV();
retsv = sv_2mortal( newRV_inc( sv_2mortal( (SV*)av ) ) );
while(--i >= 0)
av_store(av, i, newSViv(imp_sth->fbh[i].dbtype));
}
else if( kl == 9 && strEQ( key, "PRECISION" ) ) {
av = newAV();
retsv = sv_2mortal( newRV_inc( sv_2mortal( (SV*)av ) ) );
exit 0;
sub run_test{
my($dbh) = @_;
print "Connected as $dbh\n\n";
$dbh->commit;
my($cursor_a) = $dbh->prepare("select SYSDATE from DUAL");
die "Prepare failed ($DBI::err): $DBI::errstr\n" unless $cursor_a;
print "Prepared as $cursor_a\n";
# $cursor_a->debug(2);
my($cursor_b) = $dbh->prepare("select SYSDATE+1 from DUAL");
die "Prepare failed ($DBI::err): $DBI::errstr\n" unless $cursor_b;
print "Prepared as $cursor_b\n";
# $cursor_b->debug(2);
# Test object attributes
print "Number of fields: $cursor_a->{'NUM_OF_FIELDS'}\n";
print "Number of fields: $cursor_a->{'NUM_OF_FIELDS'}\n"; # now cached
die "Test not fully implemented yet";
print "Data type of first field: $cursor_a->{'DATA_TYPE'}->[0]\n";
print "Driver name: $cursor_a->{'Database'}->{'Driver'}->{'Name'}\n";
$cursor_a->execute('/usr');
$cursor_b->execute('/usr/spool');
print "Fetching data from both cursors:\n";
my(@row_a, @row_b);
while((@row_a = $cursor_a->fetchrow)
&& (@row_b = $cursor_b->fetchrow)){
print "@row_a, @row_b\n";
}
print "\nAutomatic method parameter usage check:\n";
eval { $dbh->commit('dummy') };
warn "$@\n";
print "Preparing new \$cursor_a to replace current \$cursor_a:\n";
print "(we enable debugging on current to watch it's destruction)\n";
$cursor_a->debug(2);
$cursor_a = $dbh->prepare("select mtime,name from ?");
$cursor_a->execute('../..');
print "Fetching one row from new \$cursor_a:\n";
print join(' ',$cursor_a->fetchrow),"\n";
$cursor_a->finish;
print "test done (scoped objects will be destroyed now)\n";
}
# end.
tests/perld043_stmtTryFetchForNonSelect.pl view on Meta::CPAN
$stmt = "INSERT INTO staff (id) VALUES (999)";
$sth = $dbh->prepare($stmt);
check_error("PREPARE");
$sth->execute();
check_error("EXECUTE");
@row_ary = $sth->fetchrow();
check_error("FETCHROW",
"[IBM][CLI Driver] CLI0115E Invalid cursor state. SQLSTATE=24000",
"DBI::errstr");
check_value("FETCHROW", "row_ary", undef);
$sth->finish();
check_error("FINISH");
$dbh->rollback();
check_error("ROLLBACK");
fvt_end_testcase($testcase, $success);
tests/perld046_stmtCheckActiveAttrForStmtHandleOnError.pl view on Meta::CPAN
$sth = $dbh->prepare($stmt);
check_error("PREPARE");
$sth->execute();
check_error("EXECUTE");
check_value("EXECUTE", "sth->{Active}", 1);
@row_ary = $sth->fetchrow();
check_error("FETCHROW",
"[IBM][CLI Driver] CLI0115E Invalid cursor state. SQLSTATE=24000",
"DBI::errstr");
check_value("FETCHROW", "row_ary", undef);
check_value("FETCHROW", "sth->{Active}", undef);
$sth->finish();
check_error("FINISH");
check_value("FINISH", "sth->{Active}", undef);
$dbh->rollback();
check_error("ROLLBACK");
tests/perld093_testStoredPrcMultResultset.pl view on Meta::CPAN
($testcase = $0) =~ s@.*/@@;
($tcname,$extension) = split(/\./, $testcase);
$success = "y";
fvt_begin_testcase($tcname);
$dbh = DBI->connect("dbi:DB2:$DATABASE", "$USERID", "$PASSWORD", {PrintError => 0});
check_error("CONNECT");
$sth = $dbh->do( 'DROP PROCEDURE SP_TestResultSet' );
$statement = "create procedure SP_TestResultSet() language sql begin declare c1 cursor with return to client for values( 'first record' ); declare c2 cursor with return to client for values( 'second', 'record' ); open c1; open c2; return...
$sth = $dbh->prepare( $statement );
check_error( 'PREPARE' );
$sth->execute();
check_error("EXECUTE CREATE procedure");
$sth = $dbh->prepare( '{ CALL SP_TestResultSet( ) }' );
check_error( 'PREPARE' );
$rv = $sth->execute();
( run in 0.467 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )