SqlInsert



This command inserts data into a table in a SQLite database. It comes in three different forms to allow flexibility in parameter format.
In all of the forms (n) is the database number and (table$) is the name of the table.

An automatically generated column is always added as the first column. This is the standard "_id" column.
Here is the SQLite column definition:
"_id INTEGER PRIMARY KEY AUTOINCREMENT"

SqlInsert n, table$, col1$, val11$ {, col2$, val2$...}

In this form the column names and values are paired one after another.

SqlInsert 1, "People", "FirstName","Will", "LastName","Robinson", "Age","12", "Sex","M"


SqlInsertI n, table$, ItemizedCols$, ItemizedVals$ {,delimiter$}

In this form the column names and values are stored as a Delimited String. The delimiter character is optional and will default to a comma if not specified.

columns$ = "FirstName,LastName,Age,Sex"

values$ = "Zachary,Smith,55,M"

SqlInsertI 1, "People", columns$, values$

or

SqlInsertI 1, "People", "FirstName-LastName-Age-Sex", "Zachary-Smith-55-M", "-"


Working with Arrays

SqlInsertA n, table$, columns$(), values$()

In this form the column names and values are stored in two arrays.

Dim columns$(3) = "FirstName", "LastName", "Age", "Sex"
Dim values$(3) = "Penny", "Robinson", "16", "F"

SqlInsertA 1,"People", columns$(), values$()



The array values$() may also be a two dimensional array where the records are arranged values$(rows,columns). Here each row refers to a record and the columns is the index the specified columns$() array.

For example:

Dim columns$(3) = "FirstName", "LastName", "Age", "Sex"
Dim values$(1,3)

values$(0,0) = "Penny"
values$(0,1) = "Robinson"
values$(0,2) = "16"
values$(0,3) = "F"

values$(1,0) = "Judy"
values$(1,1) = "Robinson"
values$(1,2) = "26"
values$(1,3) = "F"

SqlInsertA 1,"People", columns$(), values$()





SqlOpen


SqlClose


SqlAddTable


SqlDelTable


SqlUpdate


SqlDelete


SqlExec


SqlGetTableNames$(n)


SQLite Cursor






Become a Patron