3
I have a system developed in Delphi 7 already stable using the Firebird database, and some customers have requested that they can use Postgres as a database in the same system.
As with some SELECT’S, my system uses some reserved Firebird words, I decided to create an intermediate component that at runtime, change these words, or change the syntax so that the system continues to work, as it is today with Firebird.
However, I would like to know if there is any framework, component or even DLL that does this. So that I don’t need to reinvent the wheel, studying both syntax of each and creating checks for it. Preferably in Delphi 7 (being DLL, may be higher version).
Example:
--FIREBIRD
EXECUTE BLOCK
AS
BEGIN
IF
( EXISTS
( SELECT 1 FROM TB_FNC_SEC
WHERE FD_FNC = 1
AND FD_SEC = 'LOC'
AND FD_KEY = 'FD_FNC'
)
) THEN
UPDATE TB_FNC_SEC SET
FD_VAL = '0'
WHERE FD_FNC = 1
AND FD_SEC = 'LOC'
AND FD_KEY = 'FD_FNC';
ELSE
INSERT INTO TB_FNC_SEC (
FD_FNC,FD_SEC,FD_KEY,FD_VAL
) VALUES (
1,'LOC','FD_FNC','0') ;
END
--POSTGRES
DO
$$ --INICIO
BEGIN
IF
( EXISTS
( SELECT 1 FROM TB_FNC_SEC
WHERE FD_FNC = 1
AND FD_SEC = 'LOC'
AND FD_KEY = 'FD_FNC'
)
) THEN
UPDATE TB_FNC_SEC SET
FD_VAL = '0'
WHERE FD_FNC = 1
AND FD_SEC = 'LOC'
AND FD_KEY = 'FD_FNC';
ELSE
INSERT INTO TB_FNC_SEC (
FD_FNC, FD_SEC, FD_KEY,FD_VAL
) VALUES (
1, 'LOC','FD_FNC','0') ;
$$
Thanks in advance for the help.
In Firebird’s WHERE clause
AND FD_SEC = 'LOC'
and in Postgre hasAND FD_SEC = 'LOCALIZA'
. Is this difference intentional? If so, why is oneLOC
and the otherLOCALIZA
?– Victor Stafusa
Rush typing. rsrsrs Fixed for better subject clarity.
– Juvencio Leite