Last modified by Danniar Firdausy on 2024/09/18 20:02

From version 18.1
edited by Erik Bakker
on 2023/01/23 10:06
Change comment: There is no comment for this version
To version 23.6
edited by Danniar Firdausy
on 2024/09/18 20:02
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ebakker
1 +XWiki.dfirdausy
Content
... ... @@ -2,6 +2,8 @@
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 +
5 5  Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]].
6 6  
7 7  == 1. Prerequisites ==
... ... @@ -14,7 +14,7 @@
14 14  
15 15  == 3. Update database after retrieval ==
16 16  
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.
19 +In a 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.
18 18  
19 19  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}}.
20 20  
... ... @@ -24,22 +24,20 @@
24 24  
25 25  In this example, we search for all rows within the table for which the value in the column processed is equal to false. If so, the select statement will return each row. After the query returns all rows, the update query will ensure that all these rows will be updated by changing the value in the column processed to true. This way, you ensure these records won't be retrieved the next time we execute the select statement.
26 26  
27 -== 4. Assignment ==
29 +== 4. Key takeaways ==
28 28  
29 -See if you can find any database implementation within the projects you can access. This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment.
31 +* eMagiz allows you to execute an update statement immediately after a select statement.
32 +* This feature is particularly useful for tracking and updating record statuses, preventing repeated retrieval of the same records.
33 +* The update statement applies to all rows returned by the select query, with the changes based on the specified conditions in the where clause.
30 30  
31 -== 5. Key takeaways ==
35 +== 5. Suggested additional readings ==
32 32  
33 -* eMagiz offers the option to execute an update statement right after a select statement
34 -* In the database, this can be useful when tracking the status.
35 -* The update statement will update all rows returned via the select statement, assuming they pass the where clause
36 -
37 37  If you are interested in this topic and want more information, please read the help text provided by eMagiz and read more information on the following link:
38 +* [[Intermediate Level (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.WebHome||target="blank"]]
39 +** [[Solution Architecture (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.WebHome||target="blank"]]
40 +*** [[SQL Query (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Database connectivity.intermediate-database-connectivity-sql-query||target="blank"]]
41 +* [[Update database (Search Results)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&l_space_facet=10&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22update+database%22||target="blank"]]
42 +* [[SQL Explained (External)>>https://www.w3schools.com/sql/default.Asp||target="blank"]]
38 38  
39 -* [[SQL Explained>>https://www.w3schools.com/sql/default.Asp||target="blank"]]
40 40  
41 -== 7. Silent demonstration video ==
42 -
43 -This video demonstrates how you could have handled the assignment and gives you some context on what you have just learned.
44 -
45 -{{video attachment="intermediate-database-connectivity-update-database-after-retrieval.mp4" reference="Main.Videos.Microlearning.WebHome"/}})))((({{toc/}}))){{/container}}{{/container}}
45 +)))((({{toc/}}))){{/container}}{{/container}}