Original Author Paul Laughton, 2011
Page 150
De Re BASIC!
SQLITE Commands
Sql.open <DB_pointer_nvar>, <DB_name_sexp>
Opens a database for access. If the database does not exist, it will be created.
<DB_pointer_nvar> is a pointer to the newly opened database. This value will be set by the sql.open
command operation. <DB_pointer_nvar> is used in subsequent database commands and should not be
altered.
<DB_name_sexp> is the filename used to hold this database. The base reference directory is "<pref base
drive>/com.rfo.basic/databases/". If <DB_name_sexp> = ":memory:" then a temporary database will be
created in memory.
Note: You may have more than one database opened at same time. Each opened database must have its
own, distinct pointer.
Sql.close <DB_pointer_nvar>
Closes a previously opened database. <DB_pointer_nvar> will be set to zero. The variable may then be
reused in another sql.open command. You should always close an opened database when you are done
with it. Not closing a database can reduce the amount of memory available on your Android device.
Sql.new_table <DB_pointer_nvar>, <table_name_sexp>, C1$, C2$, ...,CN$
A single database may contain many tables. A table is made of rows of data. A row of data consists of
columns of values. Each value column has a column name associated with it.
This command creates a new table with the name <table_name_sexp> in the referenced opened
database. The column names for that table are defined by the following: C1$, C2$, ..., CN$. At least one
column name is required. You may create as many column names as you need.
BASIC! always adds a Row Index Column named "_id" to every table. The value in this Row Index Column
is automatically incremented by one for each new row inserted. This gives each row in the table a
unique identifier. This identifier can be used to connect information in one table to another table. For
example, the _id value for customer information in a customer table can be used to link specific orders
to specific customers in an outstanding order database.
Sql.drop_table <DB_pointer_nvar>, <table_name_sexp>
The table named <table_name_sexp> in the opened database pointed to by <DB_pointer_nvar> will be
dropped from the database if the table exists.
Sql.insert <DB_pointer_nvar>, <table_name_sexp>, C1$, V1$, C2$, V2$, ..., CN$, VN$
Inserts a new row of data columns and values into a table in a previously opened database.
The <table_name_sexp> is the name of the table into which the data is to be inserted. All newly inserted
rows are inserted after the last, existing row of the table.