Skip navigation.

Dominic Giles

Syndicate content
The Oracle blog of Dominic Giles.
Updated: 12 hours 37 min ago

Something for the future

Thu, 2013-07-18 05:46

A nice little feature in Oracle Database 12c is to query patching information via SQL. You can do this from SQLPlus or any other SQL interface jdbc/odbc etc. You can find more details here

However you won't be surprised to find that the following query doesn't currently return any useful information.

SYS@//oracle12c/orcl > select DBMS_QOPATCH.GET_OPATCH_LIST from dual;

SQL Translator Profiles in Oracle Database 12c

Mon, 2013-07-08 10:19

A new feature in Oracle Database 12c is the ability to intercept and translate third party SQL to Oracle syntactically correct SQL  before it is parsed and executed. So you can now intercept SQL from applications using jdbc and odbc that were designed to run against a non Oracle database and potentially run them completely unchanged. The only work necessary is done by the database development/management team. In Oracle Database 12c we also currently support the automatic translation of some databases SQL. Currently this is limited to Sybase but we're working on others. You can find all the details here

You can also use the frame work against an application that already successfully runs against an Oracle Database. You might want to do this for migration/performance/security reasons. It also gives you an opportunity to try out an important part of the framework "Translation Profiles".

The following SQL demonstrates a simple use case. I'm using the Swingbench Order Entry schema but the sample schema OE would work just as well.

First grant the privilege to the user you want to create the SQL profile on in this case SOE. You need to do this as sys or system

grant create sql translation profile to SOE

Then connect to the user you've just granted the privilege to (SOE) and create a SQL Translation profile.

-- Drop the profile if it already exists

-- Create a Translation Profile

exec dbms_sql_translator.create_profile('ORDERS_APP_PROFILE');

Then add some SQL to be translated. In our simple example we are translating a count against the ORDERS table and translating it to run against the ORDERS_SOUTH table

-- Create a Translation in that profile

      profile_name    => 'ORDERS_APP_PROFILE',
      sql_text        => 'select count(*) from orders',
      translated_text => 'select count(*) from orders_south');

At this stage it's worth seeing whats been populated. You can see the SQL via the following views.



Then test how this changes the execution by creating our new "ORDERS_SOUTH" table

-- Count the rows we get back from orders
select count(*) from orders;

-- Create a new table  orders_south with just ten rows in

create table orders_south as select * from orders where rownum < 11;

Now we've done that enable the sql translation profile we want to use

-- Set the session to use the sql translation profile

alter session set sql_translation_profile = ORDERS_APP_PROFILE

-- For testing make the sqlplus look like a foreign tool


Now when we re run our query it will use the ORDERS_SOUTH table even though we've explicitly asked for a count against the ORDERS table.

select count(*) from orders;

-- We should just see 10 rows as opposed to hundreds of thousands

And thats a quick example of SQL Translator profiles in Oracle Database 12c 

Going Production...

Thu, 2013-07-04 12:48

This blog is going production... Just like Oracle Database 12c.

 Comments and code snippets to follow