Subscribe to Posts by Email

Subscriber Count

    699

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

12c Database : SQL Translation Framework – Developer thing

SQL Translation framework is a new feature in 12c to give ability to the developers to migrate code without changing the underlying code.

In addition , this feature also provides the translation of code from non-oracle to oracle coding.

Further more, this feature can be a enhancement to sql profiles baselines etc. which can be used for plan stability.

In order to work with this feature, you will need to work on below
1) Create a translation profile
2) Register sql statements that need to convert into the profile
3) Set the event 10601 to enable the profile to work

Quick look.


	SQL> exec dbms_sql_translator.create_profile('TEST');

	PL/SQL procedure successfully completed.

	SQL> select object_name, object_type from dba_objects where object_name like 'TEST';

	OBJECT_NAME 				OBJECT_TYPE
	------------------------------------------------------------
	TEST        				SQL TRANSLATION PROFILE

	SQL> exec dbms_sql_translator.register_sql_translation('TEST','select count(*) from hr.countries','select count(*) from oe.countries');

	PL/SQL procedure successfully completed.

	SQL> grant all on sql translation profile TEST to hr,oe;

	Grant succeeded.

	SQL> alter session set sql_translation_profile = TEST;

	Session altered.

	SQL> alter session set events = '10601 trace name context forever, level 32';

	Session altered.

	SQL> set echo on
	SQL> select count(*) from hr.countries;

	  COUNT(*)
	----------
		25

	SQL> select * from table(dbms_xplan.display_cursor());

	PLAN_TABLE_OUTPUT
	-----------------------------------------------------------
	SQL_ID  2yyznfag9cypc, child number 0
	-------------------------------------
	select count(*) from oe.countries

	Plan hash value: 1399856367

	----------------------------------------------------------------------------
	| Id  | Operation        | Name            | Rows  | Cost (%CPU)| Time     |
	----------------------------------------------------------------------------
	|   0 | SELECT STATEMENT |                 |       |     1 (100)|          |
	|   1 |  SORT AGGREGATE  |                 |     1 |            |          |
	|   2 |   INDEX FULL SCAN| COUNTRY_C_ID_PK |    25 |     1   (0)| 00:00:01 |
	----------------------------------------------------------------------------


	14 rows selected.

Did u observe the execution plan, it says oe.countries rather hr.countries. This feature is already there in MySQL and seems oracle listenting to all 🙂

Comments are closed.