SQLDelight in Android: Getting Started

Aug 3 2021 · Kotlin 1.4, Android 11, Android Studio 4.1

Part 1: Preparation & Setup

07. Use Grouping Statements

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 06. Add Functions to Tables Next episode: 08. Utilize Transactions & Rollbacks

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

If you have followed along with the sample app until this point, there are only two functions missing before the UI is completely functional, and we can find them in the CollectionDetailViewModel.

insert {
}
insert {
+    INSERT INTO bug(name, description)
+    VALUES (:name, :description);
}
insert {
    INSERT INTO bug(name, description)
    VALUES (:name, :description);

+    INSERT INTO bugAttributes(bugId, size, weight, attack, defense)
+    VALUES (..., :size, :weight, :attack, :defense);
}
insert {
    INSERT INTO bug(name, description)
    VALUES (:name, :description);

    INSERT INTO bugAttributes(bugId, size, weight, attack, defense)
-    VALUES (...), :size, :weight, :attack, :defense);
+    VALUES ((SELECT last_insert_rowid()), :size, :weight, :attack, :defense);
}
fun addBug(
    name: String,
    description: String?,
    size: String,
    weight: String,
    attack: Int,
    defense: Int
) {
    database.bugQueries.insert(name, description, size, weight, attack, defense)
}