RE: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Omacht András aoma...@mve.hu [firebird-support]
 NOT (DATE_TO1mailto:firebird-supp...@yahoogroupscom] Sent: Wednesday, 12 September, 2018 14:41 To: firebird-support@yahoogroups.com Subject: RE: [firebird-support] Prevent overlaping dates in concurent environment Hi Tomasz! Tested on 2.5.8, dialect 1: CREATE TABLE RESERVED_DATE ( RES_DATE DATE NOT NULL

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Tomasz Tyrakowski t.tyrakow...@sol-system.pl [firebird-support]
On 12.09.2018 at 14:40, Omacht András aoma...@mve.hu [firebird-support] wrote: > [...] >while (curr_date <= new.date_to) do > > begin > >insert into reserved_date (res_date) values (:curr_date); > >curr_date = dateadd(1 day to curr_date); > > end > > end On a

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Tomasz Tyrakowski t.tyrakow...@sol-system.pl [firebird-support]
On 12.09.2018 at 15:04, Svein Erling Tysvær setys...@gmail.com [firebird-support] wrote: > Why wouldn't my suggestion work, Tomasz? When Karol inserts his first row > into his main table it will contain DATE_FROM 2018-09-10 and DATE_TO > 2018-09-20 and the trigger would insert 11 rows (one for

RE: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread 'Louis van Alphen' lo...@nucleo.co.za [firebird-support]
---| |---R2-| |R1---| |--R2--| From: firebird-support@yahoogroups.com [mailto:firebird-supp...@yahoogroups..com] Sent: Wednesday, 12 September, 2018 14:41 To: firebird-support@yahoogroups.com Subject: RE: [firebird-support] Prevent overlaping

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Svein Erling Tysvær setys...@gmail.com [firebird-support]
Why wouldn't my suggestion work, Tomasz? When Karol inserts his first row into his main table it will contain DATE_FROM 2018-09-10 and DATE_TO 2018-09-20 and the trigger would insert 11 rows (one for each date) into my suggested table. When the next row is inserted with DATE_FROM 2018-09-15 and

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Tomasz Tyrakowski t.tyrakow...@sol-system.pl [firebird-support]
On 12.09.2018 at 14:40, Omacht András aoma...@mve.hu [firebird-support] wrote: > Tested on 2.5.8, dialect 1: > > > > CREATE TABLE RESERVED_DATE ( > > RES_DATE DATE NOT NULL > > ); > > ALTER TABLE RESERVED_DATE ADD CONSTRAINT RESERVED_DATE_PK PRIMARY KEY > (RES_DATE); > > > >

RE: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Omacht András aoma...@mve.hu [firebird-support]
uot; on table "RESERVED_DATE". Problematic key value is ("RES_DATE" = '8-SEP-2018'). At trigger 'MEETINGS_BI' line: 9, col: 7. András From: firebird-support@yahoogroups.com Sent: Wednesday, September 12, 2018 1:59 PM To: firebird-support@yahoogroups.com Subject: Re: [firebird-

RE: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
Hi, but this require to have table with all dates. 365 rows per year per customer. This is not possible solution. This sample with customers  was only simplification. But extend this sample to meeting time date with time. This table will be too huge... Regards,Karol Bieniaszewski null

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Svein Erling Tysvær setys...@gmail.com [firebird-support]
What about a separate table for dates with one row per date and a UNIQUE constraint that you populate from a (AFTER INSERT/DELETE) trigger on your real table? HTH, Set Den ons. 12. sep. 2018 kl. 11:49 skrev liviuslivius liviusliv...@poczta.onet.pl [firebird-support] <

Re: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Tomasz Tyrakowski t.tyrakow...@sol-system.pl [firebird-support]
On 12.09.2018 at 13:29, Omacht András aoma...@mve.hu [firebird-support] wrote: > Create a (reserved_dates) table with date field, and make that field unique.. > When a user inserts a date into the reservation table a trigger immadiate > inserts this date to the reserved_dates table too. Then

RE: [firebird-support] Prevent overlaping dates in concurent environment

2018-09-12 Thread Omacht András aoma...@mve.hu [firebird-support]
Hi Karol! Create a (reserved_dates) table with date field, and make that field unique.. When a user inserts a date into the reservation table a trigger immadiate inserts this date to the reserved_dates table too. Then the unique key will stop secound insert instead of the first transaction is