Page 1 of 1

New to UniDAC: Question about components

Posted: Mon 22 Jun 2009 16:58
by gmartins
Hello all.
I'm planning in using UniDAC but I have some questions on the best way to do what I need.
So here's the situation: I'm using Delphi 7 and I need my application to use 2 different databases: Sql Server 2005 and Firebird. Currently my database is Firebird but some customers requested I migrate the database to SQL Server, since they will only support that database in the future.
So, I need to be able to have my application work on both databases: sql server and firebird.
I've made some research and I've found UniDAC some time ago. Made some tests with both databases and the delphi components look easy to use (not so diferent from FIbPlus, that I use today to connecto to firebird) and I don't think changing my delphi application is going to be my biggest problem.
The problem is with the database querys. How can I make my connection to the database work well, if I have so many differences in some SQL Sintaxes:
Ex: I have some stored procedures that I query to get data to some datasets.
I use this sintax in firebird: 'Select * from sp_proc1(:param1)'
Now, in SQL Server this doesn't work. So my question is: how can I work around this, and make a client application that can work with both databases engines and their different semanthics?
I guess other users from this forum had this problem before.

Can anyone help?
Thanks in advance.

Best Regards

Goncalo

Posted: Wed 24 Jun 2009 01:16
by Joao Cadilhe
Since 2.50 version Unidac supports Conditional Sql statements:

{if Interbase}
SELECT * FROM AAAAAA
{else}
{if Sql Server}
SELECT * FROM BBBBBB
{endif}


You can read more information about macros and conditional Sql in Unidac help topic: Unified SQL


Joao Cadilhe.

Posted: Wed 24 Jun 2009 06:27
by Plash
It is recommended to use TUniStoredProc component to call stored procedures. Call its PrepareSQL method to generate SQL statement. For Firebird/InterBase pass True as a value of IsQuery parameter of PrepareSQL. In this case the component generates a stored procedure call with SELECT. Other providers ignore IsQuery parameter.

Posted: Wed 24 Jun 2009 08:34
by gmartins
Hello Joao and Plash.
Thanks for the reply.
I'll try both your sugestions and If I have trouble I'll come back :)
Thanks once again.

Best Regards

Goncalo