Support Grouping Multiple SQL Statements
See original GitHub issueBackground I would like bring up the conversation of supporting grouping multiple SQL statements together to make it possible to use a single model in Java/Kotlin.
Usage Following is a simple use case.
Let’s say we have two tables:
salary
+-----+-----------------+--------+
| _id | title | salary |
+-----+-----------------+--------+
| 1 | Sales Associate | 1000 |
+-----+-----------------+--------+
| 2 | Manager | 1500 |
+-----+-----------------+--------+
salaryChangeNotes
+-----+----------+------------------------------------------+
| _id | time | updateNote |
+-----+----------+------------------------------------------+
| 1 | 20170918 | Increase manager's salary to 1500 |
+-----+----------+------------------------------------------+
| 2 | 20180417 | Increase sale associate's salary to 1000 |
+-----+----------+------------------------------------------+
Every time we update the salary table, we would like to insert a note into salaryChangeNotes table.
One possible implementation probably would be like this:
salary.sq
// ... create table, other logic, etc
GROUP_STATEMENTS updateSalaryRecord {
UPDATE salary
SET salary=?
WHERE title=?;
INSERT INTO salaryChangeNotes(time, updateNote)
VALUES(?, ?);
}
So in business logic, we only need to call
updateSalaryModel.bind(2000, "Manager", "20180418", "Increase manager's salary to 2000");
// Wrap return values from multiple sql statements is something we need to take care of
int updated = updateNumber.executeGroupStatement();
With more statements being grouped together, the implementation of this feature will be cleaner compared with the current approach.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Introduction to SQL GROUP BY Multiple Columns - eduCBA
SQL GROUP BY multiple columns is the technique using which we can retrieve the summarized result set from the database using the SQL...
Read more >What Is the SQL GROUPING SETS Clause, and How Do You ...
GROUPING SETS in SQL can be considered an extension of the GROUP BY clause. It allows you to define multiple grouping sets in...
Read more >SQL GROUP BY Statement - W3Schools
The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group...
Read more >Use a union query to combine multiple queries into a single ...
On the Create tab, in the Queries group, click Query Design. · On the Design tab, in the Query group, click Union. ·...
Read more >Group by Multiple Columns in SQL - Scaler Topics
To arrange similar (identical) data into groups, we use SQL GROUP BY clause. The SQL GROUP BY clause is used along with some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yes it is done, i just have to write the code
Any update on this?