DBD-DBMaker
view release on metacpan or search on metacpan
=item NULLABLE (array-ref) read-only
Returns a *reference* to an array indicating the possibility of each column
returning a null: 0 = no, 1 = yes.
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
this document method.
=item RowsInCache (integer) read-only, currently return undef.
If the driver supports a local row cache for select statements then this
ST(0) = dbd_db_rollback(dbh) ? &sv_yes : &sv_no;
void
disconnect(dbh)
SV * dbh
CODE:
D_imp_dbh(dbh);
if ( !DBIc_ACTIVE(imp_dbh) ) {
XSRETURN_YES;
}
/* Check for disconnect() being called whilst refs to cursors */
/* still exists. This 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) ? &sv_yes : &sv_no;
void
DESTROY(dbh)
SV * dbh
PPCODE:
D_imp_dbh(dbh);
dbd_st_table_info(dbh, sth, qualifier, table_type)
SV *dbh;
SV *sth;
char *qualifier;
char *table_type;
{
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
imp_sth->done_desc = 0;
rc = SQLAllocStmt(imp_dbh->hdbc, &imp_sth->hstmt);
dbmaker_error(sth, rc, "st_tables/SQLAllocStmt");
if (rc != SQL_SUCCESS) {
return 0;
}
/* just for sanity, later. Any internals that may rely on this (including */
/* debugging) will have valid data */
int
dbd_st_prepare(sth, statement, attribs)
SV *sth;
char *statement;
SV *attribs;
{
D_imp_sth(sth);
D_imp_dbh_from_sth;
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
imp_sth->done_desc = 0;
rc = SQLAllocStmt(imp_dbh->hdbc, &imp_sth->hstmt);
dbmaker_error(sth, rc, "st_prepare/SQLAllocStmt");
if (rc != SQL_SUCCESS)
{
return 0;
}
int
dbd_st_finish(sth)
SV *sth;
{
D_imp_sth(sth);
D_imp_dbh_from_sth;
D_imp_drh_from_dbh;
RETCODE rc;
int ret = 1;
/* Cancel further fetches from this cursor. */
/* We don't close the cursor till DESTROY (dbd_st_destroy). */
/* The application may re execute(...) it. */
if (DBIc_ACTIVE(imp_sth) && imp_dbh->hdbc != SQL_NULL_HDBC)
{
rc = SQLFreeStmt(imp_sth->hstmt, SQL_CLOSE);
dbmaker_error(sth, rc, "st_finish/SQLFreeStmt(SQL_CLOSE)");
if (rc != SQL_SUCCESS)
ret = 0;
#ifdef SOL22_AUTOCOMMIT_BUG
SV *keysv;
{
D_imp_sth(sth);
STRLEN kl;
char *key = SvPV(keysv,kl);
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;
int par_index;
for (par = S_st_fetch_params;
par->len > 0;
par++)
if (par->len == kl && strEQ(key, par->str))
break;
if (par->len <= 0)
case 14: /* dbmaker_length */
av = newAV();
retsv = newRV(sv_2mortal((SV*)av));
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);
dbmaker_error(sth, rc, "st_FETCH/SQLGetCursorName");
if (rc != SQL_SUCCESS)
{
if (dbis->debug >= 1)
{
fprintf(DBILOGFP,
"SQLGetCursorName returned %d in dbd_st_FETCH\n",
rc);
}
return Nullsv;
}
retsv = newSVpv(cursor_name, cursor_name_len);
break;
case 10: /* blob_size */
if (DBIc_WARN(imp_sth))
warn("Depreciated feature 'blob_size'. "
"Please use 'dbmaker_blob_size' instead.");
/* fall through */
case 12: /* dbmaker_blob_size */
case 15: /* LongReadLen */
retsv = newSViv(DBIc_LongReadLen(imp_sth));
break;
dbd_st_get_type_info(dbh, sth, ftype)
SV *dbh;
SV *sth;
int ftype;
{
dTHR;
D_imp_dbh(dbh);
D_imp_sth(sth);
RETCODE rc;
SV **svp;
char cname[128]; /* cursorname */
imp_sth->done_desc = 0;
rc = SQLAllocStmt(imp_dbh->hdbc, &imp_sth->hstmt);
if (rc != SQL_SUCCESS) {
dbmaker_error(sth, rc, "dbmaker_get_type_info/SQLGetTypeInfo");
return 0;
}
/* just for sanity, later. Any internals that may rely on this (including */
/* debugging) will have valid data */
html/dbd-dbmaker.html view on Meta::CPAN
<P>
Returns a *reference* to an array indicating the possibility of each column
returning a null: 0 = no, 1 = yes.
<P>
<PRE> Example:
print "First column may return NULL\n" if $sth->{NULLABLE}->[0];
</PRE>
<DT><STRONG><A NAME="item_CursorName">CursorName (string) read-only</A></STRONG><DD>
<P>
Returns the name of the cursor associated with the statement handle if
available.
<DT><STRONG><A NAME="item_Statement">Statement (string) read-only</A></STRONG><DD>
<P>
Returns the statement string passed to the the prepare entry elsewhere in
this document method.
<DT><STRONG><A NAME="item_RowsInCache">RowsInCache (integer) read-only, currently return undef.</A></STRONG><DD>
<P>
If the driver supports a local row cache for select statements then this
t/30insertfetch.t view on Meta::CPAN
#
# ...and delete it........
#
Check($dbh->do("DELETE FROM $table WHERE id = 1"))
or DbiError();
#
# Now, try SELECT'ing the row out. This should be fail.
#
Check(my $cursor = $dbh->prepare("SELECT * FROM $table WHERE id = 1"))
or DbiError();
Check($cursor->execute)
or DbiError();
my ($row, $errstr);
Check(! defined($row = $cursor->fetchrow_arrayref) &&
(defined($errstr = $cursor->errstr) && $cursor->errstr ne '')
) or DbiError();
Check( $cursor->finish, "\$sth->finish failed")
or DbiError();
Check(undef $cursor || 1);
#
# Finally drop the test table.
#
Check($dbh->do("DROP TABLE $table"))
or DbiError();
#
# Finally disconnect.
#
t/40blobs.t view on Meta::CPAN
Check($sth->execute)
or DbiError();
Check($sth->finish)
or DbiError();
#
# Now, try SELECT'ing the row out.
#
$dbh->{LongReadLen} = 40000;
Check($cursor = $dbh->prepare("SELECT id, name FROM $table WHERE id = 1"))
or DbiError();
Check($cursor->execute)
or DbiError();
Check((defined($row = $cursor->fetchrow_arrayref)))
or DbiError();
Check((@$row == 2 && $$row[0] == 1 && $$row[1] eq $blob))
or (ShowBlob($blob), ShowBlob(defined($$row[1]) ? $$row[1] : ""));
Check($cursor->finish)
or DbiError();
Check(undef $cursor || 1)
or DbiError();
#
# Finally drop the test table.
#
Check($dbh->do("DROP TABLE $table"))
or DbiError();
}
Check($dbh->disconnect())
( run in 0.540 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )