DBD-MaxDB
view release on metacpan or search on metacpan
# use SQLDBC_Statement for a faster version of do statements without parameters.
sub do {
my($dbh, $stmt, $attr, @params) = @_;
my $rescnt = 0;
if( -1 == $#params )
{
# No parameters, use SQLDBC_Statement
$rescnt = executeUpdate( $dbh, $stmt );
if( 0 == $rescnt )
{
$rescnt = "0E0";
}
elsif( $rescnt < -1 && $rescnt >= -4 )
{
$rescnt = -1;
}
elsif( $rescnt < -4 )
{
undef $rescnt;
}
}
else
{
$rescnt = $dbh->SUPER::do( $stmt, $attr, @params );
}
return $rescnt
}
#
# executes a simple command without parameters
# and which doesn't return a resultset
sub executeUpdate {
my ($dbh, $sql) = @_;
_executeUpdate($dbh, $sql);
}
# Call the MaxDB function SQLGetInfo
# Args are:
# $dbh - the database handle
# $item: the requested item. For example, pass 6 for SQL_DRIVER_NAME
# See the ODBC documentation for more information about this call.
#
sub GetInfo {
my ($dbh, $item) = @_;
get_info($dbh, $item);
}
sub GetTypeInfo {
my ($dbh, $sqltype) = @_;
# create a "blank" statement handle
my $sth = DBI::_new_sth($dbh, { 'Statement' => "SQLGetTypeInfo" });
# print "SQL Type is $sqltype\n";
_GetTypeInfo($dbh, $sth, $sqltype) or return undef;
$sth;
}
sub type_info_all {
my ($dbh) = @_;
my $res = DBD::MaxDB::db::_isunicode($dbh);
if ($res) {
require DBD::MaxDB::TypeInfoUnicode;
return $DBD::MaxDB::TypeInfoUnicode::type_info_all;
} else {
require DBD::MaxDB::TypeInfoAscii;
return $DBD::MaxDB::TypeInfoAscii::type_info_all;
}
}
}
{ package DBD::MaxDB::st; # ====== STATEMENT ======
use strict;
sub cancel {
my $sth = shift;
my $tmp = _Cancel($sth);
$tmp;
}
}
1;
__END__
=head1 NAME
DBD::MaxDB - MaxDB database driver for the DBI module
version 7.7.5 BUILD 000-000-000-000
=head1 SYNOPSIS
use DBI;
$dbh = DBI->connect("dbi:MaxDB:$hostname/$dbname", "$user", "$password")
or die "Can't connect $DBI::err $DBI::errstr\n";
$sth = $dbh->prepare("SELECT 'Hello World' as WELCOME from dual")
or die "Can't prepare statement $DBI::err $DBI::errstr\n";
$res = $sth->execute()
or die "Can't execute statement $DBI::err $DBI::errstr\n";
@row = $sth->fetchrow_array();
...
See the L<DBI> module documentation for full details.
=head1 DESCRIPTION
DBD::MaxDB is a Perl module which provides access to the
MaxDB databases using the DBI module. It is an
interface between the Perl programming language and the MaxDB
programming API SQLDBC that comes with the MaxDB relational
database management system.
The DBD::MaxDB module needs to link with MaxDB's common database interface
SQLDBC which is not included in this distribution. You can download it from the
MaxDB homepage at:
L<https://www.sdn.sap.com/irj/sdn/maxdb>
=head1 MODULE DOCUMENTATION
appropriate an error state. Details concerning the meaning of an error can
be found in the database messages reference at
L<http://maxdb.sap.com/documentation/>
C<< $errcode = $h->err; >>
Returns the error code.
C<< $errstr = $h->errstr; >>
Returns the error text.
C<< $sqlstate = $h->state; >>
Returns the sql state.
=head1 DBI HANDLE ATTRIBUTES
Example:
... = $h->{<attribute>}; # get/read
$h->{<attribute>} = <value> ; # set/write
=head2 Attributes common to all handles
The driver supports all of the general DBI handle attributes provided by DBI.
Differences from standard behaviour are listed below.
=over 4
=item C<ChopBlanks (boolean, inherited)>
Supported by the driver as proposed by DBI, but due to the fact that MaxDB
cannot handle trailing blanks the driver will always chop blanks for
C<CHAR/VARCHAR> columns.
=back
=head2 Database Handle Attributes
The driver supports all of the DBI database handle attributes provided by DBI.
Additionally the driver provides some MaxDB specific database handle attributes.
=over 4
=item C<maxdb_isolationlevel (integer)>
Gets/Sets the isolation level of the current connection.
=item C<maxdb_kernelversion (string, read-only)>
Gets the version of the database instance used at the current connection.
=item C<maxdb_sdkversion (string, read-only)>
Gets the version of the MaxDB SQLDBC software development kit used by the driver.
=item C<maxdb_sqlmode (string)>
Gets/Sets the SQL mode of the current connection. Possible values are
C<ORACLE | INTERNAL>.
=item C<maxdb_unicode (boolean, read-only)>
Indicates whether the current connection supports unicode (true) or not (false)
=back
=head2 Statement Handle Attributes
The driver supports all of the DBI statement handle attributes provided by DBI.
Additionally the driver provides some MaxDB specific statement handle attributes.
=over 4
=item C<maxdb_fetchSize (integer)>
Gets/Sets the maximum number of rows that can be fetched at once. Use this to
manipulate the number of rows fetched in one chunk via the order interface.
Use a value > 0 to set the maximum number of rows. Use a value <= 0 to reset
this limit to the default value. The default value is 'unlimited' (32767).
Setting this value does not affect an already executed SQL statement.
=item C<maxdb_maxrows (integer)>
Gets/Sets the number of rows of a ResultSet. The number of rows of the result
set is truncated if the result of a query statement is larger than this limit.
The default setting is 'unlimited' (0). Setting this limit does not affect an
already executed SQL statement.
=item C<maxdb_resultsetconcurrency (string)>
Gets/Sets the type of the result set concurrency. There are two kinds of
concurrency:
=over 8
=item C<CONCUR_UPDATABLE>
The result set can be updated.
=item C<CONCUR_READ_ONLY>
The result set is read-only.
=back
The default setting for the concurrency is C<CONCUR_READ_ONLY>
=item C<maxdb_resultsettype (string)>
Sets the type of a result set. A result set is only created by a query command.
There are three kinds of result sets:
=over 8
=item C<FORWARD_ONLY>
The result set can only be scrolled forward.
=item C<SCROLL_SENSITIVE>
The result set is scrollable but may change.
(like in Oracle) the concept of user and schema the same. Because database
objects are owned by an user, the owner names in the data dictionary views
correspond to schema names. This may be changed in future releases when real
schema support is added.
MaxDB also does not support catalogs so the parameter C<TABLE_CAT> is ignored as
a selection criterion.
Search patterns are supported for C<TABLE_SCHEM> and C<TABLE_NAME>.
C<TABLE_TYPE> may contain a comma-separated list of table types.
The following table types are supported: C<TABLE, VIEW, RESULT, SYNONYM,
SEQUENCE>
The result set is ordered by C<TABLE_TYPE, TABLE_SCHEM, TABLE_NAME>.
=item C<tables()>
Supported by the driver as proposed by DBI. Since MaxDB does not support
catalogs so far the parameter C<TABLE_CAT> is ignored as a selection criterion.
=item C<primary_key_info()>
Supported by the driver as proposed by DBI. Since MaxDB does not support
catalogs so far the parameter C<TABLE_CAT> is ignored as a selection criterion and
the C<TABLE_CAT> field of a fetched row is always C<NULL>.
=item C<foreign_key_info()>
Supported by the driver as proposed by DBI. Since MaxDB does not support
catalogs so far the parameter C<TABLE_CAT> is ignored as a selection criterion and
the C<TABLE_CAT> field of a fetched row is always C<NULL>.
=item C<column_info()>
Supported by the driver as proposed by DBI. Since MaxDB does not support
catalogs so far the parameter C<TABLE_CAT> is ignored as a selection criterion and
the C<TABLE_CAT> field of a fetched row is always C<NULL>.
=back
=head1 SPECIAL FEATURES
=head2 Binding of default values as parameter
The driver supports to bind a special default parameter C<$DBD::MaxDB::DEFAULT_PARAMETER>
to set the default value as parameter of a prepared statement.
use DBI;
$dbh->do("CREATE TABLE defaultvalues (ID INT NOT NULL DEFAULT 42)")
or die "Can't create table $DBI::err $DBI::errstr\n";
$sth = $dbh->prepare("INSERT INTO defaultvalues (ID) values (?)")
or die "Can't prepare statement $DBI::err $DBI::errstr\n";
$res = $sth->execute($DBD::MaxDB::DEFAULT_PARAMETER)
or die "Can't execute statement $DBI::err $DBI::errstr\n";
...
=head1 UNICODE
DBD::MaxDB supports Unicode. Perl's internal unicode format is UTF-8
but MaxDB uses UCS-2. Therefor the support is limited to UTF-8 characters
that also contained in the UCS-2 standard.
=head2 Perl and Unicode
Perl began implementing Unicode with version 5.6. But if you plan to use Unicode
it is strongly recomended to use perl 5.8.2 or later. Details about using
unicode in perl can you find in the perl documentation:
perldoc perluniintro
perldoc perlunicode
=head2 MaxDB and Unicode
MaxDB supports the code attribute Unicode for the data type CHAR and is able to
display various presentation codes in Unicode format. As well as storing data in Unicode,
you can also store the names of database objects (for example, table or column names) in
Unicode and display these with the database tools in the desired presentation code.
= head2 Installing a Unicode-Enabled Database
You can govern whether or not a database instance should be Unicode-enabled when you create it.
To do this, set the parameter _UNICODE to YES. Please note that you cannot change
the _UNICODE parameter once you have set it. You can also set the systems default value.
If you set the DEFAULT_CODE parameter to Unicode, any columns of type CHAR, VARCHAR, and
LONG for which no other code attribute has been defined, become Unicode columns.
Column definition Result
-------------------------------------------------------
CHAR (n) UNICODE UNICODE column
CHAR (n) UNICODE column
CHAR (n) ASCII ASCII column
CHAR (n) BINARY Binary column
Please note that MaxDB Unicode data is stored internally in UCS-2 format. This,
however, doubles the amount of memory space needed for storing Unicode data to the
database instance.
=head1 INSTALLATION
Please see the README file which comes with the module distribution.
=head1 MAILING LIST SUPPORT
This module is maintained and supported on a web forum,
L<https://forums.sdn.sap.com/forum.jspa?forumID=90&start=0>
Additionally you might try the dbi-user mailing list for questions about
DBI and its modules in general.
=head1 COPYRIGHT
Copyright 2000-2007 by SAP AG
This program is free software; you can redistribute it and/or
modify it under the terms of either the Artistic License, as
specified in the Perl README file or the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=head1 ADDITIONAL INFORMATION
( run in 0.972 second using v1.01-cache-2.11-cpan-39bf76dae61 )