Enable Oracle’s Compatibility Functions and Packages in YSQL

Are you migrating from Oracle to YugabyteDB? If so, Orafce is a very useful PostgreSQL Extension that allows you to implement some functions from Oracle in YugabyteDB.

For example, if you are used to DATE functions in Oracle, this extension allows you to use those functions.

Here we see that out of the box, the Oracle function NEXT_DAY does not run in YugabyteDB:

				
					
yugabyte=# SELECT current_date, next_day(current_date, 'FRIDAY') next_friday; -- Works in Oracle!
ERROR:  function next_day(date, unknown) does not exist
LINE 1: SELECT current_date, next_day(current_date, 'FRIDAY') next_f...
                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
				
			

However, after enablling the Orafce extension, it will execute in YugabyteDB!

				
					
yugabyte=# CREATE EXTENSION orafce;
CREATE EXTENSION

yugabyte=# SELECT current_date, next_day(current_date, 'FRIDAY') next_friday; -- Works in Oracle! And now in YugabyteDB too!
 current_date | next_friday
--------------+-------------
 2022-04-14   | 2022-04-15
(1 row)
				
			

Have Fun!