DBD-MaxDB
view release on metacpan or search on metacpan
maxrows = SvIV(valuesv);
if (maxrows <= 0){
dbd_maxdb_internal_error(sth, DBD_ERR_WRONG_PARAMETER_S, "MaxRows must be greater than zero");
break;
}
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;
}
}
}
DBD_MAXDB_METHOD_RETURN(imp_sth, dbd_maxdb_st_STORE_attrib, erg);
}
/***************************************************************************
*
struct imp_drh_st {
dbih_drc_t com; /*!< MUST be first element in structure */
SQLDBC_Environment *m_maxDBEnv; /*!< MaxDB environment handle*/
};
/**
* @brief This holds MaxDB Metadata. Maybe SQLDBC provides this sometime
*/
typedef struct SQLDBC_DatabaseMetaData {
SQLDBC_UInt2 getMaxTablenameLength; /*!< maximum length of a table name */
SQLDBC_UInt2 getMaxCursorLength; /*!< maximum length of a cursor name */
SQLDBC_UInt2 getMaxColumnnameLength; /*!< maximum length of a column name */
} SQLDBC_DatabaseMetaData;
/*
* @brief This holds everything to describe the database connection.
*/
struct imp_dbh_st {
dbih_dbc_t com; /*!< MUST be first element in structure */
SQLDBC_ConnectProperties *m_connprop; /*!< MaxDB connect properties */
SQLDBC_Connection *m_connection; /*!< MaxDB connect handle */
t/056stmtproperties.t view on Meta::CPAN
print " Test 11: check set CURSORNAME option\n";
$sth->{"CURSORNAME"}="SIMPSON";
MaxDBTest::Test(1);
print " Test 12: check modified CURSORNAME option\n";
$cname = $sth->{"CURSORNAME"};
print "$cname\n";
if ($cname eq "SIMPSON"){
MaxDBTest::Test(1);
} else {
MaxDBTest::Test(0, "Wrong cursor name $cname\n");
}
print " Test 13: check MAXDB_FETCHSIZE option\n";
$sth->{"MAXDB_FETCHSIZE"}=10;
MaxDBTest::Test(1);
print " Test 14: check modified MAXDB_FETCHSIZE option\n";
if ($sth->{"MAXDB_FETCHSIZE"}==10){
MaxDBTest::Test(1);
} else {
MaxDBTest::Test(0, "Wrong fetchsize $sth->{'MAXDB_FETCHSIZE'}\n");
t/mysql_30insertfetch.t view on Meta::CPAN
#
# ...and delete it........
#
Test($state or $dbh->do("DELETE FROM $table WHERE id = 1"))
or DbiError($dbh->err, $dbh->errstr);
#
# Now, try SELECT'ing the row out. This should fail.
#
Test($state or $cursor = $dbh->prepare("SELECT * FROM $table"
. " WHERE id = 1"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($cursor->err, $cursor->errstr);
my ($row, $errstr);
Test($state or (!defined($row = $cursor->fetchrow_arrayref) &&
(!defined($errstr = $cursor->errstr) ||
$cursor->errstr eq '')))
or DbiError($cursor->err, $cursor->errstr);
Test($state or $cursor->finish, "\$sth->finish failed")
or DbiError($cursor->err, $cursor->errstr);
Test($state or undef $cursor || 1);
#
# Finally drop the test table.
#
Test($state or $dbh->do("DROP TABLE $table"))
or DbiError($dbh->err, $dbh->errstr);
}
t/mysql_40bindparam.t view on Meta::CPAN
#
# Create a new table; EDIT THIS!
#
Test($state or ($def = TableDefinition($table,
["id", "INTEGER", 4, 0],
["name", "CHAR", 64, $COL_NULLABLE]),
$dbh->do($def)))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor = $dbh->prepare("INSERT INTO $table"
. " VALUES (?, ?)"))
or DbiError($dbh->err, $dbh->errstr);
#
# Insert some rows
#
# Automatic type detection
my $numericVal = 1;
my $charVal = "Alligator Descartes";
Test($state or $cursor->execute($numericVal, $charVal))
or DbiError($dbh->err, $dbh->errstr);
# Does the driver remember the automatically detected type?
Test($state or $cursor->execute("3", "Jochen Wiedmann"))
or DbiError($dbh->err, $dbh->errstr);
$numericVal = 2;
$charVal = "Tim Bunce";
Test($state or $cursor->execute($numericVal, $charVal))
or DbiError($dbh->err, $dbh->errstr);
# Now try the explicit type settings
Test($state or $cursor->bind_param(1, " 4", SQL_INTEGER()))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->bind_param(2, "Andreas König"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
# Works undef -> NULL?
Test($state or $cursor->bind_param(1, 5, SQL_INTEGER()))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->bind_param(2, undef))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
#
# Try various mixes of question marks, single and double quotes
#
Test($state or $dbh->do("INSERT INTO $table VALUES (6, '?')"))
or DbiError($dbh->err, $dbh->errstr);
if ($mdriver eq 'mysql') {
Test($state or $dbh->do("INSERT INTO $table VALUES (7, \"?\")"))
or DbiError($dbh->err, $dbh->errstr);
}
Test($state or undef $cursor || 1);
#
# And now retreive the rows using bind_columns
#
Test($state or $cursor = $dbh->prepare("SELECT * FROM $table"
. " ORDER BY id"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->bind_columns(undef, \$id, \$name))
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($ref = $cursor->fetch) && $id == 1 &&
$name eq 'Alligator Descartes')
or printf("Query returned id = %s, name = %s, ref = %s, %d\n",
$id, $name, $ref, scalar(@$ref));
Test($state or (($ref = $cursor->fetch) && $id == 2 &&
$name eq 'Tim Bunce'))
or printf("Query returned id = %s, name = %s, ref = %s, %d\n",
$id, $name, $ref, scalar(@$ref));
Test($state or (($ref = $cursor->fetch) && $id == 3 &&
$name eq 'Jochen Wiedmann'))
or printf("Query returned id = %s, name = %s, ref = %s, %d\n",
$id, $name, $ref, scalar(@$ref));
Test($state or (($ref = $cursor->fetch) && $id == 4 &&
$name eq 'Andreas König'))
or printf("Query returned id = %s, name = %s, ref = %s, %d\n",
$id, $name, $ref, scalar(@$ref));
Test($state or (($ref = $cursor->fetch) && $id == 5 &&
!defined($name)))
or printf("Query returned id = %s, name = %s, ref = %s, %d\n",
$id, $name, $ref, scalar(@$ref));
Test($state or (($ref = $cursor->fetch) && $id == 6 &&
$name eq '?'))
or print("Query returned id = $id, name = $name, expected 6,?\n");
if ($mdriver eq 'mysql') {
Test($state or (($ref = $cursor->fetch) && $id == 7 &&
$name eq '?'))
or print("Query returned id = $id, name = $name, expected 7,?\n");
}
Test($state or undef $cursor or 1);
#
# Finally drop the test table.
#
Test($state or $dbh->do("DROP TABLE $table"))
or DbiError($dbh->err, $dbh->errstr);
}
t/mysql_40listfields.t view on Meta::CPAN
#
# Create a new table
#
Test($state or ($def = TableDefinition($table, @table_def),
$dbh->do($def)))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $dbh->table_info(undef,undef,$table));
Test($state or $dbh->column_info(undef,undef,$table,'%'));
Test($state or $cursor = $dbh->prepare("SELECT * FROM $table"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($cursor->err, $cursor->errstr);
my $res;
Test($state or (($res = $cursor->{'NUM_OF_FIELDS'}) == @table_def))
or DbiError($cursor->err, $cursor->errstr);
if (!$state && $verbose) {
printf("Number of fields: %s\n", defined($res) ? $res : "undef");
}
Test($state or ($ref = $cursor->{'NAME'}) && @$ref == @table_def
&& (lc $$ref[0]) eq $table_def[0][0]
&& (lc $$ref[1]) eq $table_def[1][0])
or DbiError($cursor->err, $cursor->errstr);
if (!$state && $verbose) {
print "Names:\n";
for ($i = 0; $i < @$ref; $i++) {
print " ", $$ref[$i], "\n";
}
}
Test($state or ($ref = $cursor->{'NULLABLE'}) && @$ref == @table_def
&& !($$ref[0] xor ($table_def[0][3] & $COL_NULLABLE))
&& !($$ref[1] xor ($table_def[1][3] & $COL_NULLABLE)))
or DbiError($cursor->err, $cursor->errstr);
if (!$state && $verbose) {
print "Nullable:\n";
for ($i = 0; $i < @$ref; $i++) {
print " ", ($$ref[$i] & $COL_NULLABLE) ? "yes" : "no", "\n";
}
}
Test($state or (($ref = $cursor->{TYPE}) && (@$ref == @table_def)
&& ($ref->[0] eq DBI::SQL_INTEGER())
&& ($ref->[1] eq DBI::SQL_VARCHAR() ||
$ref->[1] eq DBI::SQL_CHAR()||
$ref->[1] eq DBI::SQL_WCHAR())))
or printf("Expected types %d and %d, got %s and %s\n",
&DBI::SQL_INTEGER(), &DBI::SQL_VARCHAR(),
defined($ref->[0]) ? $ref->[0] : "undef",
defined($ref->[1]) ? $ref->[1] : "undef");
Test($state or undef $cursor || 1);
#
# Drop the test table
#
Test($state or ($cursor = $dbh->prepare("DROP TABLE $table")))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($cursor->err, $cursor->errstr);
# NUM_OF_FIELDS should be zero (Non-Select)
Test($state or ($cursor->{'NUM_OF_FIELDS'} == 0))
or !$verbose or printf("NUM_OF_FIELDS is %s, not zero.\n",
$cursor->{'NUM_OF_FIELDS'});
Test($state or (undef $cursor) or 1);
#
# Test different flavours of quote. Need to work around a bug in
# DBI 1.02 ...
#
my $quoted;
if (!$state) {
$quoted = eval { $dbh->quote(0, DBI::SQL_INTEGER()) };
}
Test($state or $@ or $quoted eq 0);
t/mysql_40nulls.t view on Meta::CPAN
#
# Test whether or not a field containing a NULL is returned correctly
# as undef, or something much more bizarre
#
Test($state or $dbh->do("INSERT INTO $table VALUES"
. " ( NULL, 'NULL-valued id' )"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor = $dbh->prepare("SELECT * FROM $table"
. " WHERE " . IsNull("id")))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($rv = $cursor->fetchrow_arrayref) or $dbdriver eq 'CSV')
or DbiError($dbh->err, $dbh->errstr);
Test($state or (!defined($$rv[0]) and defined($$rv[1])) or
$dbdriver eq 'CSV')
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->finish)
or DbiError($dbh->err, $dbh->errstr);
Test($state or undef $cursor || 1);
#
# Finally drop the test table.
#
Test($state or $dbh->do("DROP TABLE $table"))
or DbiError($dbh->err, $dbh->errstr);
}
t/mysql_40numrows.t view on Meta::CPAN
# This section should exercise the sth->rows
# method by preparing a statement, then finding the
# number of rows within it.
# Prior to execution, this should fail. After execution, the
# number of rows affected by the statement will be returned.
#
Test($state or $dbh->do("INSERT INTO $table"
. " VALUES( 1, 'Alligator Descartes' )"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($cursor = $dbh->prepare("SELECT * FROM $table"
. " WHERE id = 1")))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($numrows = $cursor->rows) == 1 or ($numrows == -1))
or ErrMsgF("Expected 1 rows, got %s.\n", $numrows);
Test($state or ($numrows = TrueRows($cursor)) == 1)
or ErrMsgF("Expected to fetch 1 rows, got %s.\n", $numrows);
Test($state or $cursor->finish)
or DbiError($dbh->err, $dbh->errstr);
Test($state or undef $cursor or 1);
Test($state or $dbh->do("INSERT INTO $table"
. " VALUES( 2, 'Jochen Wiedmann' )"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($cursor = $dbh->prepare("SELECT * FROM $table"
. " WHERE id >= 1")))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($numrows = $cursor->rows) == 2 or ($numrows == -1))
or ErrMsgF("Expected 2 rows, got %s.\n", $numrows);
Test($state or ($numrows = TrueRows($cursor)) == 2)
or ErrMsgF("Expected to fetch 2 rows, got %s.\n", $numrows);
Test($state or $cursor->finish)
or DbiError($dbh->err, $dbh->errstr);
Test($state or undef $cursor or 1);
Test($state or $dbh->do("INSERT INTO $table"
. " VALUES(3, 'Tim Bunce')"))
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($cursor = $dbh->prepare("SELECT * FROM $table"
. " WHERE id >= 2")))
or DbiError($dbh->err, $dbh->errstr);
Test($state or $cursor->execute)
or DbiError($dbh->err, $dbh->errstr);
Test($state or ($numrows = $cursor->rows) == 2 or ($numrows == -1))
or ErrMsgF("Expected 2 rows, got %s.\n", $numrows);
Test($state or ($numrows = TrueRows($cursor)) == 2)
or ErrMsgF("Expected to fetch 2 rows, got %s.\n", $numrows);
Test($state or $cursor->finish)
or DbiError($dbh->err, $dbh->errstr);
Test($state or undef $cursor or 1);
#
# Finally drop the test table.
#
Test($state or $dbh->do("DROP TABLE $table"))
or DbiError($dbh->err, $dbh->errstr);
}
( run in 0.343 second using v1.01-cache-2.11-cpan-4d50c553e7e )