=head1 DBD::Oracle =begin docbook =end docbook =head1 =head2 Version This driver summary is for C version 0.60. =head2 Author and Contact Details The driver author is Tim Bunce. He can be contacted via the I mailing list. =head2 Supported Database Versions and Options The C module supports both Oracle 7 and Oracle 8. Building for Oracle 8 defaults to use the new Oracle 8 OCI interface, which enables use of some Oracle 8 features including LOBs and "INSERT ... RETURNING ...". An emulation module for the old Perl4 oraperl software is supplied with C, making it very easy to upgrade C scripts to Perl5. =head2 Connect Syntax The Cconnect()> Data Source Name, or I, can be one of the following: dbi:Oracle:tnsname dbi:Oracle:sidname dbi:Oracle:T:hostname:sidname There are no driver specific attributes for the Cconnect()> method. =head2 Numeric Data Handling Oracle only has one flexible underlying numeric type, NUMBER. But Oracle does support several ANSI standard and IBM data type names as aliases, including: INTEGER = NUMBER(38) INT = NUMBER(38) SMALLINT = NUMBER(38) DECIMAL(p,s) = NUMBER(p,s) NUMERIC(p,s) = NUMBER(p,s) FLOAT = NUMBER FLOAT(b) = NUMBER(p) where b is the binary precision, 1 to 126 REAL = NUMBER(18) The NUMBER datatype stores positive and negative fixed and floating-point numbers with magnitudes between 1.0 x 10-130 and 9.9...9 x 10125 (38 nines followed by 88 zeroes), with 38 digits of precision. You can specify a fixed-point number using the following form: NUMBER(p,s) where I is the scale, or the number of digits to the right of the decimal point. The scale can range from -84 to 127. You can specify an integer using NUMBER(p). This is a fixed-point number with precision I

and scale 0. This is equivalent to NUMBER(p,0). You can specify a floating-point number using NUMBER. This is a floating-point number with decimal precision 38. A scale value is not applicable for floating-point numbers. C always returns all numbers as strings. Thus the driver puts no restriction on size of PRECISION or SCALE. =head2 String Data Handling Oracle supports the following string data types: VARCHAR2(size) NVARCHAR2(size) CHAR CHAR(size) NCHAR NCHAR(size) RAW(size) The RAW type is presented as hexadecimal characters. The contents are treated as non-character binary data and thus are never "translated" by character set conversions. CHAR types and the RAW type have a limit of 2000 bytes. For VARCHAR types the limit is 2000 bytes in Oracle 7 and 4000 in Oracle 8. The NVARCHAR2 and NCHAR variants hold string values of a defined national character set (Oracle 8 only). For those types the maximum number of characters stored may be lower when using multibyte character sets. The CHAR and NCHAR types are fixed length and blank padded. Oracle automatically converts character data between the character set of the database defined when the database was created and the character set of the client, defined by the NLS_LANG parameter for the CHAR and VARCHAR2 types or the NLS_NCHAR parameter for the NCHAR and NVARCHAR2 types. I can be used to convert strings between character sets. Oracle 8 supports 180 storage character sets. UTF-8 is supported. See the National Language Support section of the Oracle Reference manual for more details on character set issues. Strings can be concatenated using either the C<||> operator or the C SQL function. =head2 Date Data Handling Oracle supports one flexible date/time data type: DATE. A DATE can have any value from January 1, 4712 BC to December 31, 4712 AD with a one second resolution. Oracle supports a very wide range of date formats and can use one of several calendars (Arabic Hijrah, English Hijrah, Gregorian, Japanese Imperial, Persian, ROC Official (Republic of China) and Thai Buddha). We'll only consider the Gregorian calendar here. The default output format for the DATE type is defined by the NLS_DATE_FORMAT configuration parameter, but it's typically C, I, 20-FEB-99 in most western installations. The default input format for the DATE type is the same as the output format. Only that one format is recognised. If you specify a DATE value without a time component, the default time is 00:00:00 (midnight). If you specify a DATE value without a date, the default date is the first day of the current month. If a date format that has a two digit year, such as the C in C (a common default) then the date returned is always in the current century. The C format can be used instead to provide a 50 year pivot. The default date format is specified either explicitly with the initialization parameter NLS_DATE_FORMAT or implicitly with the initialization parameter NLS_TERRITORY. For information on these parameters, see Oracle8 Referencee. You can change the default date format for your session with the "ALTER SESSION" command. For example: ALTER SESSION SET NLS_DATE_FORMAT='MM/DD/YYYY' The C function can be used to parse a character string containg a date in a known format. For example: UPDATE table SET date_field=TO_DATE('1999-02-21', 'YYYY-MM-DD') The C function can be used to format a date. For example: SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') FROM DUAL The current datetime is returned by the C function. You can add numbers to DATE values. The number is interpreted as numbers of days; for example, C is this time tomorrow, and C is three minutes ago. You can subtract two dates to find the difference, in days, between them. Oracle provides a wide range of date functions including C, C, C, C, C (of the month), and C. The following SQL expression can be used to convert an integer "seconds since 1-jan-1970 GMT" value to the corresponding database date time: to_date(trunc(:unixtime/86400, 0) + 2440588, 'J') -- date part +(mod(:unixtime,86400)/86400) -- time part To do the reverse you can use: (date_time_field - TO_DATE('01-01-1970','DD-MM-YYYY')) * 86400 Oracle does no automatic time zone adjustments. However it does provide a C function that calculates time zone adjustments for a range of time zones. C returns the date and time in time zone I when the date and time in time zone I are represented by I. =head2 LONG/BLOB Data Handling Oracle supports these LONG/BLOB data types: LONG - Character data of variable length LONG RAW - Raw binary data of variable length CLOB - A large object containing single-byte characters NCLOB - A large object containing national character set data BLOB - Binary large object BFILE - Locator for external large binary file The LONG types can hold upto 2 gigabytes. The other types (LOB and FILE) can hold upto 4 gigabytes. The LOB and FILE types are only available when using Oracle 8 OCI. The LONG RAW, and RAW, types are passed to and from the database as strings consisting of pairs of hex digits. The I and I attributes work as defined. However, the LongReadLen attribute seems to be limited to 65535 bytes on most platforms when using Oracle 7. Building C with Oracle 8 OCI raises that limit to 4 gigabytes. The maximum length of C parameter value that can be used to insert LONG data seems to be limited to 65535 bytes on most platforms when using Oracle 7. Building C with Oracle 8 OCI raises that limit to 4 gigabytes. The TYPE attribute value SQL_LONGVARCHAR indicates an Oracle LONG type. The value SQL_LONGVARBINARY indicates an Oracle LONG RAW type. These values are not always required but their use is strongly recommended. No other special handling is required for LONG/BLOB data types. They can be treated just like any other field when fetching or inserting etc. =head2 Other Data Handling issues The C driver supports the C method. Oracle supports automatic conversions between data types wherever it's reasonable. =head2 Transactions, Isolation and Locking C supports transactions. The default transaction isolation level is 'Read Commited'. Oracle supports READ COMMITED and SERIALIZABLE isolation levels. The level be changed per-transaction by executing a C statement (where I is the name of the isolation level required). Oracle also supports transaction-level read consistency. This can be enabled by issuing a SET TRANSACTION statement with the READ ONLY option. In Oracle, the default behavior is that a lock never prevents other users from querying the table. A query never places a lock on a table. Readers never block writers and writers never block readers. Rows returned by a SELECT statement can be locked to prevent them from being changed by another transaction by appending C to the select statement. Optionally, you can specify a column list in parentheses after the FOR UPDATE clause. The C statement can be used to apply an explicit lock on an entire table. A range of row and table locks are supported. =head2 No-Table Expression Select Syntax To select a constant expression, that is, an expression that doesn't involve data from a database table or view, you can select from the DUAL table. For example, C