Documentation Index

Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt

Use this file to discover all available pages before exploring further.

update-statement()

Prev Next

This function runs a data-changing SQL statement a on the database represented by alias b. Placeholders in the form &parameterNumber in the statement are replaced by the values of parameters c to j. Characters required for valid syntax (for example, quotes around strings) must already be part of the statement.

If you run an INSERT statement and the target table has columns with automatically generated values, you can specify the names of these columns as a comma-separated list in k. This saves the generated values for later use in the Mapping.

The function returns the number of affected rows after execution. If m is set to true, it returns -1 in case of an SQL error. If k contains a list of column names, the function creates a list SQL_AUTOGEN_KEY. This list contains the values of the individual columns in the order defined in k.

NOTE:

In addition to the &parameterNumber notation, you can also use the notation for prepared statements in the form @parameterNumber:parameterType@. Prefer prepared statements, because they prevent SQL injection attacks. Within prepared statements, parameters replace only single values. You cannot use them to pass value lists for IN, table or column names, operators, sort orders, or complete SQL fragments.

Parameters

Parameter

Description

a

SQL statement to run.

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. The function saves their values for later use.

l

(optional) Maximum number of rows to affect (if supported by the driver). 0 means all. Default: 0.

m

(optional) If true, the function ignores SQL errors reported by the database. Default: <empty> (== false).

Examples

Assume a table zipcodes that contains the ZIP codes of Germany (an imaginary 20000 entries). The primary key is the column id with the autogen property. Each example is independent and is based on the same starting data in the table.

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 INSERT call, a list SQL_AUTOGEN_KEY is created. It contains the value 20001 of the newly generated primary key.