question

anseakukwe14 avatar image
anseakukwe14 asked

How do set up an sql trigger for a sales shop database to be subtracting goods sold and given the over quantity remained for sales made each day.

Using triggers to update inserted rows constantly.
database-triggers
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

seanlange avatar image seanlange commented ·
You need MORE than just an AFTER INSERT trigger if you want to have any chance at this. You will also need to handle UPDATES and DELETES. Honestly this type of stock calculation should be done on the fly as needed in most situations.
0 Likes 0 ·
anseakukwe14 avatar image anseakukwe14 commented ·
seanlange, please explain well. what codes am I going to use?
0 Likes 0 ·
seanlange avatar image seanlange anseakukwe14 commented ·
This should be a comment, not an answer. I couldn't possibly tell you what code to use here. I have no idea what your tables are like or what you are trying to do. I can tell you that in my opinion managing this via triggers is a lot more work than you think. If you can post your table definitions and an explanation of what you are trying to do I can help. Take a look at this for examples of what you should post. http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/
1 Like 1 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.