1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package androidx.sqlite.db
17 
18 /** An interface to map the behavior of [android.database.sqlite.SQLiteStatement]. */
19 public interface SupportSQLiteStatement : SupportSQLiteProgram {
20     /**
21      * Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example
22      * CREATE / DROP table, view, trigger, index etc.
23      *
24      * @throws [android.database.SQLException] If the SQL string is invalid for some reason
25      */
executenull26     public fun execute()
27 
28     /**
29      * Execute this SQL statement, if the the number of rows affected by execution of this SQL
30      * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.
31      *
32      * @return the number of rows affected by this SQL statement execution.
33      * @throws [android.database.SQLException] If the SQL string is invalid for some reason
34      */
35     public fun executeUpdateDelete(): Int
36 
37     /**
38      * Execute this SQL statement and return the ID of the row inserted due to this call. The SQL
39      * statement should be an INSERT for this to be a useful call.
40      *
41      * @return the row ID of the last row inserted, if this insert is successful. -1 otherwise.
42      * @throws [android.database.SQLException] If the SQL string is invalid for some reason
43      */
44     public fun executeInsert(): Long
45 
46     /**
47      * Execute a statement that returns a 1 by 1 table with a numeric value. For example, SELECT
48      * COUNT(*) FROM table;
49      *
50      * @return The result of the query.
51      * @throws [android.database.sqlite.SQLiteDoneException] if the query returns zero rows
52      */
53     public fun simpleQueryForLong(): Long
54 
55     /**
56      * Execute a statement that returns a 1 by 1 table with a text value. For example, SELECT
57      * COUNT(*) FROM table;
58      *
59      * @return The result of the query.
60      * @throws [android.database.sqlite.SQLiteDoneException] if the query returns zero rows
61      */
62     public fun simpleQueryForString(): String?
63 }
64