Create a trigger update [closed]












0















Create a trigger that automatically when inserting data into the builds_result table updated the value of the updated_time field of the apps table to the current date and time. Error is given in on apps.updated_time



create trigger upd after insert
on builds_result
for each row
execute procedure new apps.updated_time = now();










share|improve this question















closed as unclear what you're asking by a_horse_with_no_name, marc_s, EdChum, Rob, lagom Nov 25 '18 at 8:39


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    This sounds more like an instruction (to you) rather than a question for us.

    – 404
    Nov 24 '18 at 16:50











  • @eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

    – mangyst
    Nov 24 '18 at 16:58






  • 2





    Post the code then so we can try to see what's wrong. And post the exact error you're getting.

    – 404
    Nov 24 '18 at 16:59











  • I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

    – 404
    Nov 24 '18 at 17:08











  • This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

    – mangyst
    Nov 24 '18 at 17:14


















0















Create a trigger that automatically when inserting data into the builds_result table updated the value of the updated_time field of the apps table to the current date and time. Error is given in on apps.updated_time



create trigger upd after insert
on builds_result
for each row
execute procedure new apps.updated_time = now();










share|improve this question















closed as unclear what you're asking by a_horse_with_no_name, marc_s, EdChum, Rob, lagom Nov 25 '18 at 8:39


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    This sounds more like an instruction (to you) rather than a question for us.

    – 404
    Nov 24 '18 at 16:50











  • @eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

    – mangyst
    Nov 24 '18 at 16:58






  • 2





    Post the code then so we can try to see what's wrong. And post the exact error you're getting.

    – 404
    Nov 24 '18 at 16:59











  • I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

    – 404
    Nov 24 '18 at 17:08











  • This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

    – mangyst
    Nov 24 '18 at 17:14
















0












0








0








Create a trigger that automatically when inserting data into the builds_result table updated the value of the updated_time field of the apps table to the current date and time. Error is given in on apps.updated_time



create trigger upd after insert
on builds_result
for each row
execute procedure new apps.updated_time = now();










share|improve this question
















Create a trigger that automatically when inserting data into the builds_result table updated the value of the updated_time field of the apps table to the current date and time. Error is given in on apps.updated_time



create trigger upd after insert
on builds_result
for each row
execute procedure new apps.updated_time = now();







postgresql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 17:21







mangyst

















asked Nov 24 '18 at 16:45









mangystmangyst

32




32




closed as unclear what you're asking by a_horse_with_no_name, marc_s, EdChum, Rob, lagom Nov 25 '18 at 8:39


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by a_horse_with_no_name, marc_s, EdChum, Rob, lagom Nov 25 '18 at 8:39


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1





    This sounds more like an instruction (to you) rather than a question for us.

    – 404
    Nov 24 '18 at 16:50











  • @eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

    – mangyst
    Nov 24 '18 at 16:58






  • 2





    Post the code then so we can try to see what's wrong. And post the exact error you're getting.

    – 404
    Nov 24 '18 at 16:59











  • I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

    – 404
    Nov 24 '18 at 17:08











  • This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

    – mangyst
    Nov 24 '18 at 17:14
















  • 1





    This sounds more like an instruction (to you) rather than a question for us.

    – 404
    Nov 24 '18 at 16:50











  • @eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

    – mangyst
    Nov 24 '18 at 16:58






  • 2





    Post the code then so we can try to see what's wrong. And post the exact error you're getting.

    – 404
    Nov 24 '18 at 16:59











  • I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

    – 404
    Nov 24 '18 at 17:08











  • This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

    – mangyst
    Nov 24 '18 at 17:14










1




1





This sounds more like an instruction (to you) rather than a question for us.

– 404
Nov 24 '18 at 16:50





This sounds more like an instruction (to you) rather than a question for us.

– 404
Nov 24 '18 at 16:50













@eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

– mangyst
Nov 24 '18 at 16:58





@eurotrash the fact of the matter is that I tried to write but every time it gives a syntax error

– mangyst
Nov 24 '18 at 16:58




2




2





Post the code then so we can try to see what's wrong. And post the exact error you're getting.

– 404
Nov 24 '18 at 16:59





Post the code then so we can try to see what's wrong. And post the exact error you're getting.

– 404
Nov 24 '18 at 16:59













I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

– 404
Nov 24 '18 at 17:08





I think you need to have a read of postgresql.org/docs/current/sql-createtrigger.html to see the correct way to create a trigger, and postgresql.org/docs/current/plpgsql-trigger.html on how to create a trigger function.

– 404
Nov 24 '18 at 17:08













This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

– mangyst
Nov 24 '18 at 17:14







This results in an error indicating apps.updated_time create trigger upd after insert on builds_result for each row execute procedure new apps.updated_time = now();

– mangyst
Nov 24 '18 at 17:14














1 Answer
1






active

oldest

votes


















0














Here's a brief overview of how to setup a trigger.



First create the trigger function:



CREATE OR REPLACE FUNCTION my_trigger_function()
RETURNS TRIGGER AS
$BODY$
BEGIN
UPDATE apps
SET updated_time = NOW();

RETURN NEW;
END
$BODY$
LANGUAGE plpgsql;


It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.



Then you create a trigger on the builds_result table to execute this function:



CREATE TRIGGER upd
AFTER INSERT ON builds_result
FOR EACH ROW
EXECUTE PROCEDURE my_trigger_function();


That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here's a brief overview of how to setup a trigger.



    First create the trigger function:



    CREATE OR REPLACE FUNCTION my_trigger_function()
    RETURNS TRIGGER AS
    $BODY$
    BEGIN
    UPDATE apps
    SET updated_time = NOW();

    RETURN NEW;
    END
    $BODY$
    LANGUAGE plpgsql;


    It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.



    Then you create a trigger on the builds_result table to execute this function:



    CREATE TRIGGER upd
    AFTER INSERT ON builds_result
    FOR EACH ROW
    EXECUTE PROCEDURE my_trigger_function();


    That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.






    share|improve this answer




























      0














      Here's a brief overview of how to setup a trigger.



      First create the trigger function:



      CREATE OR REPLACE FUNCTION my_trigger_function()
      RETURNS TRIGGER AS
      $BODY$
      BEGIN
      UPDATE apps
      SET updated_time = NOW();

      RETURN NEW;
      END
      $BODY$
      LANGUAGE plpgsql;


      It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.



      Then you create a trigger on the builds_result table to execute this function:



      CREATE TRIGGER upd
      AFTER INSERT ON builds_result
      FOR EACH ROW
      EXECUTE PROCEDURE my_trigger_function();


      That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.






      share|improve this answer


























        0












        0








        0







        Here's a brief overview of how to setup a trigger.



        First create the trigger function:



        CREATE OR REPLACE FUNCTION my_trigger_function()
        RETURNS TRIGGER AS
        $BODY$
        BEGIN
        UPDATE apps
        SET updated_time = NOW();

        RETURN NEW;
        END
        $BODY$
        LANGUAGE plpgsql;


        It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.



        Then you create a trigger on the builds_result table to execute this function:



        CREATE TRIGGER upd
        AFTER INSERT ON builds_result
        FOR EACH ROW
        EXECUTE PROCEDURE my_trigger_function();


        That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.






        share|improve this answer













        Here's a brief overview of how to setup a trigger.



        First create the trigger function:



        CREATE OR REPLACE FUNCTION my_trigger_function()
        RETURNS TRIGGER AS
        $BODY$
        BEGIN
        UPDATE apps
        SET updated_time = NOW();

        RETURN NEW;
        END
        $BODY$
        LANGUAGE plpgsql;


        It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.



        Then you create a trigger on the builds_result table to execute this function:



        CREATE TRIGGER upd
        AFTER INSERT ON builds_result
        FOR EACH ROW
        EXECUTE PROCEDURE my_trigger_function();


        That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 17:29









        404404

        3,0851726




        3,0851726

















            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python