view release on metacpan or search on metacpan
($active && $_ eq $focused) ? $$widgets{$_}->draw($fwh, 1) :
$$widgets{$_}->draw($fwh);
}
}
sub _cursor {
# Forms don't have cursors, per-se
}
=head2 setField/getField
$form->setField(BORDER => 1);
view all matches for this distribution
view release on metacpan or search on metacpan
# The following are provided for use with descendent
# classes, and are expected to be overridden.
$obj->_conf(%conf);
$obj->input_key($ch);
$obj->_content($mwh);
$obj->_cursor
=head1 REQUIREMENTS
=over
The draw method can be overridden in each descendant class. It
is reponsible for the rendering of the widget, and only that. The first
argument is mandatory, being a valid window handle with which to create
the widget's derived window. The second is optional, but if set to
true, will tell the widget to draw itself in an 'active' state. For
instance, the TextField widget will also render a cursor, while a
ButtonSet widget will render the selected button in standout mode.
The rendering sequence defined in this class is as follows:
# Get the canvas geometry and create a window handle to it
$dwh->delwin;
return 0;
}
$self->_content($cwh);
$self->_cursor($cwh) if $active;
=cut
sub draw {
my $self = shift;
$dwh->delwin;
return 0;
}
$self->_content($cwh);
$self->_cursor($cwh) if $active;
# Flush the changes to the screen and release the window handles
$cwh->refresh;
$cwh->delwin;
$dwh->refresh;
my $conf = $self->{CONF};
# Override this method to render widget content
}
=head2 _cursor
$obj->_cursor
This method should be overriden in all descendent classes that display a
cursor in the content area. The B<draw> method, as defined in this class,
calls this method after the content is rendered, and passes it a window handle
the exact size of the content area.
=cut
sub _cursor {
my $self = shift;
my $dwh = shift;
my $conf = $self->{CONF};
# Override this method to render widget cursor
}
1;
=head1 HISTORY
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DB/Berkeley.pm view on Meta::CPAN
You can reset the iterator using:
$iter->iterator_reset();
Note that calling C<each()> or other iteration methods directly on the C<$db> object
will use an internal cursor that is separate from the object returned by C<iterator()>.
This is especially useful for nested iteration or concurrent traversal contexts.
=head2 sync
view all matches for this distribution
view release on metacpan or search on metacpan
Add support for the Backup command, including support for DPF backups
(with included logs) in DB2 V9.5.
=head1 Changes in the 2.9 release
=head2 Fix core dump in load from cursor
A second bug in the db2Load command, caused a load from cursor (source
type "Statement") to perform an invalid free, sometimes leading to a
core dump. Now fixed. Have run valgrind on import/export/load to
verify no additional mistakes are present.
=head1 Changes in the 2.8 release
=head2 Fix core dump in load from cursor
A bug in the db2Load command, introduced in the 2.7 release, caused a
load from cursor (source type "Statement") to dump core. Now fixed.
=head2 BugFix in Load / Import
A bug in the Load and Import methods prevented load/import operations
against mixed-case schema and table names (which have to be
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/ADO.pm view on Meta::CPAN
my ( $outer, $sth ) = DBI::_new_sth( $dbh, { Statement => $statement } );
$sth->{ado_cachesize} = $dbh->{ado_cachesize};
$sth->{ado_comm} = $comm;
$sth->{ado_conn} = $conn;
$sth->{ado_cursortype} = $dbh->{ado_cursortype} || $attr->{CursorType};
$sth->{ado_fields} = undef;
$sth->{ado_max_errors} = $dbh->{ado_max_errors};
$sth->{ado_refresh} = 1;
$sth->{ado_rownum} = -1;
$sth->{ado_rows} = -1;
lib/DBD/ADO.pm view on Meta::CPAN
_assign_param( $sth, $n, $$vref, $attr, $i );
}
}
}
# At this point a Command is ready to Execute. To allow for different
# type of cursors, we need to create a Recordset object.
# However, a Recordset Open does not return affected rows. So we need to
# determine if a Recordset Open is needed, or a Command Execute.
my $UseRecordSet = !defined $sth->{ado_usecmd} &&
( defined $sth->{ado_cursortype}
|| defined $sth->{ado_users}
);
my $UseResponseStream = $sth->{ado_executeoption} &&
( $sth->{ado_executeoption} == $Enums->{ExecuteOptionEnum}{adExecuteStream} );
lib/DBD/ADO.pm view on Meta::CPAN
}
elsif ( $UseRecordSet ) {
$rs = Win32::OLE->new('ADODB.RecordSet');
return if DBD::ADO::Failed( $sth,"Can't create 'ADODB.RecordSet'");
my $CursorType = $sth->{ado_cursortype} || 'adOpenForwardOnly';
$sth->trace_msg(" -- Open Recordset using CursorType '$CursorType'\n", 5 );
$rs->Open( $comm, undef, $Enums->{CursorTypeEnum}{$CursorType} );
return if DBD::ADO::Failed( $sth,"Can't Open Recordset for '$sql'");
_retrieve_out_params( $sth );
$sth->trace_msg(" -- CursorType: $rs->{CursorType}\n", 5 );
lib/DBD/ADO.pm view on Meta::CPAN
$sth = $dbh->prepare( $statement ) or die $dbh->errstr;
$sth = $dbh->prepare( $statement, \%attr ) or die $dbh->errstr;
DBD::ADO's prepare() supports setting the CursorType, e.g.:
$sth = $dbh->prepare( $sql, { ado_cursortype => 'adOpenForwardOnly' } ) ...
# the CursorType attribute is deprecated:
$sth = $dbh->prepare( $sql, { CursorType => 'adOpenForwardOnly' } ) ...
Possible cursortypes are:
adOpenForwardOnly (default)
adOpenKeyset
adOpenDynamic
adOpenStatic
It may be necessary to prepare the statement using cursortype 'adOpenStatic'
when using a statement handle within a statement handle:
while( my $table = $sth1->fetchrow_hashref ) {
...
my $col = $sth2->fetchrow_hashref;
lib/DBD/ADO.pm view on Meta::CPAN
As a workaround, the C<ado_size> attribute for C<bind_param> was
introduced in version 2.95:
$sth->bind_param( $p_num, $bind_value, { ado_size => $size } );
=item MSDAORA may have problems with client-side cursors
MSDAORA may throw an error, return an empty result set or loop forever
when C<CursorLocation> is set to C<adUseClient>.
This setting is used in catalog methods for sorting and filtering.
view all matches for this distribution
view release on metacpan or search on metacpan
eg/blobs.pl view on Meta::CPAN
my $dbh;
my $ins;
my $nrows;
my $upd;
my $cursor;
my $sth;
my $blob1;
my $blob2;
my $bloblen = 1000000;
my $i;
eg/blobs.pl view on Meta::CPAN
#
# Check the inserts values by fetching the values back
#
printf( "Checking inserts\n" );
$cursor = $dbh->prepare( "select a, b from blobs" );
$cursor->execute();
$nrows = 0;
while( ($a,$b) = $cursor->fetchrow() ) {
$nrows++;
if( $a ne $blob1 && $a ne $blob2 ) {
die( "******ERROR: Fetched value for column a is incorrect: %s\n", $a );
}
if( $b ne $blob1 && $b ne $blob2 && $b ne "jcs" ) {
die( "******ERROR: Fetched value for column b is incorrect: %s\n", $b );
}
}
if( defined( $cursor->err ) && defined( $cursor->errstr ) ) {
die( "******ERROR: err %d, errstr %s\n", $cursor->err, $cursor->errstr );
} elsif( $nrows != 3 ) {
die( "******ERROR: Incorrect number of rows fetched: %d\n", $nrows );
} else {
printf( "Inserts OK\n" );
}
$cursor->finish();
#
# Do some updates
#
printf( "Doing updates\n" );
eg/blobs.pl view on Meta::CPAN
#
# Check updates
#
printf( "Checking updates\n" );
$cursor = $dbh->prepare( "select a, b from blobs" );
$cursor->execute();
$nrows = 0;
while( ($a,$b) = $cursor->fetchrow() ) {
$nrows++;
if( $a eq $blob1 && $b ne $blob1 ) {
die( "******ERROR: Update didn't work correctly\n" );
}
if( $a ne $blob1 && $a ne $blob2 ) {
eg/blobs.pl view on Meta::CPAN
}
if( $b ne $blob1 && $b ne $blob2 && $b ne "jcs" ) {
die( "******ERROR: Fetched value for column b is incorrect\n" );
}
}
if( defined( $cursor->err ) && defined( $cursor->errstr ) ) {
die( "******ERROR: err %d, errstr %s\n", $cursor->err, $cursor->errstr );
} elsif( $nrows != 3 ) {
die( "******ERROR: Incorrect number of rows fetched: %d\n", $nrows );
} else {
printf( "Updates OK\n" );
}
$cursor->finish();
$dbh->commit();
$dbh->do( 'drop table blobs' );
$dbh->disconnect();
undef $dbh;
view all matches for this distribution
view release on metacpan or search on metacpan
{
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
dTHR;
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
{
dTHR;
D_imp_dbh_from_sth;
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
imp_sth->done_desc = 0;
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
dTHR;
D_imp_dbh_from_sth;
RETCODE rc;
int ret = 0;
/* Cancel further fetches from this cursor. */
/* We don't close the cursor till DESTROY (dbd_st_destroy). */
/* The application may re execute(...) it. */
/* XXX semantics of finish (eg oracle vs odbc) need lots more thought */
/* re-read latest DBI specs and ODBC manuals */
if (DBIc_ACTIVE(imp_sth) && imp_dbh->hdbc != SQL_NULL_HDBC) {
int i;
SV *retsv = NULL;
T_st_params *par;
int n_fields;
imp_fbh_t *fbh;
char cursor_name[256];
SWORD cursor_name_len;
RETCODE rc;
for (par = S_st_fetch_params; par->len > 0; par++)
if (par->len == kl && strEQ(key, par->str))
break;
while(--i >= 0)
av_store(av, i, newSViv(imp_sth->fbh[i].ColLength));
break;
case 9: /* CursorName */
rc = SQLGetCursorName(imp_sth->hstmt,
cursor_name, sizeof(cursor_name), &cursor_name_len);
if (!SQL_ok(rc)) {
dbd_error(sth, rc, "st_FETCH/SQLGetCursorName");
return Nullsv;
}
retsv = newSVpv(cursor_name, cursor_name_len);
break;
case 10:
retsv = newSViv(DBIc_LongReadLen(imp_sth));
break;
default:
dTHR;
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
imp_sth->done_desc = 0;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/SQL/Amazon/Spool.pm view on Meta::CPAN
$obj->{errstr} = 'Resultset timeout has expired.',
$obj->{_keys} = undef,
return undef
if (time() > $obj->{_timeout});
my $cursor = defined($obj->{_cursor}) ? $obj->{_cursor} : -1;
my $keys = $obj->{_keys};
return undef
if ($cursor >= $#$keys);
my $row;
$cursor++;
while ($cursor <= $#$keys) {
$row = $obj->{_table}->fetch($keys->[$cursor]);
$obj->{_currkey} = $keys->[$cursor];
last if $row;
$cursor++;
}
$obj->{_cursor} = $cursor;
$obj->{errstr} = $row,
$obj->{row} = undef,
$obj->{_currkey} = undef,
return undef
unless ref $row;
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Mock.pm view on Meta::CPAN
mock_call('database_property', 'DatabasePropertyResponse', '{"props":[{"key":{"name":"GET_DATABASE_MAJOR_VERSION"},"value":{"type":"INTEGER","numberValue":4}},{"key":{"name":"GET_DEFAULT_TRANSACTION_ISOLATION"},"value":{"type":"INTEGER","numberVa...
}
sub mock_create_table {
mock_prepare_seq([
'{"statement":{"connectionId":"35p0fchr4g6az0wwy8l541zl0ys2yh","id":79,"signature":{"sql":"DROP TABLE IF EXISTS TEST","cursorFactory":{"style":"LIST"}}},"metadata":{"serverAddress":"c497a18abde6:8765"}}',
'{"statement":{"connectionId":"35p0fchr4g6az0wwy8l541zl0ys2yh","id":81,"signature":{"sql":"CREATE TABLE TEST(ID BIGINT PRIMARY KEY, TEXT VARCHAR)","cursorFactory":{"style":"LIST"}}},"metadata":{"serverAddress":"c497a18abde6:8765"}}'
]);
mock_execute_seq([
'{"results":[{"connectionId":"35p0fchr4g6az0wwy8l541zl0ys2yh","statementId":80,"metadata":{"serverAddress":"c497a18abde6:8765"}}],"metadata":{"serverAddress":"c497a18abde6:8765"}}',
'{"results":[{"connectionId":"35p0fchr4g6az0wwy8l541zl0ys2yh","statementId":82,"metadata":{"serverAddress":"c497a18abde6:8765"}}],"metadata":{"serverAddress":"c497a18abde6:8765"}}'
]);
view all matches for this distribution
view release on metacpan or search on metacpan
tests/perld043_stmtTryFetchForNonSelect.pl view on Meta::CPAN
$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");
view all matches for this distribution
view release on metacpan or search on metacpan
Example:
print "First column may return NULL\n" if $sth->{NULLABLE}->[0];
=item CursorName (string) read-only
Returns the name of the cursor associated with the statement handle if
available.
=item Statement (string) read-only
Returns the statement string passed to the the prepare entry elsewhere in
view all matches for this distribution
view release on metacpan or search on metacpan
DTF_TAT_AUTOCOMMIT
DTF_TAT_RESULTTYPE
These two attributes are very important, as they control the auto-commit behavior of the
database and the kind (sequential, random) of the result set's cursor. The following table
shows the available information regarding these attributes:
--------------------+------------+---------------+---------------+-------------------
Attribute | Attr. Type | current Value | default Value | Range
--------------------+------------+---------------+---------------+-------------------
=item B<$errcode = DtfResMoveToFirstRow ($hres);>
# move to the first row of a result table with a sequential cursor
# (the result table must be of type DTF_RT_SEQUENTIAL)
Arguments:
input: $hres a valid result handle
=item B<$errcode = DtfMoveToNextRow ($hres);>
# move to the next row of a result table with a sequential cursor
# (the result table must be of type DTF_RT_SEQUENTIAL)
Arguments:
input: $hres a valid result handle
=item B<$errcode = DtfResMoveToRow ($hres, $rowIndex);>
# moves a result set's cursor to an absolute position
# (the result table must be of type DTF_RT_RANDOM)
Arguments:
input: $hres a valid result handle
$rowIndex is the 0-based index of the row to move the cursor to
=item B<$errcode = DtfResQueryFieldInfo ($hres, $colIndex, $fieldSize, $isNull);>
view all matches for this distribution
view release on metacpan or search on metacpan
# --------------------------------------------------------------------------
# Cursor functions: prepare/execute/fetch/nrows, etc.
# --------------------------------------------------------------------------
print "Testing: \$cursor = \$dbh->prepare( 'SELECT FROM $test_tabname WHERE ¼±ÊÌ»Ò = 1' ): ";
( $cursor = $dbh->prepare( "SELECT * FROM $test_tabname WHERE ¼±ÊÌ»Ò = 1" ) )
and print( "prepare select ok\n" )
or print( "prepare select not ok: $DBI::errstr\n" );
print "Testing: \$cursor->execute: ";
( $cursor->execute )
and print( "execute select ok\n" )
or die "execute select not ok: $DBI::errstr\n";
# expect the following select to fail, as id=1 has been deleted already
print "Testing: \$cursor->fetchrow: ";
if ( @row = $cursor->fetchrow )
{
print( "not ok ($DBI::err): $DBI::errstr, record: @row\n" );
}
else
{
print( "ok\n" ); # expect it to fail for id=1
}
print "Testing: \$cursor->finish: ";
( $cursor->finish )
and print( "ok\n" )
or print( "not ok: $DBI::errstr\n" );
# multiple record tests
print "Testing: \$cursor = \$dbh->prepare( 'SELECT FROM $test_tabname' ): ";
( $cursor = $dbh->prepare( "SELECT * FROM $test_tabname" ) )
and print( "prepare select ok\n" )
or die "prepare select not ok: $DBI::errstr\n";
print "Testing: \$cursor->execute: ";
( $cursor->execute )
and print( "ok\n" )
or die "not ok: $DBI::errstr\n";
print "Testing: multiple \$cursor->fetchrow's:\n";
while ( @row = $cursor->fetchrow )
{
if ( $DBD::Empress::err != 0 )
{
print "Fetch Error ($DBD::Empress::err): $DBD::Empress::errstr\n";
}
print( "@row\n" )
}
print "Testing: \$cursor->finish: ";
( $cursor->finish )
and print( "ok\n" )
or die "not ok: $DBI::errstr\n";
( $dbh->disconnect )
and print(" d$iconnect\n")
view all matches for this distribution
view release on metacpan or search on metacpan
# --------------------------------------------------------------------------
# Cursor functions: prepare/execute/fetch/nrows, etc.
# --------------------------------------------------------------------------
print "Testing: \$cursor = \$dbh->prepare( 'SELECT FROM $test_tabname WHERE ¼±ÊÌ»Ò = 1' ): ";
( $cursor = $dbh->prepare( "SELECT * FROM $test_tabname WHERE ¼±ÊÌ»Ò = 1" ) )
and print( "prepare select ok\n" )
or print( "prepare select not ok: $DBI::errstr\n" );
print "Testing: \$cursor->execute: ";
( $cursor->execute )
and print( "execute select ok\n" )
or die "execute select not ok: $DBI::errstr\n";
# expect the following select to fail, as id=1 has been deleted already
print "Testing: \$cursor->fetchrow: ";
if ( @row = $cursor->fetchrow )
{
print( "not ok ($DBI::err): $DBI::errstr, record: @row\n" );
}
else
{
print( "ok\n" ); # expect it to fail for id=1
}
print "Testing: \$cursor->finish: ";
( $cursor->finish )
and print( "ok\n" )
or print( "not ok: $DBI::errstr\n" );
# multiple record tests
print "Testing: \$cursor = \$dbh->prepare( 'SELECT FROM $test_tabname' ): ";
( $cursor = $dbh->prepare( "SELECT * FROM $test_tabname" ) )
and print( "prepare select ok\n" )
or die "prepare select not ok: $DBI::errstr\n";
print "Testing: \$cursor->execute: ";
( $cursor->execute )
and print( "ok\n" )
or die "not ok: $DBI::errstr\n";
print "Testing: multiple \$cursor->fetchrow's:\n";
while ( @row = $cursor->fetchrow )
{
if ( $DBD::EmpressNet::err != 0 )
{
print "Fetch Error ($DBD::EmpressNet::err): $DBD::EmpressNet::errstr\n";
}
print( "@row\n" )
}
print "Testing: \$cursor->finish: ";
( $cursor->finish )
and print( "ok\n" )
or die "not ok: $DBI::errstr\n";
( $dbh->disconnect )
and print(" d$iconnect\n")
view all matches for this distribution
view release on metacpan or search on metacpan
Firebird.pm view on Meta::CPAN
Calling do() method without bind value(s) will do the same.
=item * CLOSE, OPEN, DECLARE CURSOR
$sth->{CursorName} is automagically available upon executing a "SELECT .. FOR
UPDATE" statement. A cursor is closed after the last fetch(), or by calling
$sth->finish().
=item * PREPARE, EXECUTE, FETCH
Similar functionalities are obtained by using prepare(), execute(), and
view all matches for this distribution
view release on metacpan or search on metacpan
print "Doing a query (expecting 'Data truncated' error)... ";
#$::ful_dbh->{LongTruncOk} = 0;
#my $cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'', {fulcrum_MaximumHitsInInternalColumns => 100});
my $cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'');
if ($cursor) {
print "(execute) ... ";
$cursor->execute;
print "ok, now fetching (fetchrow): ";
my $text;
my @row;
my $eot;
my $data_truncated = 0;
while (@row = $cursor->fetchrow) {
$data_truncated++ if ($cursor->state =~ /01004/);
}
print "checking data truncated condition... ";
if ($data_truncated == 0) {
print "FAILED: did not detect 01004 [Data truncated] condition!\n";
exit 1;
exit 1;
}
print "Doing another query (this time you'll see the data)... ";
$DBD::Fulcrum::ful_maxhitsinternalcolumns = 64;
$cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'');
if ($cursor) {
print "(execute) ... ";
$cursor->execute;
print "ok, now fetching (fetchrow):\n***\n";
my $text;
my @row;
my $eot;
my $data_truncated = 0;
while (@row = $cursor->fetchrow) {
$data_truncated++ if ($DBI::state =~ /truncated/);
$cursor->blob_read (1, 0, 8192, \$text);
#or (print "+++ RB NOT OK:$DBI::errstr\n");
$text = $` if ($text =~ /\x00/);
print "(FILE: $row[1] TITLE: '$row[3]') "; #$text removed to clean up output
}
if ($data_truncated > 0) {
else {
print "FAILED: Prepare failed ($DBI::errstr)\n";
exit 1;
}
$cursor->finish;
$ful_dbh->disconnect;
print "Exiting\nIf you are here, then most likely all tests were successful.\n";
exit 0;
# end.
view all matches for this distribution
view release on metacpan or search on metacpan
dbd-illustra.pod view on Meta::CPAN
Neither automatic row numbering nor row count limitations are supported.
=head3 Positioned updates and deletes
Illustra supports positioned updates or deletes in cursors that have been
explicitly created and opened C<FOR UPDATE>. For example:
$dbh->do("DECLARE cur1 CURSOR FOR SELECT * FROM tab1 FOR UPDATE");
$dbh->do("OPEN cur1");
$sth = $dbh->prepare("FETCH NEXT FROM cur1");
view all matches for this distribution
view release on metacpan or search on metacpan
Informix.pm view on Meta::CPAN
at the moment; yes, some clown in marketing decreased the version number).
All version families acquire extra versions on occasion.
Note that DBD::Informix does not work with Informix ESQL/C Version
4.1x or earlier versions because it uses both SQL descriptors and
strings for cursor names and statement names, and these features were
not available before Version 5.00.
For information about Informix software, you should also read the
Notes/FAQ file that is distributed with Informix Database Driver for Perl DBI.
Informix.pm view on Meta::CPAN
=head2 CREATING STATEMENTS
You can also prepare a statement for multiple uses, and you can do
this for SELECT and EXECUTE PROCEDURE statements that return data
(cursory statements) as well as noncursory statements that return no data.
You create a statement handle (another reference) using:
$sth = $dbh->prepare($stmt);
If the statement is a SELECT that returns data (not SELECT...INTO TEMP) or
an EXECUTE PROCEDURE for a procedure that returns values, a cursor is
declared for the prepared statement.
The prepare call accepts an optional attributes parameter that is a
reference to a hash.
Starting with version 1.03.PC1, the following attributes are recognized:
Informix.pm view on Meta::CPAN
The ix_ScrollCursor is a placeholder that may become unnecessary with a
future revision of DBI.
The ix_CursorWithHold attribute is only of relevance if AutoCommit is
disabled.
When AutoCommit is enabled, all cursors have to be WITH HOLD (just one
more reason to hate AutoCommit).
$sth = $dbh->prepare("SELECT id, name FROM tablename", {'ix_CursorWithHold' => 1});
After the cursor is opened ($sth->execute), it is not closed by
$dbh->commit().
Either fetch all the rows or use $sth->finish() to close it.
The ix_InsertCursor attribute can be applied to an INSERT statement (but
generates an error -481 for other types of statement).
Subsequent uses of $sth->execute() will use the ESQL/C PUT statement to
insert the data, and $sth->finish() will close the INSERT cursor.
There is at present no mechanism to invoke the FLUSH statement.
It would be reasonable to add {ix_BlobLocation => 'InFile'} to support
per-statement blob location.
Informix.pm view on Meta::CPAN
# Emphasizing the SQL action.
$sth = $dbh->prepare($stmt) or die "Failed to prepare '$stmt'\n"
You can tell whether the statement is just executable or whether it is
a cursory (fetchable) statement by testing the
Informix-specific attribute ix_Fetchable.
The approved, canonical DBI method of doing this check is
"$sth->{NUM_OF_FIELDS} > 0".
Once the statement is prepared, you can execute it:
$sth->execute;
For a noncursory statement, this simply executes the statement.
If the statement is executed successfully, the number of rows
affected will be returned.
If an error occurs, the returned value will be undef.
If the statement does not affect any rows, the string returned is
"0E0", which evaluates to true but also to zero.
For a cursory statement, $sth->execute opens the cursor.
If the cursor is opened successfully, it returns the value "0E0",
which evaluates to true but also to zero.
If an error occurs, the returned value will be undef.
You can also specify the input parameters for a statement that contains
question-marks as place-holders using:
Informix.pm view on Meta::CPAN
clause of the INSERT statement.
The INSERT statement is a special case, and it provides support for
code that implements the non-SQL statement 'LOAD FROM "file" INSERT
INTO SomeTable'.
For cursory statements, you can discover the returned column
names, types, nullability, and so on.
You do this with:
@name = @{$sth->{NAME}}; # Column names
@null = @{$sth->{NULLABLE}}; # True => accepts nulls
Informix.pm view on Meta::CPAN
For example, in "SELECT A.Column, B.Column FROM Table1 A, Table1 B
WHERE ...", both the return columns are described as 'column'.
=back
If the statement is a cursory statement, you can retrieve the
values in any of a number of ways, as described in the DBI
specification.
$ref = $sth->fetchrow_arrayref;
$ref = $sth->fetch; # Alternative spelling...
Informix.pm view on Meta::CPAN
BUG: ix_BlobLocation is not handled properly.
=back
When you have fetched as many rows as required, you close the cursor using:
$sth->finish;
You do not have to finish a cursor explicitly if you executed a fetch
that failed to retrieve any data.
Using $sth->finish simply closes the cursor but does not free the cursor
or the statement.
That is done when you destroy (undef) the statement handle:
undef $sth;
Informix.pm view on Meta::CPAN
$txt = $sth->{Statement};
=head2 CURSORS FOR UPDATE
You can use the (DBI standard) attribute $sth->{CursorName} to retrieve the name of a
cursor.
If the statement for $sth is actually a SELECT and the cursor is in a
MODE ANSI database or is declared with the 'FOR UPDATE [OF col,...'
tag, you can use the cursor name in a 'DELETE...WHERE CURRENT OF'
or 'UPDATE...WHERE CURRENT OF' statement.
$st1 = $dbh->prepare("SELECT * FROM SomeTable FOR UPDATE");
$wc = "WHERE CURRENT OF $st1->{CursorName}";
$st2 = $dbh->prepare("UPDATE SomeTable SET SomeColumn = ? $wc");
Informix.pm view on Meta::CPAN
In a MODE ANSI database, you can execute BEGIN WORK successfully.
However, if AutoCommit is On, the transaction is immediately
committed, so it does you no good.
If the user elects to switch to AutoCommit On, things get trickier.
All cursors need to be declared WITH HOLD so that Group 4B statements
being committed do not close the active cursors.
Whenever a Group 4B statement is executed, the statement needs to be
committed.
With OnLine (and theoretically with SE), if the statement fails there
is no need to do a rollback -- the statement failing did the rollback
anyway.
Informix.pm view on Meta::CPAN
$sth->execute => EXECUTE or OPEN
$sth->fetch => FETCH
$sth->fetchrow => FETCH
$sth->finish => CLOSE
undef $sth => FREE cursor, FREE statement, etc
=head1 KNOWN RESTRICTIONS
=over 2
view all matches for this distribution
view release on metacpan or search on metacpan
Informix4.xs view on Meta::CPAN
CODE:
D_imp_dbh(dbh);
if ( !DBIc_ACTIVE(imp_dbh) ) {
XSRETURN_YES;
}
/* 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) && !dirty) {
warn("disconnect(%s) invalidates %d active cursor(s)",
SvPV(dbh,na), (int)DBIc_ACTIVE_KIDS(imp_dbh));
}
ST(0) = dbd_db_disconnect(dbh, imp_dbh) ? &sv_yes : &sv_no;
view all matches for this distribution
view release on metacpan or search on metacpan
if ($sql_sth) {
$sql_sth->finish;
undef $sql_sth;
1;
} else {
carp "Ingperl: close with no open cursor, at"
if $sql_drh->{Warn};
1;
}
}
sub sql_fetch {
croak "Ingperl: No active cursor, at" unless $sql_sth;
my(@row) = $sql_sth->fetchrow();
$sql_rowcount = $sql_sth->rows();
unless (@row) {
&sql_close();
return wantarray ? () : undef;
sub sql_eval_row1{
my $sth = $sql_dbh->prepare(@_);
return undef unless $sth;
$sth->execute or return undef;
my(@row) = $sth->fetchrow; # fetch one row
$sth->finish; # close the cursor
undef $sth;
@row;
}
# Library function to execute a select and return first col
$sth->execute or return undef;
my ($row, @col);
while ($row = $sth->fetch){
push(@col, $row->[0]);
}
$sth->finish; # close the cursor
undef $sth;
@col;
}
package Ingperl::var;
@values = &sql_fetch;
Fetch the next record of data returned from the last prepared
select statement. When all records have been returned &sql_fetch
will close the select statement cursor and return an empty array.
For example:
&sql('select * from iitables') || die $sql_error;
while(@values = &sql_fetch){
B<DBD:> C<&sql_fetch> will call C<&sql_close> when the last row of data
has been fetched. This has been the way it was supposed to be...
B<DBD:> C<&sql_fetch> will die with the error C<Ingperl: No active
cursor> if an error has occured in the C<&sql(select..)>-statement.
B<DBD:> C<$scalar = &sql_fetch> returns the first column of data if
C<$sql_sth-E<gt>{CompatMode}> is set; this is the default mode for
Ingperl and is the expected behaviour for Perl4. In Perl5 (and with
C<$sql_sth-E<gt>{CompatMode}> unset) the number of columns will be
=item * sql_close
&sql_close;
This function needs to be called B<only> if you do not use C<&sql_fetch>
to fetch B<all> the records B<and> you wish to close the cursor as soon as
possible (to release locks etc). Otherwise ignore it. Always returns
true.
B<DBD:> If C<$sql_sth-E<gt>{Warn}> is false the warning C<Ingperl: close
with no open cursor> will be given whenever a closed cursor is reclosed.
The default behaviour is to omit the warning.
=back
IngPerl Functions to describe the currently prepared statement. These
Create Table As Select or Copy this variable holds the number of rows
affected.
=item * $sql_readonly (default 1)
If true then prepared sql statements are given read only cursors this is
generally a considerable performance gain.
B<DBD:> Not implemented. All cursors are readonly - there is no way to
modify the value of a cursor element, therefore no reason not to make
the cursors readonly. The value of this variable was ignored already in
Ingperl 2.0.
=item * $sql_showerrors (default 0)
If true then ingres error and warning messages are printed by
@row1 = &sql_eval_row1('select ...');
Execute a select statement and return the first row.
B<DBD:> This is executed in a separate cursor and can therefore be
executed while a &sql_fetch-loop is in progres.
=item * sql_eval_col1
@col1 = &sql_eval_col1('select ...');
Execute a select statement and return the first column.
B<DBD:> As &sql_eval_col1 this is executed in a separate cursor.
=head1 NOTES
The DBD::Ingres module has been modelled closely on Tim Bunce's
DBD::Oracle module and warnings that apply to DBD::Oracle and the
view all matches for this distribution
view release on metacpan or search on metacpan
IngresII.pm view on Meta::CPAN
execute time rather than bind time. (Similar to bind_param_inout, except
you don't pass them as references.)
=head2 ing_readonly
Normally cursors are declared C<READONLY> to increase speed. READONLY
cursors don't create exclusive locks for all the rows selected; this is
the default.
If you need to update a row then you will need to ensure that either
=over 4
IngresII.pm view on Meta::CPAN
{ ing_readonly => 1} );
will be opened C<FOR READONLY>.
When you wish to actually do the update, where you would normally put the
cursor name, you put:
$sth->{CursorName}
instead, for example:
IngresII.pm view on Meta::CPAN
$sth->execute;
and so on. B<Note> that an C<update> will now cause an SQL error.
In fact the "FOR UPDATE" seems to be optional, i.e., you can update
cursors even if their SELECT statements do not contain a C<for update>
part.
If you wish to update such a cursor you B<must> include the C<ing_readonly>
attribute.
B<NOTE> DBD::IngresII version later than 0.19_1 have opened all cursors for
update. This change breaks that behaviour. Sorry if this breaks your code.
=head2 ing_rollback
The DBI docs state that 'Changing C<AutoCommit> from off to on will
IngresII.pm view on Meta::CPAN
=head2 disconnect_all
Not implemented
=head2 commit and rollback invalidate open cursors
DBD::IngresII should warn when a commit or rollback is isssued on a $dbh
with open cursors.
Possibly a commit/rollback should also undef the $sth's. (This should
probably be done in the DBI-layer as other drivers will have the same
problems).
After a commit or rollback the cursors are all ->finish'ed, i.e., they
are closed and the DBI/DBD will warn if an attempt is made to fetch
from them.
A future version of DBD::IngresII wil possibly re-prepare the statement.
view all matches for this distribution
view release on metacpan or search on metacpan
InterBase.pm view on Meta::CPAN
Calling do() method without bind value(s) will do the same.
=item * CLOSE, OPEN, DECLARE CURSOR
$sth->{CursorName} is automagically available upon executing a "SELECT .. FOR
UPDATE" statement. A cursor is closed after the last fetch(), or by calling
$sth->finish().
=item * PREPARE, EXECUTE, FETCH
Similar functionalities are obtained by using prepare(), execute(), and
InterBase.pm view on Meta::CPAN
}
=item * Using $dbh->{ib_softcommit} = 1
This driver-specific attribute is available as of version 0.30. You may want
to look at t/40cursoron.t to see it in action.
=back
=head2 Why do nested statement handles break under AutoCommit mode?
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/JDBC.pod view on Meta::CPAN
$h->jdbc_func(parameter, ..., <jdbc_method_name>);
For example,
$ret = $dbh->jdbc_func("getAutoCommit");
$ret = $sth->jdbc_func("mycursor", "Statement.setCursorName");
The driver-specific method C<jdbc_func> replaces the previous use
of the standard DBI method C<func> for calling JDBC
methods. Since C<jdbc_func> is a driver-specific method, the
C<jdbc_> prefix previously required on the method name argument
lib/DBD/JDBC.pod view on Meta::CPAN
Examples
$ret = $sth->jdbc_func("jdbc_Statement.getMaxFieldSize");
$sth1->jdbc_func("mycursor", "jdbc_Statement.setCursorName");
$sth1->jdbc_func([22 => SQL_INTEGER], "jdbc_Statement.setMaxFieldSize");
$ret = $sth1->jdbc_func("jdbc_ResultSet.next");
$ret = $sth1->jdbc_func("cname", "jdbc_ResultSet.getString");
$ret = $sth2->jdbc_func("eno", [5003 => SQL_INTEGER], "jdbc_ResultSet.updateInt");
lib/DBD/JDBC.pod view on Meta::CPAN
Some sort of explicit support for scrollable result sets will
probably be implemented at a later date.
=head2 Closing cursors
When a statement handle goes out of scope, Perl will call its
DESTROY method. This method will cause C<Statement.close> to be
called on the associated Java C<Statement> object in the
DBD::JDBC server. For many applications, this is
lib/DBD/JDBC.pod view on Meta::CPAN
The server was asked to return the value of an unknown attribute.
=item Error code 4
This error code indicates that the client attempted to do
something which requires a cursor (a ResultSet) on the server,
but no cursor is present.
=item Error code 5
No metadata is currently available. This error will result if a
request is made for a statement attribute at a time when no
view all matches for this distribution
view release on metacpan or search on metacpan
C<< $dbh->pg_lo* >> methods. Please note that access to a large object, even read-only
large objects, must be put into a transaction.
=head2 Cursors
Although Kingbase supports cursors, they have not been used in the current
implementation. When DBD::KB was created, cursors in Kingbase could only be
used inside a transaction block. Because only one transaction block at a time
is allowed, this would have implied the restriction not to use any nested
C<SELECT> statements. Therefore the L</execute> method fetches all data at
once into data structures located in the front-end application. This fact
must to be considered when selecting large amounts of data!
You can use cursors in your application, but you'll need to do a little
work. First you must declare your cursor. Now you can issue queries against
the cursor, then select against your queries. This typically results in a
double loop, like this:
# WITH HOLD is not needed if AutoCommit is off
$dbh->do("DECLARE csr CURSOR WITH HOLD FOR $sql");
while (1) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/MVS_FTPSQL.pm view on Meta::CPAN
(precisely phantom) rows, as another concurrent transaction can insert rows that match
the search criteria of the query.
=item Cursor Stability (CS)
This is the default isolation level. It locks only the row (the page) that is currently being returned. As the cursor leaves the row, the lock is released and acquired for the next one, until all the data is returned.
While this maximizes concurrency and prevents dirty reads it does not
ensure that the data retrieved will not be changed by other transactions, so
if the transaction reads the same row of data more than once odds are it
gets different results each time (nonrepetable read phenomena).
view all matches for this distribution
view release on metacpan or search on metacpan
Changes.historic view on Meta::CPAN
21/07/95:09:22 Added a field into imp_sth (currow) which keeps track of the
current row that's been fetched from the result struct. If I
can fix the return codes coming from fetchrow, it'll work!
21/07/95:10:30 Pondered bind variables in cursors. Since there isn't a bind
function in the API, I may have to frig the way that prepare/
execute works, ie, move the call to msqlQuery *after* it's
done some parsing for bind values......Hm.
21/07/95:10:35 Twiddled some bits in the fetchrow cycle.
view all matches for this distribution
view release on metacpan or search on metacpan
SQLDBC_PreparedStatement_setMaxRows (imp_sth->m_prepstmt, maxrows);
erg = SQLDBC_TRUE;
break;
}
case sth_maxdb_option_CursorName:{
char* cursorname = SvPV(valuesv,kl);
SQLDBC_PreparedStatement_setCursorName (imp_sth->m_prepstmt, cursorname, kl, SQLDBC_StringEncodingType_Encoding_UTF8) ;
erg = SQLDBC_TRUE;
break;
}
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
{
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
/* SV **svp; */
/* char cname[128]; */ /* cursorname */
dTHR;
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
{
dTHR;
D_imp_dbh_from_sth;
RETCODE rc;
/* SV **svp;
char cname[128]; */ /* cursorname */
imp_sth->done_desc = 0;
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
imp_sth->odbc_ignore_named_placeholders = imp_dbh->odbc_ignore_named_placeholders;
dTHR;
D_imp_dbh_from_sth;
RETCODE rc;
int ret = 0;
/* Cancel further fetches from this cursor. */
/* We don't close the cursor till DESTROY (dbd_st_destroy). */
/* The application may re execute(...) it. */
/* XXX semantics of finish (eg oracle vs odbc) need lots more thought */
/* re-read latest DBI specs and ODBC manuals */
if (DBIc_ACTIVE(imp_sth) && imp_dbh->hdbc != SQL_NULL_HDBC) {
STRLEN kl;
char *key = SvPV(keysv,kl);
int i;
SV *retsv = NULL;
T_st_params *par;
char cursor_name[256];
SWORD cursor_name_len;
RETCODE rc;
for (par = S_st_fetch_params; par->len > 0; par++)
if (par->len == kl && strEQ(key, par->str))
break;
while(--i >= 0)
av_store(av, i, newSViv(imp_sth->fbh[i].ColLength));
break;
case 9: /* CursorName */
rc = SQLGetCursorName(imp_sth->hstmt,
cursor_name, sizeof(cursor_name), &cursor_name_len);
if (!SQL_ok(rc)) {
dbd_error(sth, rc, "st_FETCH/SQLGetCursorName");
return Nullsv;
}
retsv = newSVpv(cursor_name, cursor_name_len);
break;
case 10: /* odbc_more_results */
retsv = newSViv(imp_sth->moreResults);
break;
case 11:
dTHR;
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
#if 0
/* TBD: cursorname? */
char cname[128]; /* cursorname */
#endif
imp_sth->henv = imp_dbh->henv; /* needed for dbd_error */
imp_sth->hdbc = imp_dbh->hdbc;
view all matches for this distribution
view release on metacpan or search on metacpan
dbdnet/extratests/multicursor.pl view on Meta::CPAN
#!/usr/bin/perl -w
#
# Tests multiple simultaneous cursors being open
#
# Assuming we have a table of the schema in 'numerics.pl'
$dbname = "test";
$tablename1 = "test3";
dbdnet/extratests/multicursor.pl view on Meta::CPAN
$dbh = $drh->connect( 'dbhost', $dbname, 'blah', 'blah' );
if ( !defined $dbh ) {
die "Cannot connect to database: $DBI::errstr\n";
}
# Open the first cursor
$sth1 = $dbh->prepare( "
SELECT id1, id2, id3, id4, name
FROM $tablename1" );
if ( !defined $sth1 ) {
die "Cannot prepare sth1: $DBI::errstr\n";
}
# Open the second cursor
$sth2 = $dbh->prepare( "
SELECT id, name
FROM $tablename2" );
if ( !defined $sth2 ) {
die "Cannot prepare sth2: $DBI::errstr\n";
view all matches for this distribution
view release on metacpan or search on metacpan
odbc_async_exec => undef, # sth and dbh
odbc_exec_direct => undef,
odbc_describe_parameters => undef,
odbc_SQL_ROWSET_SIZE => undef,
odbc_SQL_DRIVER_ODBC_VER => undef,
odbc_cursortype => undef,
odbc_query_timeout => undef, # sth and dbh
odbc_has_unicode => undef,
odbc_out_connect_string => undef,
odbc_version => undef,
odbc_err_handler => undef,
=head3 odbc_SQL_DRIVER_ODBC_VER
This, while available via get_info() is captured here. I may get rid
of this as I only used it for debugging purposes.
=head3 odbc_cursortype
This allows multiple concurrent statements on SQL*Server. In your
connect, add
{ odbc_cursortype => 2 }.
If you are using DBI > 1.41, you should also be able to use
{ odbc_cursortype => DBI::SQL_CURSOR_DYNAMIC }
instead. For example:
my $dbh = DBI->connect("dbi:ODBC:$DSN", $user, $pass,
{ RaiseError => 1, odbc_cursortype => 2});
my $sth = $dbh->prepare("one statement");
my $sth2 = $dbh->prepare("two statement");
$sth->execute;
my @row;
while (@row = $sth->fetchrow_array) {
normal and it will be subject to LongReadLen and b) fail
odbc_lob_read.
NOTE: Some database engines and ODBC drivers do not allow you to
retrieve columns out of order (e.g., MS SQL Server unless you are
using cursors). In those cases you must ensure the lob retrieved is
the last (or only) column in your select list.
NOTE: You can retrieve only part of a lob but you will probably have
to call finish on the statement handle before you do anything else
with that statement. When only retrieving part of a large lob you
view all matches for this distribution