update-statement()

This function executes a data changing SQL statement a on the database being represented by alias b. Placeholders in the form of &parameterNumber being defined in the statement are replaced by the values of parameters c to j. Characters that are needed for a valid syntax need to be placed in the statement.

If an INSERT statement is executed and if the table contains columns where the values are generated automatically, the names of these columns can be specified as comma-separated list k if these values are needed during the mapping.

After the execution of the statement, the number of affected rows is returned. If m is true, the return value is -1 in case of an SQL error. If k has been set with a list of column names, a list SQL_AUTOGEN_KEY is created containing the values of the specified columns in the same order as they have been set in k.

Important note: In addition to the use of &parameterNumber for parameters it is possible to use the naming scheme for 'prepared statements'. The use of this prevents SQL Injection Attacks and should be preferred.

Parameters


Parameter

Description

a

SQL statement to be called.

b

The database alias.

c

(optional) Parameter &1 of the statement.

d

(optional) Parameter &2 of the statement.

e

(optional) Parameter &3 of the statement.

f

(optional) Parameter &4 of the statement.

g

(optional) Parameter &5 of the statement.

h

(optional) Parameter &6 of the statement.

i

(optional) Parameter &7 of the statement.

j

(optional) Parameter &8 of the statement.

k

(optional) Comma-separated list of column names with autogen functionality whose values should be saved for later use.

l

(optional) Number of maximum rows to be affected (if supported by the driver). 0 means all. Default: 0.

m

(optional) If true, SQL errors coming from the database are ignored. Default: <empty> (== false).


Examples


Defined is a map zipcodes containing all ZIP codes of Germany (imaginary 20000 entries). The primary key is the column ID with autogen feature.


Parameter a

Parameter b

Parameter c

Parameter d

Parameter e…j

Parameter k

Parameter l

Parameter m

Result

update zipcodes set city = '&1' where city = '&2'

testdb

München

Muenchen





243

update zipcodes set city = '&1' where city = '&2'

testdb

München

Muenchen



5


5

update zipcodes set city = @1:s@ where city = @2:s@

testdb

München

Muenchen





243

insert into zipcodes (zipcode,city,county)

values ('99999', 'Palma de Mallorca', 'New federal state')

testdb




id



1

After the call of the INSERT statement a list SQL_AUTOGEN_KEY is created containing the value of the newly generated row's primary key 20001.