Previously we used DB2 as database, but now we are migrating to Oracle. Now, in our project we have extensively used sql’s that were Db2 specific.
Is there any way to convert those DB2 specific queries to oracle supported queries.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have a lot of work ahead!
Between DB2 and Oracle, some important differences are (just an arbitrary enumeration of what I can think of):
Data types
SMALLINT,INTEGER,DOUBLE, etc. Those don’t exist in Oracle SQL (although some exist in PL/SQL). This is important for DDL and for casting and some other use cases, such as the correctness of predicatesDATEandTIMESTAMPis the fact thatTIMESTAMPhas microseconds. ButDATEmay also contain time information. In DB2,DATEhas no time information, I think.VARCHARandVARCHAR2in OracleNULL. In Oracle,NULLis much more general than in DB2. Before DB2 v9.7, you had to castNULLto any explicit type, e.g.cast(null as integer). That’s not necessary in Oracle.System objects
SYSIBM.DUALsimply becomesDUALLOCATEbecomesINSTRSyntax
TRUNCATE IMMEDIATEbecomesTRUNCATEEXCEPTbecomesMINUSFETCH FIRST n ROWS ONLY: There is no such clause in Oracle. You’ll have to useROWNUMorROW_NUMBER() OVER()filtering (see this example)MERGEstatement is more powerful than that of Oracle, in case you use this.INSERT INTO .. (..) VALUES (..), (..), (..). With Oracle, you’d have to writeINSERT INTO .. SELECT .. UNION ALL SELECT .. UNION ALL SELECT ..Advanced
Your most efficient shot at this might be to use SQL abstraction of some sort. If you’re using Java, I would recommend you wrap your SQL statements with jOOQ (Disclaimer: I work for the company behind jOOQ). jOOQ provides API-level abstraction for all of the above facts. A great deal of SQL can be executed both on DB2 and Oracle, without adaptation. We’re also working on a more independent translator product: https://www.jooq.org/translate
On a higher level of abstraction, Hibernate (or other JPA implementations) can do the same for you