Customer Portal

Write SUCCESS flag to Database After Successful DB Output

Comments 4

  • Avatar
    Pedro Vazquez Rosario
    0
    Comment actions Permalink
    Hi listsos,

    The output port you are utilizing to set the flag is only returns rejected records, which works well for the Failure Flag. Now to set the Success flag, I would recommend using the second output port and set a returning statement to output a record inserted. It's also imported to note that the second out will return a value regardless if the record was added. To resolve this, I would recommend filtering any null values from the return record.

    exampleDB.PNG
  • Avatar
    listsos
    0
    Comment actions Permalink
    Thanks for your reply!

    I have moved the SUCCESS job the Port 1. I don't have any metadata selected for the connection as the SUCCESS job will simply be running "UPDATE STATUS_TABLE set STATUS = 'SUCCESS" presuming the graph completes successfully.

    When running the job, it now errors stating "No metadata and no metadata stub defined for edge". What should be included in the Metadata, no data is really being passed along to the second database write.
  • Avatar
    listsos
    0
    Comment actions Permalink
    Also note that the first DB Output Table job (after the MEMGET) will add thousands of records. I simply want to add a single SUCCESS or FAILURE flag to another database table when the graph completes.
  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hello Listsos,
    the DBOutputTable is capable of returning records that were successfully inserted into a database, as well as returning those that failed. You could take advantage of one of these features to achieve the desired result. Attached is an example solution of how this can be approached. The main idea of the graph is that the query (which is updating the status table) is stored in a dictionary as a single string value and is set to "UPDATE STATUS_TABLE set STATUS = 'SUCCESS'" by default. If no record fails in the process of inserting data into the database, the DBOutputTable component will not send any records on the port 0, thus not affecting the query in the dictionary. On the contrary, if there was even a single record that failed during the inserting process, it will result in changing the dictionary value to "UPDATE STATUS_TABLE set STATUS = 'FAIL'". In the next phase, there is a DBExecute component that will run the query in the dictionary and update the status table respectively.
    Kind regards,

Please sign in to leave a comment.