Changes for page Update database after retrieval
Last modified by Danniar Firdausy on 2024/09/18 20:02
From version 23.6
edited by Danniar Firdausy
on 2024/09/18 20:02
on 2024/09/18 20:02
Change comment:
There is no comment for this version
To version 23.5
edited by Danniar Firdausy
on 2024/09/11 10:38
on 2024/09/11 10:38
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -2,8 +2,6 @@ 2 2 3 3 In the previous [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.intermediate-database-connectivity-sql-query||target="blank"]] we discussed the fundamentals of SQL queries. In this microlearning, we will learn how you could update the record(s) in the database the moment after you have read the information from the database. This functionality can help you update a status field to ensure you won't keep reading the same record(s) repeatedly. 4 4 5 -In our previous [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.intermediate-database-connectivity-sql-query||target="blank"]], we explored the basics of SQL queries. Now, we will take it a step further by learning how to update database records immediately after retrieving them. This approach is useful for managing statuses, ensuring you do not repeatedly read, or retrieve, the same records. Let's dive into how this functionality works and how to implement it within eMagiz. 6 - 7 7 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 8 8 9 9 == 1. Prerequisites == ... ... @@ -16,7 +16,7 @@ 16 16 17 17 == 3. Update database after retrieval == 18 18 19 -In aprevious [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.intermediate-database-connectivity-sql-query||target="blank"]] we discussed the fundamentals of SQL queries. In this microlearning, we will learn how you could update the record(s) in the database the moment after you have read the information from the database. This functionality can help you update a status field to ensure you won't keep reading the same record(s) repeatedly.17 +In the previous [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.intermediate-database-connectivity-sql-query||target="blank"]] we discussed the fundamentals of SQL queries. In this microlearning, we will learn how you could update the record(s) in the database the moment after you have read the information from the database. This functionality can help you update a status field to ensure you won't keep reading the same record(s) repeatedly. 20 20 21 21 To update the records we just read from the table, we need a slightly different update statement. As you probably remember the update statement in the previous example was written as follows {{code language="sql"}}UPDATE mytable SET changeddate = :headers[timestamp] where id = :headers[id]{{/code}}. However, with this functionality, the update statement should look like this {{code language="sql"}}UPDATE mytable SET processed = TRUE where id IN (:id){{/code}}. 22 22 ... ... @@ -28,9 +28,9 @@ 28 28 29 29 == 4. Key takeaways == 30 30 31 -* eMagiz allowsyouto execute an update statement immediatelyafter a select statement.32 -* Thisfeature isparticularlyusefulfortrackingand updating recordstatuses, preventing repeated retrieval of the same records.33 -* The update statement appliestoall rows returnedbythe selectquery, withthechangesbased on thespecified conditionsinthe where clause.29 +* eMagiz offers the option to execute an update statement right after a select statement 30 +* In the database, this can be useful when tracking the status. 31 +* The update statement will update all rows returned via the select statement, assuming they pass the where clause 34 34 35 35 == 5. Suggested additional readings == 36 36