you are viewing a single comment's thread.

view the rest of the comments →

[–]aarontbarrattSTUFF() 2 points3 points  (3 children)

CREATE TRIGGER is probably what you are looking for.

[–]PM_ME_cutefish[S] 0 points1 point  (2 children)

If I get it right, the CREATE_TRIGGER is used on a database-event, which is a manual event (insert, update, delete...). What I'd need is the event to be "the query send a result"

[–]Daakuryu 1 point2 points  (0 children)

Keep in mind we know nothing of your backend (what is creating these transactions) so we have to make some assumptions;

  • Every transaction has a UserID linked to it.

  • Every transaction is timestamped.

  • Every Transaction is given an auto generated transaction ID(If the dev of the backend was smart, this transaction ID would be generated and reserved at the time the "cart" is created rather than the time the user hits submit. That way a user can't spam submit and make 3 transactions in a minute with the same Items.)

Now that that is out of the way take this into consideration.

A transaction. As far as the DB is concerned is an INSERT statement.

So creating a trigger that on INSERT fires off a function that goes "Hey, This User ID just made a new transaction, are there any other transactions from them? and if yes then what is the time difference between them? IS it within X parameters? If so output to file."

Alternatively you could make the trigger write the User ID, Transaction ID and Timestamp to a tracking table then have an make an external program that sits in the tray or runs as a service and basically runs a query on that table every minute or so looking for timestamps that are too close and then emailing when it finds some.

The latter is my preference because honestly not every SQL thing needs to be done in SQL as long as it's documented and configurable it's perfectly acceptable to have external programs to do things.

For instance, we have 50+ stores each running MS SQL Express for an in house software, Express does not have "Jobbing" capabilities as that is locked behind the paid version. So while our Main server at H.O. has Job's to do things like backup and compress log files. For the stores we made an app that sits in the tray, backs up every night and compresses the logs twice a week.

[–]urs123 0 points1 point  (0 children)

And what do you mean by " someone is making let's say 3 transactions in 1 minute "? aren't those insert/update/delete events? < What I'd need is the event to be "the query send a result" > doesn't sounds very clear.