Alex
2004-09-19 15:24:36 UTC
Hi,
In my project I have two databases: primary which is an SQLite db, and
secondary which is based on a different engine. A table in the primary db
contains values which are keys for the secondary db. To maintain coherence
of the two databases I use SQLite triggers. The DELETE and UPDATE commands
are handled fine, but INSERT causes a problem.
The point is that if the OR REPLACE clause is specified, INSERT may
overwrite an existing row instead of inserting a new one. In this case the
appropriate record in the secondary db must be deleted. However, I cannot do
it because OLD is not available inside the INSERT trigger regardless of the
operation actually performed.
What is worse, the SQL part of the project is done by a quite different
person, so no restrictions on SQL syntax used may be imposed. The solution I
need must be universal.
So, before starting to invent a workaround I'd like to consult with you,
people. I hope, I'm not the first person who encountered this problem. Any
suggestions are highly appriciated.
Thanks,
Alex
In my project I have two databases: primary which is an SQLite db, and
secondary which is based on a different engine. A table in the primary db
contains values which are keys for the secondary db. To maintain coherence
of the two databases I use SQLite triggers. The DELETE and UPDATE commands
are handled fine, but INSERT causes a problem.
The point is that if the OR REPLACE clause is specified, INSERT may
overwrite an existing row instead of inserting a new one. In this case the
appropriate record in the secondary db must be deleted. However, I cannot do
it because OLD is not available inside the INSERT trigger regardless of the
operation actually performed.
What is worse, the SQL part of the project is done by a quite different
person, so no restrictions on SQL syntax used may be imposed. The solution I
need must be universal.
So, before starting to invent a workaround I'd like to consult with you,
people. I hope, I'm not the first person who encountered this problem. Any
suggestions are highly appriciated.
Thanks,
Alex