Subject | Re: [Firebird-general] Counting only certain log events |
---|---|
Author | Svein Erling Tysvær |
Post date | 2018-04-10T06:57:33Z |
Why not simply something like
INSERT INTO PRINT_LOG (<fields>)
VALUES(<whatever>)
WHERE NOT EXISTS(SELECT * FROM PRINT_LOG PL
WHERE PL.Client_ID = :Client_ID
AND PL.Event_DateTime > CURRENT_TIMESTAMP - 1)
I assume things are inserted chronologically and that there are no problems with simultaneous inserts for the same client.
HTH,
Set
2018-04-09 23:31 GMT+02:00 dressel@... [Firebird-general] <Firebird-general@yahoogroups.com>:
I have new way a user wants to pay for the software.
I have a log of when a user prints a report for a client. From the first log event, they can create as many reports for that client in 24 hours as they want, it is only counted as one. After 24 hours, any reports create count as an additional report and again, 24 hours to create another report. The basic data fields are:
PrintLog
PrintLog_ID
Event_DateTime
Client_ID
The primary key uses PrintLog_ID exclusively, and a foreign key uses Client_ID. Event_DateTime is indexed
Any suggestions on how to create the SQL this? I'm guessing that it requires a stored proc. .
Ed Dressel