Tuesday, March 2, 2021

Translating Stored Procedures Between Dialects

In the past years, we’ve invested a lot of effort into improving our procedural language capabilities in jOOQ. What started with a simple internal API to support the emulations of DDL clauses like these: 

SQL
 




x
26


 
1
-- Some dialect that supports this
2
create table if not exists t (i varchar(10));
3
 
4
-- Db2
5
begin
6
  declare continue handler for sqlstate '42710' begin end;
7
  execute immediate 'create table T (I varchar(10))';
8
end
9
 
10
-- Oracle
11
begin
12
  execute immediate 'create table T (I varchar2(10))';
13
exception
14
  when others then
15
    if sqlerrm like 'ORA-00955%' then null;
16
    else raise;
17
    end if;
18
end;
19
 
20
-- SQL Server
21
begin try
22
  create table T (I varchar(10))
23
end try
24
begin catch
25
  if error_number() != 2714 throw;
26
end catch





from DZone.com Feed https://ift.tt/3b9UbvV

No comments:

Post a Comment