Trigger in MySQL upon changing stock status












1















enter image description here



This are one of the requirement that have to be done for my assignment and I am having a trouble on how or where do i start. my lecturer told us smth having a trigger and he is reluctant to guide us how we should so it.



I have an Ordertbl where if the order status are set as "Ordered" the stock will remain the same where if the status are changed to "Received" the stock increases, same as having a "Delivered" status, the qty will be deducted from the inventory:



Scenario:



I ordered product from Supplier and the status are "Ordered", then the Admin or Clerk can change the status to "Received" thus the qty will be add up to the InventoryTbl.



How do i implement the trigger thing in MySQL?



I am using .jsp. Do I have to create the trigger code in .jsp or in database?










share|improve this question
















bumped to the homepage by Community 27 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

    – oNare
    Oct 27 '15 at 21:18


















1















enter image description here



This are one of the requirement that have to be done for my assignment and I am having a trouble on how or where do i start. my lecturer told us smth having a trigger and he is reluctant to guide us how we should so it.



I have an Ordertbl where if the order status are set as "Ordered" the stock will remain the same where if the status are changed to "Received" the stock increases, same as having a "Delivered" status, the qty will be deducted from the inventory:



Scenario:



I ordered product from Supplier and the status are "Ordered", then the Admin or Clerk can change the status to "Received" thus the qty will be add up to the InventoryTbl.



How do i implement the trigger thing in MySQL?



I am using .jsp. Do I have to create the trigger code in .jsp or in database?










share|improve this question
















bumped to the homepage by Community 27 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

    – oNare
    Oct 27 '15 at 21:18
















1












1








1








enter image description here



This are one of the requirement that have to be done for my assignment and I am having a trouble on how or where do i start. my lecturer told us smth having a trigger and he is reluctant to guide us how we should so it.



I have an Ordertbl where if the order status are set as "Ordered" the stock will remain the same where if the status are changed to "Received" the stock increases, same as having a "Delivered" status, the qty will be deducted from the inventory:



Scenario:



I ordered product from Supplier and the status are "Ordered", then the Admin or Clerk can change the status to "Received" thus the qty will be add up to the InventoryTbl.



How do i implement the trigger thing in MySQL?



I am using .jsp. Do I have to create the trigger code in .jsp or in database?










share|improve this question
















enter image description here



This are one of the requirement that have to be done for my assignment and I am having a trouble on how or where do i start. my lecturer told us smth having a trigger and he is reluctant to guide us how we should so it.



I have an Ordertbl where if the order status are set as "Ordered" the stock will remain the same where if the status are changed to "Received" the stock increases, same as having a "Delivered" status, the qty will be deducted from the inventory:



Scenario:



I ordered product from Supplier and the status are "Ordered", then the Admin or Clerk can change the status to "Received" thus the qty will be add up to the InventoryTbl.



How do i implement the trigger thing in MySQL?



I am using .jsp. Do I have to create the trigger code in .jsp or in database?







mysql trigger






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 27 '15 at 21:20









oNare

2,67921231




2,67921231










asked Oct 27 '15 at 16:03









lanouvalanouva

61




61





bumped to the homepage by Community 27 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 27 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

    – oNare
    Oct 27 '15 at 21:18





















  • You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

    – oNare
    Oct 27 '15 at 21:18



















You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

– oNare
Oct 27 '15 at 21:18







You just need to make a trigger with it exact action time (BEFORE|AFTER) in the affected tables. Edit your post and add your SHOW CREATE TABLE xxxx and some data test.

– oNare
Oct 27 '15 at 21:18












1 Answer
1






active

oldest

votes


















0














You would create the trigger on each table in the mysql DB that is affected.



The article below provides information on how to create a trigger -



https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f119335%2ftrigger-in-mysql-upon-changing-stock-status%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You would create the trigger on each table in the mysql DB that is affected.



    The article below provides information on how to create a trigger -



    https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html






    share|improve this answer




























      0














      You would create the trigger on each table in the mysql DB that is affected.



      The article below provides information on how to create a trigger -



      https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html






      share|improve this answer


























        0












        0








        0







        You would create the trigger on each table in the mysql DB that is affected.



        The article below provides information on how to create a trigger -



        https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html






        share|improve this answer













        You would create the trigger on each table in the mysql DB that is affected.



        The article below provides information on how to create a trigger -



        https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 27 '15 at 16:40









        MJCookieMJCookie

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f119335%2ftrigger-in-mysql-upon-changing-stock-status%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Liste der Baudenkmale in Friedland (Mecklenburg)

            Single-Malt-Whisky

            Czorneboh