Need to write a query which will be run against SqlServer and Oracle. A query just selects a constant.
In SqlServer this is achieved with:
SELECT 1 AS Value;
Oracle:
SELECT 1 AS Value FROM DUAL;
But database is not known at runtime. Is it possible to have one sql query for both DBMS?
Queries above work fine but need to unify the syntax.
Both products support table valued constructors so you can do
select *
from (values
(1)
) a (Value);
- Oracle Fiddle
- SQL Server Fiddle