LibreOffice 25.8.04 (x86.64) Ubuntu 24.04
and
LibreOffice 7.6.7.2 (x86.64) Ubuntu 20.04 (The machine I’m on now)
I have a firebird external database and I’m trying to create a constraint on a number of date fields.
I have a table “Bookings” which has 3 date fields “DateRecvd”, “StartDate” and “EndDate”
These represent the date an order was “received” for a stay at our property, when the stay “Started” and when it “Ended”.
Obviously “EndDate” must be > “StartDate” and I have managed to enter a constraint using SQL:-
ALTER TABLE "Bookings" ADD CONSTRAINT "CK_StartEndDate" CHECK ("EndDate" > "StartDate")
which works just fine.
I also have a “Payments” table with a “PaidDate” and obviously payment cannot be made before the order was “received”. Because I have discovered that a default date in a subform seems to be “14th Feb 2019” (mentioned in a previous post), I have tried without success to create a restraint to ensure that “Payments.PaidDate” cannot be less than “Bookings.RecvdDate”. I’ve tried SQL:-
ALTER TABLE "Payments" ADD CONSTRAINT "CK_PaidDate" CHECK ("PaidDate" > "Bookings.RecvdDate")
But receive the following error:-
1: firebird_sdbc error:
*unsuccessful metadata update
*ALTER TABLE Payments failed
*Dynamic SQL Error
*SQL error code = -206
*Column unknown
*Bookings.RecvdDate
caused by
'ALTER TABLE "Payments" ADD CONSTRAINT "CK_PaidDate" CHECK ("PaidDate" > "Bookings.RecvdDate")
'
at /build/libreoffice-Dc86jq/libreoffice-7.6.7/connectivity/source/drivers/firebird/Util.cxx:69
I’m guessing that this is because I’m trying to create a constraint in one table based on a field in another table. Is this possible? and what am I doing wrong?
As a temporary measure I’ve used SQL:
ALTER TABLE "Payments" ADD CONSTRAINT "CK_PaidDate" CHECK ("PaidDate" > ‘30/11/2019’)
to ensure that a date must be later than 30th Nov 2019, which gets round the 14/2/2019 problem.