NAME
DBD::MaxDB - MaxDB database driver for the DBI module version 7.7.5 BUILD 000-000-000-000
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 DBI module documentation for full details.
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: https://www.sdn.sap.com/irj/sdn/maxdb
MODULE DOCUMENTATION
This section describes the driver specific behavior and restrictions. It does not describe the DBI interface in general. For this purpose please consult the DBI documentation.
Connect
To connect to a database with a minimum of parameters, use the following syntax:
$dbh = DBI->connect($url, $user, $password);
The URL contains the name of the database instance, and, if you are connecting to a remote computer, the name of this computer. Additionally the URL may contain some other connection options described below.
- Define the connection URL
-
Use the following format:
dbi:MaxDB:/<database_server>[:<port>]/<database_name>[?<options>]
Parameter Description ---------------------------------------------------- <database_server> Name of the database computer (default localhost) <port> Socket port to which you want to connect. Specify this port only if the X Server (MaxDB remote communication server) has been configured with a port that is not the system default port. <database_name> Name of the database instance <options> See the following section Connection Options
- Connection Options
-
You can use connection options to define the properties of a database instance connection. You can specify these options as part of the connection URL. In this case, you must specify them with the following format:
<name>=<value>[&<name>=<value>...]
You can define the following options:
Option Description ------------------------------------------------------- user Name of the database user password User password sqlmode SQL mode, possible values are ORACLE | INTERNAL.The system default is INTERNAL. timeout Command timeout of the connection (in seconds) isolationlevel Isolation level of the connection statementcachesize The number of prepared statements to be cached for the connection for re-use. Possible values are: <n>: desired number of statements, 0: no statements are cached, UNLIMITED: unlimited number of statements are cached.
- Examples
-
Definition of the parameter url for a connection to the database TST on the computer REMOTESERVER
dbi:MaxDB:REMOTESERVER/TST
Definition of the parameter url for a connection to the database TST on the remote computer REMOTESERVER using the port 7673. (This definition requires the X Server to be configured with the same port.)
dbi:MaxDB:servermachine:7673/TST
Definition of the parameter url for a connection to the database TST on the local computer
dbi:MaxDB:TST
Definition of the parameter url for a connection to the database TST on the local computer; the SQL mode is ORACLE and a command timeout of 120 seconds is defined:
dbi:MaxDB:TST?sqlmode=ORACLE&timeout=120
Datasources
@data_sources = DBI->data_sources('MaxDB');
The driver supports this method. Note that only data sources on the local computer will be listed.
Error messages
In case of an error the driver returns an error code, an error text and if appropriate an error state. Details concerning the meaning of an error can be found in the database messages reference at http://maxdb.sap.com/documentation/
$errcode = $h->err;
Returns the error code.
$errstr = $h->errstr;
Returns the error text.
$sqlstate = $h->state;
Returns the sql state.
DBI HANDLE ATTRIBUTES
Example:
... = $h->{<attribute>}; # get/read
$h->{<attribute>} = <value> ; # set/write
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.
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
CHAR/VARCHAR
columns.
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.
maxdb_isolationlevel (integer)
-
Gets/Sets the isolation level of the current connection.
maxdb_kernelversion (string, read-only)
-
Gets the version of the database instance used at the current connection.
maxdb_sdkversion (string, read-only)
-
Gets the version of the MaxDB SQLDBC software development kit used by the driver.
maxdb_sqlmode (string)
-
Gets/Sets the SQL mode of the current connection. Possible values are
ORACLE | INTERNAL
. maxdb_unicode (boolean, read-only)
-
Indicates whether the current connection supports unicode (true) or not (false)
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.
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.
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.
maxdb_resultsetconcurrency (string)
-
Gets/Sets the type of the result set concurrency. There are two kinds of concurrency:
CONCUR_UPDATABLE
-
The result set can be updated.
CONCUR_READ_ONLY
-
The result set is read-only.
The default setting for the concurrency is
CONCUR_READ_ONLY
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:
FORWARD_ONLY
-
The result set can only be scrolled forward.
SCROLL_SENSITIVE
-
The result set is scrollable but may change.
SCROLL_INSENSITIVE
-
The result set is scrollable and not change.
The default for the result set type is
SCROLL_INSENSITIVE
maxdb_rowsaffected (integer, read-only)
-
Returns the number of rows affected by the executed SQL statement. This method returns a non-zero value if more than one row was addressed by the SQL statement. If the return value is lower than zero, more than one rows was addressed but the exact number of addressed rows cannot be determined.
maxdb_tablename (integer, read-only)
-
Retrieves the table name (for
SELECT FOR UPDATE
commands only).
METADATA SUPPORT
get_info()
andtype_info_all()
-
Supported by the driver as proposed by DBI.
table_info()
-
The driver supports parameters for
table_info()
. Currently is in MaxDB (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
TABLE_CAT
is ignored as a selection criterion.Search patterns are supported for
TABLE_SCHEM
andTABLE_NAME
.TABLE_TYPE
may contain a comma-separated list of table types. The following table types are supported:TABLE, VIEW, RESULT, SYNONYM, SEQUENCE
The result set is ordered by
TABLE_TYPE, TABLE_SCHEM, TABLE_NAME
. tables()
-
Supported by the driver as proposed by DBI. Since MaxDB does not support catalogs so far the parameter
TABLE_CAT
is ignored as a selection criterion. primary_key_info()
-
Supported by the driver as proposed by DBI. Since MaxDB does not support catalogs so far the parameter
TABLE_CAT
is ignored as a selection criterion and theTABLE_CAT
field of a fetched row is alwaysNULL
. foreign_key_info()
-
Supported by the driver as proposed by DBI. Since MaxDB does not support catalogs so far the parameter
TABLE_CAT
is ignored as a selection criterion and theTABLE_CAT
field of a fetched row is alwaysNULL
. column_info()
-
Supported by the driver as proposed by DBI. Since MaxDB does not support catalogs so far the parameter
TABLE_CAT
is ignored as a selection criterion and theTABLE_CAT
field of a fetched row is alwaysNULL
.
SPECIAL FEATURES
Binding of default values as parameter
The driver supports to bind a special default parameter $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";
...
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.
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
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 system’s 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.
INSTALLATION
Please see the README file which comes with the module distribution.
MAILING LIST SUPPORT
This module is maintained and supported on a web forum,
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.
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.
ADDITIONAL INFORMATION
Additional information on the DBI project can be found at the following URL:
where documentation, links to the mailing lists and mailing list archives and links to the most current versions of the modules can be used.
Information on the DBI interface itself can be gained by typing:
perldoc DBI
Information on the MaxDB database can be found on the WWW at
https://www.sdn.sap.com/irj/sdn/maxdb
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 832:
Non-ASCII character seen before =encoding in 'system’s'. Assuming CP1252