Anda di halaman 1dari 37

Welcome to JQL vs. SQL learning unit of Oracle Direct Connect Drivers Course.

In
this learning unit, you will learn the internal working of RDBMS Driver. You will also
have a brief introduction into how the JQL statements are translated to a SQL
statement.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 1


After completing this learning unit, you will be able to:

Differentiate between the JQL and SQL commands


Analyze XMLdriver.log to understand the internal working of RDBMS driver
Identify the detailed working of RDBMS driver.
State the need for Views, Index while querying an RDDMS.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 2


Let us understand the working of CREATE.FILE command by creating a file named
TRG.TEST .

The screenshot shows part of the XMLdriver.log file generated when the
CREATE.FILE command is executed. You can see the DICTONARY part of the
XMLORACLE file created, being translated into a SQL statement CREATE TABLE
D_TRG_TEST. This table D_TRG_TEST is created under T24DATA tablespace. This
table contains two fields namely RECID(VARCHAR 255) and XMLRECORD (type
XMLTYPE).

Note: Make sure the following variables are set, in order for these activities to be
recorded in the log.
JEDI_XMLDRIVER_DEBUG
JEDI_XMLDRIVER_DEBUG_DISPLAY
JEDI_XMLDRIVER_TRACE

A primary key has been created for the field RECID. Name of the primary key
constraint is PK_D_TRG_TEST. The index created for the primary key has been
placed under the T24INDEX tablespace. The name, path and the type of the file have
been updated to the STUBFILES table.

When the variable JEDI_XMDRIVER_TRACE is set, all the info will get logged like the
functions and procedures called, value of the variables assigned at different stages,

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 3


etc. This detailed level of logging is provided on developers point of view.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 3


This part of XMLdriver.log file displayed above shows the translation of DATA part of
the XMLORACLE file created which is translated into an SQL statement CREATE
TABLE TRG_TEST under T24DATA tablespace. A table TRG_TEST contains two
fields namely RECID(VARCHAR (255)) and XMLRECORD (type XMLTYPE). A
primary key has been created for the field RECID. Name of the primary key
constraint is PK_TRG_TEST. The index created for the primary key has been
placed under the T24INDEX tablespace.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 4


Let us now understand the working of JQL WRITE, we will test it by creating a record
in TRG.TEST file.

This screenshot displays the creation of a record under the TRG.TEST file. The
content “WELCOME TO T3DCDO TRAINING” has been entered and saved into the
record.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 5


Let us check the log details of the record update performed at jshell, which eventually
updates table TRG_TEST at Oracle.

This part of XMLdriver.log file displayed above, shows the translation of WRITE onto
oracle table TRG_TEST. The record key is RECORD1<row id> , record content is
<c1>WELCOME TO T3DCDO<c1> , where rowid denotes the record name and c1 the
column on which the content is updated onto the table TRG_TEST

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 6


Let us now understand the working of JQL – CLEAR.FILE, we will test It by deleting
the contents from TRG.TEST file.

Let us check the log details of CLEAR.FILE at jshell, which eventually deletes
contents of file TRG_TEST at Oracle. This part of XMLdriver.log displayed above
shows the translation of CLEAR.FILE in SQL.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 7


Let us now understand the working of JQL – DELETE.FILE, we will test It by deleting
TRG.TEST file.

Let us check the log details of DELETE.FILE at jshell, which eventually DROPS the file
TRG_TEST at Oracle.

This part of XMLdriver.log displayed above shows execution of jmainfunction


dbDropTable

Entry for the above mentioned files are removed from the STUBFILES table.

At the J4 level, TRG.TEST have been deleted.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 8


In this illustration you will execute a plain select on file FBNK.ACCOUNT

J4 statement used : SELECT FBNK.ACCOUNT

When the SELECT FBNK.ACCOUNT statement(mentioned above) is executed, it


would have selected all the IDs of the Customer application and display the secondary
prompt.

The J4 SELECT statement has been converted to an Oracle SQL statement by the
driver.

Oracle SQL statement : SELECT t.RECID FROM FBNK_ACCOUNT t

Since this is a simple select this will lead to full table scan

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 9


From the prompt, let us now open a record using the JED editor and see how that
request translates to an Oracle SQL statement.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 10


When a jed command is issued from the jshell, record is read from the Oracle
database and displayed to the user.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 11


From the jshell prompt, let us now execute a plain SELECT statement with condition.
The JQL statement is SELECT FBNK.ACCOUNT WITH @ID = 100724.

The JQL used is : SELECT FBNK.ACCOUNT WITH @ID = 100724


The SQL statement used to select record with ID 100724 : SELECT t.RECID FROM
FBNK_ACCOUNT t WHERE NUMCAST(RECID)=100724

RECID will be already indexed and this select will fetch only those records with ID
100724 from the database.

Note: NUMCAST is just a simple function that returns TO_NUMBER of its input
argument

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 12


From the jshell prompt, let us now execute a SELECT statement with condition using
fields other than @ID. In this illustration the example we are using is a query on field
CURRENCY. The JQL statement execute at jshell is SELECT FBNK.ACCOUNT
WITH CURRENCY EQ 'JPY'

The Oracle SQL used is SELECT RECID, t.XMLRECORD.GetClobVal() FROM


FBNK_ACCOUNT t

The above query shows that the full table is selected at the
Oracle level and then the whole set of data is filtered at the
jbase level to met the selection criteria. This will affect the
performance.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 13


Index has been created on the CUSTOMER file for the field CURRENCY. This will
improve the performance when we try to query the CUSTOMER with conditions based
on CURRENCY field.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 14


From the jshell prompt, let us now execute a SELECT statement with condition using
fields other than @ID. In this illustration the example we are using is a query on field
CURRENCY.

The JQL statement execute at jshell is SELECT FBNK.ACCOUNT WITH


CURRENCY EQ 'JPY'

Equivalent SQL statement

SELECT t.RECID FROM FBNK_ACCOUNT t WHERE


NVL(NUMCAST(EXTRACTVALUE(t.XMLRECORD,'/row/c23')),0)=1000

After creating an index, there won’t be a full table scan and there will be an
improvement in performance.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 15


The JQL statement execute at jshell is SELECT FBNK.ACCOUNT WITH
CURRENCY EQ 'JPY‘

The ORACLE SQL used is SELECT t.RECID FROM FBNK_ACCOUNT t WHERE


NVL(
EXTRACTVALUE(t.XMLRECORD,'/row/c23')),0)=‘JPY’

ExtractValue() function takes two arguments. The first is the XML data, the second is
the XPath expression that you want to evaluate. The function returns the first text node
under each element that matches the XPath expression

Here the Xpath expression is /row/c9. (This is to fetch c9 element inside row element)

Note: NUMCAST is just a simple function that returns TO_NUMBER of its input
argument

NVL function is used to replace NULL value with 0

ORACLE inspects the XML data contained in the “XMLRECORD" column, navigates
from the root “row" element to “c9“ element and check whether the value is JPY

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 16


CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 16
After you had created index by giving the command CREATE-INDEX, in order to
check if the index has been created at the Oracle level, use the following command -
SELECT INDEX_NAME FROM USER_INDEXES WHERE INDEX_NAME LIKE
‘NIX%’

However there is an alternative method to figure out the index created, if you know the
application . You can use this command mentioned below:

SELECT INDEX_NAME, TABLE_NAME FROM USER_INDEXES WHERE


TABLE_NAME = ‘<TABLE NAME> ’ (In the above illustration, we have substituted
FBNK_ACCOUNT instead of TABLE NAME.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 17


When ever a SELECT is performed based on a multi value field it will always result in
full table being performed.

Select will be a simple select at the database level, meaning all the record ids will be
fetched from the database and then filtered at the jbase level to meet the selection
criteria.

Index creation on a multi value field is not supported in R10

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 18


When ever a SELECT is performed based on a local reference field, it will always
result in full table scan being performed.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 19


Index created on a Local Reference Field. Creation of index on a particular field is
used to improve the performance when we try to query a particular file based on
the value in the indexed field

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 20


Now the selection query has used the created index, which improves
performance.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 21


CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 22
All our T24 applications are stored as tables at the Oracle level.

As mentioned earlier, each of those tables will contain 2 columns namely, RECID
and XMLRECORD.

Rebuilding STANDARD.SELECTION record for an application will result in the


creation of a view for that application at the Oracle level.

Using views we will be able to query based on individual fields in a table.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 23


Now, let us rebuild the STANDARD,SELECTION record for the ACCOUNT
application.

Setting the field ‘REBUILD.SYS.FIELDS’ to ‘Y’ and committing/authorizing the record


in the STANDARD.SELECTION application will result in rebuilding the
STANDARD.SELECTION record and will create a view at the Oracle level.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 24


This will rebuild this record by building dictionary items for the particular application.
Note, You will have to rebuild the STANDARD SELECTION record for important
application for which you would like to query using views.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 25


On rebuilding STANDARD.SELECTION for ACCOUNT application.

A view V_FBNK_ACCOUNT has been created for the file FBNK.ACCOUNT

A view V_FBNK_ACCOUNT#HIS has been created for the file FBNK.


ACCOUNT$NAU

A view V_FBNK_ACCOUNT#NAU has been created for the file FBNK.


ACCOUNT$HIS

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 26


To check if the views have been created at the Oracle level, execute the following
Oracle SQL statement.

SELECT VIEW_NAME FROM USER_VIEWS

This screenshot above displays the views created for currently logged in Oracle user.

To obtain the field definition of the view created, execute the following Oracle SQL
statement DESC <VIEW_NAME>.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 27


CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 28
These variables mentioned below will enable the above mentioned feature for
BINARYXML and COMPRESSION globally

JEDI_XMLORACLE_BINARYXML=1
JEDI_XMLORACLE_NOCOMPRESS=1

SecureFile is new type of LOB data vs. BasicFile. Table has to be recreated if
migrating exist data from old LOB type. Default FALSE ( using SecureFile).

NOTE:
The driver by default creates table in a compressed format.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 29


Options used on the specific CREATE command are:

CREATE-FILE TESTFILE11 TYPE=XMLORACLE BINARYXML=YES

CREATE-FILE TESTFILE2 TYPE=XMLORACLE NOXMLSCHEMA=YES

CREATE-FILE TESTFILE4 TYPE=XMLORACLE NOCOMPRESS=YES

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 30


Options used on the specific CREATE command are:

CREATE-FILE TESTFILE3 TYPE=XMLORACLE BINARYXML=YES


NOXMLSCHEMA=YES

CREATE-FILE TESTFILE4 TYPE=XMLORACLE BINARYXML=YES


NOCOMPRESS=YES

CREATE-FILE TESTFILE5 TYPE=XMLORACLE NOXMLSCHEMA=YES


NOCOMPRESS=YES

CREATE-FILE TESTFILE6 TYPE=XMLORACLE BINARYXML=YES


NOXMLSCHEMA=YES

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 31


Q 1:
Type: Enter all possible choice for this question

Question : Which of these are the commands to create a view in Oracle for T24
applications from jshell or T24.

Choice 1: Rebuild STANDARD.SELECTION record for respective application


Choice 2: Use CREATE-EXTSTATS command
Choice 3: CREATE-EXTINDEX command
Choice 4: Rebuild FILE.CONTROL record for the respective application
Choice 5: CREATE-VIEW command
Choice 6: Use CREATE-trigger command

Correct Answer: Choice 1, Choice 5


-----------------------------------------------------------------------------------------------------------
Q 2:
Type: True or False

Question: The equivalent of JQL CREATE-FILE in SQL is SELECT TABLE


Answer: False

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 32


--------------------------------------------------------------------------------------------------------------

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 32


Q 3:
Type: Multiple-choice (one or more correct options)

Question : Which of these are SQL equivalent for JQL - TRANSTART

Choice 1: TRANSBEGINING
Choice 2: BEGIN TRANSACTION
Choice 3: TRANSBEGIN
Choice 4: TRANSROLLFORWARD

Correct Answer: Choice 3


-----------------------------------------------------------------------------------------------------------
Q 4:
Type: True or False

Question: The JEDI_XMLORACLE_TRACE variable is set to 1 to enable


ORAdriver.log and detail tracing of XMLORACLE driver function.

Answer: True
--------------------------------------------------------------------------------------------------------------

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 33


In this learning unit, you learnt about the internal working of RDBMS Driver.

You will now be able to:

Differentiate between the JQL and SQL commands


Analyze ORAdriver.log to understand the internal working of RDBMS driver
Identify the detailed working of RDBMS driver.
State the need for Views, Index while querying an RDDMS.

CONV3.Direct Connect Drivers Oracle - JQL vs. SQL.R15 34

Anda mungkin juga menyukai