I have a program that runs on several systems which have either MSServer or Oracle as supporting database. Unfortunately a query that runs on one database may not run on another type, because of the different SQL dialects (especially with date/time manipulation)
As I have to cope with only two types of databases, as solved the problem as follows:
I deliberately execute a query that will fail on Oracle (in my case a SELECT DATEDIFF(...) FROM ....)
If it does indeed fail, then execute the Oracle SQL; if not execute MSSQL.
That approach works, but I'm uneasy with it:
- There may be more than two types of DBs in the future (There shouldn't be, but life is unpredictable)
- One can simulate the DATEDIFF function on Oracle by implementing a user function/procedure. So I can not 100% count on it (or any other function)
My question: Can I find and access within the database itself information telling which data base it is? In some kind of catalog or system tables?
Or do you have other suggestions/approaches?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
As I have to cope with only two types of databases, as solved the problem as follows:
I deliberately execute a query that will fail on Oracle (in my case a SELECT DATEDIFF(...) FROM ....)
If it does indeed fail, then execute the Oracle SQL; if not execute MSSQL.
That approach works, but I'm uneasy with it:
- There may be more than two types of DBs in the future (There shouldn't be, but life is unpredictable)
- One can simulate the DATEDIFF function on Oracle by implementing a user function/procedure. So I can not 100% count on it (or any other function)
My question: Can I find and access within the database itself information telling which data base it is? In some kind of catalog or system tables?
Or do you have other suggestions/approaches?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]