Exploring SQL translation profiles
A SQL translation profile can serve as the first solution for dynamic SQL transformation. Although it is primarily intended to transform non-Oracle SQL syntax, it can also be used internally to transform date function calls and representations. The DBMS_SQL_TRANSLATION
package and its methods power the management of the SQL translation profile. Simply, the translation profile is created and given a name (in our case, it is called DATE_PROF
), and then the query transformation registration is carried out. Multiple statements can be registered for the transformation by using the REGISTER_SQL_TRANSLATION
procedure of the DBMS_SQL_TRANSLATION
package.
The REGISTER_SQL_TRANSLATION
procedure takes three parameters – the name of the SQL translation profile (parameter 1), the original statement (parameter 2), and the transformed statement (parameter 3). In our case, we transform two statements by referencing the sysdate
and systimestamp
functions...