Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Interbase Sql Conversion to Sql Server and Oracle

i have a delphi application which uses database interbase / firebird. To consult and write data I use the InterBase components palette (IBTable, IBQuery, IBDataset). I'm performing the conversion of my system to sqlserver / Oracle but i have thousands of queries that are assembled at runtime with SQL Instructions Specific of database InterBase/Firebird. Anyone know any component or tool that makes Parse commands Interbase -> SQL Server or Interbase-> Oracle ?

what i need its something like:

Var
  Parser: TParser;
  OutputSql: String;
Begin
   Parser := TParser.Create();
   Parser.Text := 'SELECT FIRST 10 CITYNAME FROM TBCITY';

   if Firebird then
      OutPutSql := Parser.ParseTo('SQLSERVER');

   if Oracle then
      OutPutSql := Parser.ParseTo('ORACLE');

   ComponentAccess.Sql.Text := OutPutSql;
   ...

The Result Of:

Parser.ParseTo('SQLSERVER');

Will Be

'SELECT TOP 10 CITYNAME FROM TBCITY'

And

Parser.ParseTo('ORACLE');

Will Be

'SELECT CITYNAME FROM TBCITY WHERE ROWNUM <= 10'

like image 867
Mauro Reis Avatar asked Aug 03 '26 01:08

Mauro Reis


2 Answers

1) AFAIK, libraries like AnyDAC, have SQL abstraction syntax. May be you can use this feature in your SQL command text.

2) If you are assembling your SQL at runtime, then why not just code like that:

if Firebird then
  SQL.Add(...)
else if Oracle then
  SQL.Add(...)
...
like image 175
oodesigner Avatar answered Aug 05 '26 13:08

oodesigner


We have implemented that in AnyDAC. You may use LIMIT escape function:

ADQuery1.Sql.Text := 'SELECT {LIMIT(10)} CITYNAME FROM TBCITY';

AnyDAC will automatically translate that into target DBMS syntax.

like image 40
da-soft Avatar answered Aug 05 '26 14:08

da-soft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!