Sqlite Toolkit - @octave_sqlite/sqlupdate


: sqlupdate (db, tablename, data, filter)
: sqlupdate (db, tablename, data, filter, propertyname, propertyvalue …)

Update rows of data into a table.

Update rows of data into a sqlite database table based on the input filter.

Inputs

db

Previously created octave_sqlite object

tablename

Name of table to write data to

data

Table containing data to write to the database. Variables names are expected to match the database.

filter

A Filter object or cell array of filter objects used to determine which rows of the table to update.

propertyname, propertyvalue

property name/value pairs where known properties are:

Catalog

An optional database catalog name.

Schema

An optional database schema name.

Outputs

None

Examples

Create a database table and insert a row

 
 # create sql connection
 db = sqlite("mytest.db", "create");
 # create table (if it does not exist) and then insert 2 rows
 t = dbtable([1;2],['Name1';'Name2'], 'VariableNames', {'Id','Name'});
 # insert table data
 sqlwrite(db, "Test", t, 'ColumnType', {'numeric', 'text'});
 # make a filter to select what to update
 rf = dbrowfilter({'Id'});
 rf = rf.Id > 1;
 # update name where Id > 1
 t = dbtable(['Name3'], 'VariableNames', {'Name'});
 sqlupdate(db, "Test", t, rf);
 
 

See also: sqlite, execute.