Oracle® Transparent Gateway for DB2 Installation and User's Guide 10g Release 2 (10.2) for IBM z/OS (OS/390) Part Number B16220-02 |
|
|
View PDF |
Oracle Transparent Gateway for DB2 allows applications written for the Oracle database server to access tables in a DB2 database. Using a database link, the access can be made transparent by using synonyms or views of the DB2 tables. However, there are fundamental SQL, data type, and semantic differences between the Oracle database server and the DB2 database. Read this chapter to learn these differences and for information about developing applications.
This chapter includes the following sections:
An application written to access information in a DB2 database interfaces with an Oracle database server. When developing applications, remember the following:
You must define the DB2 database to the application by use of a database link. Your application specifies tables existing on a DB2 database using the name defined in the database link. For example, if you define a database link naming the DB2 database link DB2, and an application needs to retrieve data from an Oracle database server and the DB2 database, then the following SQL statement retrieves data from both Oracle and DB2:
SELECT EMP.EMPNO, EMPS.SALARY FROM EMP, EMPS@DB2 WHERE EMP.EMPNO = EMPS.EMPNO;
In this example, EMP
is a table on the Oracle database server and EMPS
is a table on the DB2 server. Alternatively, you can define a synonym or a view on the DB2 server table and access the information without the database link suffix.
You can perform reads and writes of data to a defined DB2 database. SELECT
, INSERT
, UPDATE
, and DELETE
are all valid operations.
A single transaction can write to one DB2 database and to multiple Oracle database servers.
Single SQL statements, using a JOIN
, can refer to tables in multiple Oracle database servers, multiple DB2 databases, or both.
When evaluating and tuning the gateway configuration, you can achieve performance gains by using the Oracle array processing interface. An array is a collection of data items, called elements, associated with a single variable. With arrays, you can use a single SQL statement to manipulate an entire collection of data items. For example, suppose you want to insert information regarding 100 employees into the EMP
table on DB2. Without arrays, your program must do 100 individual INSERT
s—one for each employee. With arrays, only one INSERT
is necessary.
The use of array processing reduces network calls, which can save elapsed time and CPU cycles. In addition, when using INSERT
for multiple rows, DB2 processing is optimized by retaining the original SQL statement for repeated running.
You can set the array size between the client and the gateway by using your Oracle application implementation for UPDATE
, DELETE
, and INSERT
.
For more information about array processing usage and implementation in your Oracle application, refer to the SQL*Plus User's Guide and Reference or the Oracle Call Interface Programmer's Guide.
Note:
For performance reasons, Oracle Corporation recommends setting the initial Oracle application array size between 10 and 100.The Oracle database server supports fetch reblocking with the HS_RPC_FETCH_REBLOCKING
parameter.
When the value of this parameter is set to ON
(the default), the array size for SELECT
statements is determined by the HS_RPC_FETCH_SIZE
value. The HS_RPC_FETCH_SIZE
parameter defines the number of bytes sent with each buffer from the gateway to the Oracle database server. The buffer might contain one or more qualified rows from DB2. This feature can provide significant performance enhancements, depending on the application design, installation type, and workload.
The array size between the client and the Oracle database server is still determined by the Oracle application.
The gateway stored procedure support is an extension of Oracle stored procedures. An Oracle stored procedure is a schema object that logically groups a set of SQL and other PL/SQL programming language statements together to perform a specific task. Oracle stored procedures are stored in the database for continued use. Applications use standard Oracle PL/SQL to call stored procedures.
Oracle stored procedures can be located in a local instance of the Oracle database server and a remote instance. The following example shows two stored procedures: oraproc1
is a procedure stored in the ORA1
Oracle instance, while oraproc2
is a procedure stored in the ORA2
Oracle instance.
To maintain location transparency in the application, a synonym can be created:
CREATE SYNONYM oraproc2 FOR oraproc2@ora2;
After this synonym is created, the application no longer needs to use the database link specification to call the stored procedure at the remote Oracle instance.
The second statement in oraproc1
is used to access a table in the ORA2 instance. In the same way, Oracle stored procedures can be used to access DB2 tables through the gateway.
empproc
is an Oracle stored procedure, which subsequently accesses data in DB2 using the gateway:
Like the Oracle database server, standard PL/SQL is used to create and run the procedure. There is no difference with the gateways except that the stored procedure is accessing DB2 instead of the Oracle database server.
Gateway two-phase commit processing also applies to updates to DB2 being made within an Oracle stored procedure. This means the stored procedure can update a single instance of DB2 while also updating any number of Oracle database servers within a single transaction.
The procedural feature of the gateway enables execution of native DB2 stored procedures. In other words, the stored procedure is no longer defined in the Oracle database server, but instead, is defined to DB2. Again, standard Oracle PL/SQL is used by the Oracle application to run the DB2 stored procedure.
The gateway does not require special definitions to call the DB2 stored procedure. Once the stored procedure is defined to DB2, the gateway is able to use the existing DB2 definition to run the procedure.
An Oracle application calls the empproc
stored procedure that is defined to DB2.
From the perspective of the application, running the DB2 stored procedure is no different than invoking a stored procedure at a remote Oracle instance.
In order for an Oracle application to call a DB2 stored procedure, it is first necessary to create the DB2 stored procedure on the DB2 system using the procedures found in the IBM documents for your platform and operating system.
After the stored procedure is defined to DB2, the gateway is able to access the data using a standard PL/SQL call. For example, an employee name, JOHN SMYTHE, is passed to the DB2 stored procedure REVISE_SALARY. The DB2 stored procedure retrieves the salary value from the DB2 database to calculate a new yearly salary for JOHN SMYTHE
. The revised salary returned in RESULT
is used to update the EMP
table of an Oracle database server:
DECLARE INPUT VARCHAR2(15); RESULT NUMBER(8,2); BEGIN INPUT := 'JOHN SMYTHE'; SYSPROC.REVISE_SALARY@DB2(INPUT, RESULT); UPDATE EMP SET SAL = RESULT WHERE ENAME = INPUT; END;
When running a DB2 stored procedure, a two-part procedure name is sent to DB2 through the gateway. If no qualifier is used in the Oracle application to call the stored procedure, then the userid passed over the database link, or PUBLIC
, is used as the qualifier for the procedure name.
DB2 stored procedures migrated from DB2 V5.1 require that SYSPROC
must be the first qualifier of a stored procedure name. Therefore, the application must ensure SYSPROC
is used as the qualifier for the DB2 stored procedure. One way to do this is to explicitly qualify the procedure name:
BEGIN SYSPROC.PROC1(parm1) END
DB2 stored procedures for DB2 V6.1 and subsequent allows stored procedures to be qualified by schema name other than SYSPROC
.
The following are special considerations for using the procedural feature with the gateway:
DB2 stored procedures do not have the ability to coordinate, commit, and rollback activity on recoverable resources such as IMS or CICS transactions. Therefore, if the DB2 stored procedure calls a CICS or IMS transaction, then it is considered a separate unit of work and does not affect the completion of the stored procedure. This means that if you are running a DB2 stored procedure from an Oracle application and this procedure calls a CICS or IMS transaction, then the gateway cannot recover from any activity that occurred within the CICS or IMS transaction.
For example, the CICS transaction could rollback a unit of work, but this does not prevent the gateway from committing other DB2 work contained within the DB2 stored procedure.
Likewise, if the DB2 stored procedure updated an irrecoverable resource such as a VSAM file, then the gateway considers this activity separate from its own recoverable unit of work.
When running DB2 stored procedures containing DB2 SQL, you must have the collection ID of the DB2 package specified in the CREATE PROCEDURE
. If this was not initially specified, an ALTER PROCEDURE
can be done to add this.
This is required because the DB2 plan for the gateway must identify the packages for the DB2 stored procedures it runs. The default DB2 bind JCL, delivered with the gateway, uses *.*
to identify the package list for the gateway. When this is specified, DB2 identifies the collection ID of the DB2 stored procedure as the one specified in the COLLID
column of the DB2 stored procedure entry in the SYSROUTINES
table.
PL/SQL records cannot be passed as parameters when invoking a DB2 stored procedure.
The gateway supports DB2SQL
, GENERAL
and GENERAL
WITH NULLS
linkage conventions of DB2 stored procedures.
The GENERAL
linkage convention means that the parameters passed to and from the DB2 stored procedure cannot be null.
The DB2SQL
and GENERAL WITH NULLS
linkage convention means that the parameters passed to and from the DB2 stored procedure can be null when they are passed using indicator variables.
Embedded PL/SQL or OCI can be used in the host program to operate on indicator variables. Refer to Appendix E, "Sample Applications", for a sample DB2 stored procedure and PL/SQL program using the GENERAL
WITH NULLS
linkage convention.
The passthrough SQL feature allows an application developer to send a SQL statement directly to DB2 without the statement being interpreted by the Oracle database server. The DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE SQL
passthrough statements supported by the gateway are limited to nonqueries (INSERT
, UPDATE
, DELETE
, and DDL
statements) and cannot contain bind variables. The gateway can run native DB2 SQL statements by using DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
.
DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
is a built-in gateway function. This function receives one input argument and returns the number of rows affected by the SQL statement. For DDL statements, the function returns zero.
DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
is the reserved name of the gateway and are used specifically for running native DB2 SQL.
This release of Oracle Transparent Gateway for DB2 enables retrieval of result sets from queries issued with passthrough. The syntax is different from the DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
function. Refer to "Retrieving Result Sets Through Passthrough" for more information.
To run a passthrough SQL statement using DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
, use the following syntax:
number_of_rows = DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@dblink ('native_DB2_sql');
where:
Insert a row into a DB2 table using DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
:
DECLARE num_rows integer; BEGIN num_rows:=DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@dblink ('INSERT INTO SCOTT.DEPT VALUES (10,''PURCHASING'',''PHOENIX'')'); END; /
Create a table in DB2 using DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE
:
DECLARE num_rows integer; BEGIN num_rows:=DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@dblink ('CREATE TABLE MYTABLE (COL1 INTEGER, COL2 INTEGER, COL3 CHAR(14), COL4 VARCHAR(13))'); END; /
Oracle Transparent Gateway for DB2 provides a facility to retrieve results sets from a SELECT
SQL statement entered through passthrough. Refer to the Oracle Database Heterogeneous Connectivity Administrator's Guide for additional information.
DECLARE CRS binary_integer; RET binary_integer; VAL VARCHAR2(10) BEGIN CRS:=DBMS_HS_PASSTHROUGH.OPEN_CURSOR@gtwlink; DBMS_HS_PASSTHROUGH.PARSE@gtwlink(CRS,'SELECT NAME FROM PT_TABLE'); BEGIN RET:=0; WHILE (TRUE) LOOP RET:=DBMS_HS_PASSTHROUGH.FETCH_ROW@gtwlink (CRS,FALSE); DBMS_HS_PASSTHROUGH.GET_VALUES@gtwlink (CRS,1,VAL); INSERT INTO PT_TABLE_LOCAL VALUES (VAL); END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN BEGIN DBMS_OUTPUT.PUT_LINE('END OF FETCH'); DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@gtwlink(CRS); END; END; END; /
To move data between applications and the underlying database, the gateway maps data values from a host variable or literal of a specific data type to a data type understood by the underlying database.
Oracle tools and applications expect Oracle data types. Consequently, the gateway maps values from DB2 servers into appropriate Oracle data types before passing these values back to the application or Oracle tool. The data type mapping and restrictions are:
DB2 Server | Oracle External | Criteria |
---|---|---|
CHAR(N) |
CHAR(N) |
N=<255* |
VARCHAR(N) |
VARCHAR2(N) LONG |
N=<4000 (refer to Note 1) 4000<N<DB2 maximum long value |
LONG VARCHAR(N) |
VARCHAR2(N) LONG |
N=<4000 (refer to Note 1) 4000<N<DB2 maximum long value |
CHAR(N) FOR BIT DATA |
RAW(N) |
N=<255 (refer to Note 2) |
VARCHAR(N) FOR BIT DATA |
RAW(N) LONG RAW(N) |
1=<N=<2000 (refer to Note 1) 2000<N=<DB2 maximum long value |
LONG VARCHAR(N) FOR BIT DATA |
RAW(N) LONG RAW(N) |
1=<N=<2000 (refer to Note 1) 2000<N=<DB2 maximum long value |
DATE |
DATE |
Refer to "Performing Date and Time Operations" |
TIME |
CHAR(8) |
Refer to "Performing Date and Time Operations" |
TIMESTAMP |
CHAR(26) |
Refer to "Performing Date and Time Operations" |
TIMESTAMP |
TIMESTAMP(6) |
Based on the ORACLE_TIMESTAMP environment variable.
|
GRAPHIC (N) |
CHAR(2N) |
N<127 |
VARGRAPHIC (N) |
VARCHAR(2N) |
N<2000 |
LONG VARGRAPHIC (N) |
VARCHAR2(2N) |
2000<N<DB2 maximum long value |
FLOAT(N) (single) |
FLOAT(21) |
1=<N=<21 |
FLOAT(N) (double) |
FLOAT(53) |
22=<N=<53 |
Decimal(P,S) |
NUMBER(P,S) |
n/a |
INTEGER |
NUMBER(10) |
n/a |
SMALLINT |
NUMBER(5) |
n/a |
ROWID |
RAW(40) |
|
BLOB |
LONG RAW |
|
CLOB |
LONG |
|
DBCLOB |
LONG |
Note:
Also, the Oracle database server can support a length of up to 2000 fixed character columns, but the maximum for DB2 is 255.
The Oracle Database 10g database server allows only one LONG
column per table. This might allow for a situation where a DB2 table cannot be directly replicated as an Oracle table.
To determine DB2 maximum long values, refer to the IBM documents for your platform and operating system.
In certain cases, the equivalent Oracle CHAR
, VARCHAR
or LONG
columns will be different lengths than the original DB2 columns. This is due to character set differences that require more (or fewer) bytes in the Oracle representation than in the original DB2 representation.
In the most common case, the Oracle character set Unicode AL32UTF8
uses 1, 2 or 3 bytes to represent one character. If the DB2 column is single-byte EBCDIC
and defined as CHAR(10)
, it shows up through the gateway as CHAR(30)
. This is required because each EBCDIC
character (which only takes 1 byte in the single-byte EBCDIC
character set) may require 1, 2 or 3 bytes to represent the character in Unicode AL32UTF8
.
Some character sets will double the length of the original DB2 character columns, some will triple it. If the Oracle database is running in a single-byte ASCII character set, the length will always be the same in DB2 and Oracle, with one exception.
In the case of Oracle running in a single byte character set (like US7ASCII
or WE8ISO8859P1
) and DB2 GRAPHIC
columns (which use two bytes to represent each character), the size of the Oracle character column will be half the size of the original DB2 GRAPHIC
column.
Other character sets (like Unicode) will cause DB2 GRAPHIC
columns to require more bytes than the original DB2 columns.
Frequently, DB2 databases are designed to hold non-character binary data in character columns. Applications run on DB2 systems can store and retrieve data as though it contained character data. However, when an application accessing this data runs in an environment using a different character set, inaccurate data might be returned.
When character data is sent to DB2 from an ASCII system, ASCII data is translated to EBCDIC
. This translation is meaningless when the characters are binary data in a character column. The application receives incorrect information or errors.
To resolve these errors, the gateway requires character columns on DB2 holding non-character data be created with the FOR BIT DATA
option. In the application, the character columns holding non-character data can be processed using the Oracle data types RAW
and LONG RAW
. The DESCRIBE
information for a character column defined with FOR BIT DATA
on the host always indicates RAW
or LONG
RAW
.
Existing DB2 tables can be changed by directly updating the DB2 catalog.
For more information about DB2 parameters, refer to the IBM documents for your platform and operating system.
The DB2 VARCHAR
data type can be from one to the maximum long value for DB2. This data type is converted to an Oracle VARCHAR2
data type if it is between 1 and 4000 characters in length. If character length is between 4000 and the maximum long value for DB2, then it is converted to an Oracle LONG
data type.
For additional information about determining the maximum long value for DB2, refer to the IBM documents for your platform and operating system.
The Oracle LONG
data type can be from 1 to 2 G in length, but the DB2 VARCHAR
data type can be no longer than 32 740 bytes. If you define a LONG
data type longer than 32 740 bytes in length, then you receive an error message.
The implementation of date and time data differs significantly in DB2 databases and the Oracle database server. The Oracle database server has a single date data type, DATE
, containing both calendar date and time of day information. DB2 databases support the following three distinct date and time data types:
There is no built-in mechanism that translates the IBM TIME
and TIMESTAMP
data to Oracle DATE
data. An application must process TIME
data types in the Oracle CHAR
format with a length of eight bytes. An application must process the TIMESTAMP
data type in the Oracle CHAR
format with a length of 26 bytes.
An application reads TIME
and TIMESTAMP
columns as character strings and converts or subsets portions of the string to perform numerical operations. TIME
and TIMESTAMP
values can be sent to a DB2 database as character literals or bind variables of the appropriate length and format.
Oracle and IBM DATE
data types are mapped to each other. If an IBM DATE
is queried, then it is converted to an Oracle DATE
with a zero (midnight) time of day. If an Oracle DATE
is processed against an IBM DATE
column, then the date value is converted to the IBM DATE
format and any time value is discarded.
Character representations of dates are different in the Oracle database server format and DB2 format. When an Oracle application SQL statement contains a date literal or conveys a date using a character bind variable, the gateway must convert the date to a DB2-compatible format.
Oracle Transparent Gateway for DB2 includes a DB2 local date exit. The exit is called only when needed and does not interfere with normal DB2 operations or impact performance. With the exit installed, DB2 DATE
columns are handled through the gateway. If you do not install the exit, then Oracle SQL requires changes when referencing DB2 DATE
columns.
When a string constant, string bind variable, string expression, or character column is compared or assigned to a DB2 date column, it is converted from its string format to an internal DB2 format before DB2 processes it. DB2 date conversion routines look for the following formats of date string. The DB2 local date exit is called only if the date string does not match any of the standard formats.
DB2 Date Format | Pattern | Example |
---|---|---|
EUR |
DD.MM.YYYY | 30.10.1994 |
ISO |
YYYY-MM-DD | 1994-10-30 |
JIS |
YYYY-MM-DD | 1994-10-30 |
LOCAL |
DD-MON-YY | 30-OCT-94 |
LOCAL |
DD-MON-RR | 29-MAR-05 |
USA |
MM/DD/YYYY | 10/30/1994 |
The LOCAL
DB2 date format is available when the gateway local date exit is installed.
The local exit is called only if the date format cannot be matched to ISO, JIS, USA, or EUR formats. In a native DB2 program, this is frequently due to a bad date string value. If a bad date string value is entered, then the DB2 local date exit is called and rejects the bad date string.
The DB2 local date exit is called in the following circumstances:
A native DB2 program has a bad date string value that cannot be matched to ISO, JIS, USA, or EUR formats.
A gateway program supplies one of the Oracle DATE formats, 'DD-MON-YY' or 'DD-MON-RR'.
When you install the DB2 local date exit (DSNXVDTX) supplied with the gateway, you can use ISO, JIS, USA, and EUR as well as the Oracle date formats 'DD-MON-YY', 'DD-MON-YYYY', and 'DD-MON-RR' through the gateway. The DB2 local date exit must be installed in order to specify these Oracle date formats without any SQL changes. If you do not install the exit, then you must use the Oracle TO_DATE
function to pass these Oracle date formats through the gateway. Refer to "Step 4: Make Authorization and Local Date Exits Available to DB2" on page 5-28 for further information.
If the gateway local date exit is installed on the DB2 system, then DB2 DATE
columns appear as Oracle DATE
columns through the gateway. Normal Oracle DATE
processing and string values can be used. DB2 DATE
columns are handled as Oracle DATE
columns.
If the gateway's DB2 local date exit is not installed, then most SQL statements referencing DB2 DATE
columns require changes. When a string constant or string bind variable is compared or assigned to a DB2 DATE
column, a TO_DATE
function must be added to the statement, enclosing the constant or bind variable.
When the DB2 local date exit is installed, the following SQL statements are accepted:
INSERT INTO EMP (HIREDATE) VALUES ('30-OCT-94'); SELECT * FROM EMP WHERE HIREDATE = '30-OCT-94'; UPDATE EMP SET HIREDATE = '31-OCT-94' WHERE HIREDATE = '30-OCT-94'; DELETE FROM EMP WHERE HIREDATE = '31-OCT-94';
If the DB2 local date exit is not installed, then the following SQL statements are required:
INSERT INTO EMP (HIREDATE) VALUES (TO_DATE('30-OCT-94')); SELECT * FROM EMP WHERE HIREDATE = TO_DATE('30-OCT-94'); UPDATE EMP SET HIREDATE = TO_DATE('31-OCT-94') WHERE HIREDATE = TO_DATE('30-OCT-94'); DELETE FROM EMP WHERE HIREDATE = TO_DATE('31-OCT-94');
The following patterns can be used for the NLS_DATE_FORMAT
:
DB2 Date Format | Pattern | Example |
---|---|---|
EUR | DD.MM.YYYY | 30.10.1994 |
ISO | YYYY-MM-DD | 1994-10-30 |
JIS | YYYY-MM-DD | 1994-10-30 |
USA | MM/DD/YYYY | 10/30/1994 |
The Oracle default format of 'DD-MON-YY' is not allowed with DB2. As a result, the gateway local date exit is provided to change the Oracle default date format of 'DD-MON-YY' or 'DD-MON-RR' to the DB2 ISO format of 'YYYY-MM-DD' before passing the date to DB2.
The following example demonstrates the most efficient way to enter and select date values in the twenty-first century:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; INSERT INTO EMP (HIREDATE) VALUES ('2008-07-23'); SELECT * FROM EMP WHERE HIREDATE = '2008-07-23'; UPDATE EMP SET HIREDATE = '2008-07-24' WHERE HIREDATE = '2008-07-23'; DELETE FROM EMP WHERE HIREDATE = '2008-07-24';
The Oracle TO_DATE
function is preprocessed in SQL INSERT
, UPDATE
, DELETE
, and SELECT
WHERE
clauses. TO_DATE
functions in SELECT
result lists are not preprocessed.
The TO_DATE
function is often needed to provide values to update or compare with date columns. Therefore, the gateway replaces the information included in the TO_DATE
clause with an acceptable value before the SQL statement is sent to DB2.
Except for the SELECT
result list, all TO_DATE
functions are preprocessed and turned into values that are the result of the TO_DATE
function with one exception. If TO_DATE(column)
is coded, then it is always post-processed by Oracle because DB2 doesn't have a TO_DATE
function like Oracle's.
All forms of the TO_DATE
function (with one, two, or three operands) are supported.
The following SQL expression forms do not work correctly with the gateway:
date + number number + date date - number date1 - date2
The date and number addition and subtraction (date + number
, number + date
, date - number
) forms are sent through to the DB2 server where they are rejected. The supported servers do not allow number addition or subtraction with dates. Because of differing interpretations of date subtraction in the supported servers, subtracting two dates (date1 - date2
) does not work correctly when postprocessed by the integrating server.
Note:
Oracle recommends avoiding date arithmetic expressions in all gateway SQL statements.DB2 servers perform automatic conversions to the numeric data type of the destination column (such as integer, double-precision floating point, or decimal). You have no control over data type conversion, and this conversion might be independent of the data type of the destination column in the database.
For example, if PRICE
is an integer column of the PRODUCT
table in a DB2 database, then the update shown in the following example inaccurately sets the price of an ice cream cone to $1.00 because the DB2 server automatically converts a floating point to an integer:
UPDATE PRODUCT SET PRICE = 1.50 WHERE PRODUCT_NAME = 'ICE CREAM CONE ';
Because PRICE
is an integer, the DB2 server automatically converts the decimal data value of 1.50 to 1.
DB2 does not have a column equivalent to the Oracle ROWID
column. Because the ROWID
column is not supported, these restrictions apply:
UPDATE
and DELETE
are not supported with the WHERE CURRENT OF CURSOR
clause.
When these statements are used in precompiler and PL/SQL programs, they rely internally on the Oracle ROWID
function.
Oracle fast refresh materialized views between the Oracle database server and DB2 are not supported.
Oracle fast refresh materialized views rely internally on the Oracle ROWID
column. However, complete refresh materialized views are supported.
Katakana is not supported in the DB2 GRAPHIC
data type because the data type is double byte only. Katakana is encoded as single byte in IBM code pages 290 and 1027, and Oracle JA16DBCS and JA16EBCDIC930 character sets.
Katakana can be supported in DB2 CHAR
and VARCHAR
data types as mixed data if Oracle client programs and the Oracle database server are linked with NLSRTL release 2.3.4 or later. This uses the correct Katakana translation routines.
CHAR FOR BIT DATA
is fixed length binary data in DB2. In the Oracle database server, CHAR FOR BIT DATA
is converted to RAW
, which is in variable length binary format.
DB2 CHAR
and VARCHAR
for bit data (RAW data types) are supported. Raw data in VALUES
clause, WHERE
clause predicate, or bind variables are treated as hexadecimal digits.
Ensure that your programs:
One of the most important features of the Oracle Open Gateways product family is providing SQL transparency to the user and the application programmer. Foreign data store SQL functions can be categorized into three areas:
SQL functions with the same meaning and results on both the Oracle database server and foreign data stores. Some examples of compatible SQL functions include:
Translated
SQL functions that provide the same functionality but are referenced by a different name at the Oracle database server and the foreign data store. Translated SQL functions include NVL
as an Oracle Database Server Function with the DB2 function of VALUE
.
Advanced SQL functions that are supported by the Oracle database server and that cannot be expressed or recognized by the foreign data store.
SQL compensation in the Oracle Open Gateways enriches the semantics of the native SQL of a remote data source, such as DB2. This important feature of the gateway allows application developers and users to leverage the advanced features of the Oracle database server.
Refer to Appendix D, "Quick Reference to Oracle SQL Functions", for a listing of the Oracle database server functions. For more detailed information, refer to the Oracle Database SQL Reference.
Some gateway postprocessing considerations are explained below.
A SELECT
without the FOR UPDATE
clause can be handled in one of three ways:
If the entire WHERE
clause of the SELECT
statement is acceptable syntax for DB2, then it is given to DB2 to perform.
If part, but not all, of the WHERE
clause of the SELECT
statement uses features not available in DB2, then the WHERE
clause is split between the DB2 system and the Oracle database server.
The portion of the WHERE
clause acceptable for DB2 is sent to DB2. The Oracle database server post processes the results of the DB2 SELECT
and applies the Oracle-specific
WHERE
clause elements. This results in DB2 doing as much of the WHERE clause as possible.
If the entire WHERE clause is not acceptable for DB2, then an unqualified SELECT
(without the WHERE
clause) is sent for DB2, and the Oracle database server postprocesses the entire WHERE
clause.
The Oracle database server postprocesses SELECT
statements without the FOR
UPDATE
clause. Most Oracle SELECT
statements are supported. One exception is the CONNECT BY
clause.
DB2 must process the entire SELECT FOR UPDATE
, INSERT
, UPDATE
, and DELETE
clauses. The Oracle database server cannot postprocess these clauses. Only SQL that is a common subset of the Oracle database server and DB2 SQL can be used with these statements.
The following rules exist for the use of SELECT FOR
UPDATE
, INSERT
, UPDATE
, and DELETE
clauses:
Only Oracle syntax that is also valid for DB2 can be used. For DB2 SQL syntax, refer to the IBM documents for your platform and operating system.
The following Oracle database server functions are supported with all options:
The NOWAIT
option of the FOR UPDATE
clause of the SELECT
statement is not supported.
Please be aware of the following differences between the Oracle Database Server and DB2.
When using the following command from SQL*Plus:
DELETE FROM ABC@dblink
all rows are deleted from a segmented tablespace. However, DB2 occasionally sets the updated rows field to negative 1 (-1) even though more rows are actually deleted. This can cause the result from SQL*Plus to indicate an incorrect number of rows updated.
Oracle bind variables become DB2 parameter markers when used with the gateway. Therefore, the bind variables are subject to the same restrictions as DB2 parameter markers. For example, the following statements are not allowed:
WHERE :x IS NULL WHERE :x = :y
For more information about DB2 parameter marker restrictions, refer to the IBM documents for your platform and operating system.
The gateway can optionally augment the DB2 database catalogs with data dictionary views modeled after the Oracle data dictionary. These views are based on the dictionary tables in the DB2 database, presenting the catalog information in views familiar to Oracle users. The views created during the installation of the gateway automatically limit the data dictionary information presented to each user based on the privileges of that user.
The gateway data dictionary views provide the gateway users with an interface (that looks like an Oracle database server interface) to the contents and use of the DB2 database. Some of these views are required by Oracle products.
You can query the gateway data dictionary views to look at the objects in the DB2 database and to determine the authorized users of the DB2 database.
All Oracle DB2 catalog views are supported in this release of the gateway. Refer to Appendix C, "Data Dictionary Views", for descriptions of Oracle DB2 catalog views.
You are able to access DB2 special registers using the gateway. During installation of the gateway, a DB2 view is created to access special registers. For example, to find out the primary authorization ID being used by the gateway, run the following statement from your application:
SELECT CURRENT_USER FROM OTGDB2.OTGREGISTER@DB2
where OTGDB2 is the default qualifier of the OTGREGISTER
view, and DB2 is the name of a database link to the gateway. Refer to Appendix C, "Data Dictionary Views", for a description of the OTGREGISTER
view.