The Lock preference sets the isolation level to use when connecting to the database.
ODBC only
For UltraLite, only one application can connect to the database
at a time. However, a single application can have up to four separate
connections to the same database, and each connection can have a
separate transaction running. UltraLite does not provide alternative
locking behaviors and the lock value is set to Read Uncommitted
in PocketBuilder.
In multiuser databases, transactions initiated by different users can overlap. If these transactions access common data in the database, they can overwrite each other or collide.
To prevent concurrent transactions from interfering with each other and compromising the integrity of your database, certain DBMSs allow you to set the isolation level when you connect to the database. Isolation levels are defined by your DBMS and specify the degree to which operations in one transaction are visible to operations in a concurrent transaction. Isolation levels determine how your DBMS isolates or locks data from other processes while it is being accessed.
PocketBuilder uses the Lock preference to allow you to set various database lock options. Each lock value corresponds to an isolation level defined by your DBMS.
When to specify the Lock value
You must set the Lock value before you
connect to the database in the PocketBuilder development environment
or in a PocketBuilder application. The Lock value takes effect only
when the database connection occurs. Changes to the Lock value after
the connection occurs have no effect on the current connection.
You can set the Lock value in a script as a property of the Transaction object. The following syntax assumes you are using the default Transaction object, SQLCA, but you can also use a user-defined Transaction object:
SQLCA.Lock = "value"
where value is the lock value you want to set.
The following table lists the lock values and corresponding isolation levels for ODBC. You set the lock value in a PocketBuilder application script, and the isolation level in a database profile.
Lock values |
Isolation levels |
---|---|
RU RC RR TS TV |
Read Uncommitted Read Committed Repeatable Read Serializable Transactions Transaction Versioning |
For information about how SQL Anywhere handles isolation levels, see the chapter on using transactions and isolation levels in the SQL Anywhere Server SQL Usage book in the SQL Anywhere documentation.
Select the isolation level you want from the Isolation Level drop-down list on the Connection tab in the Database Profile Setup dialog box.
The default lock value depends on how your database is configured. For information, see your DBMS documentation.
The TV (Transaction Versioning) setting does not apply to SQL Anywhere databases.
Example 1 To set the Lock value to RC (Read Committed) for an SQL Anywhere database:
Development environment Select Read Committed from the Isolation Level drop-down list in the Database Profile Setup dialog box.
PocketBuilder application script Type the following in a script:
SQLCA.Lock = "RC"
If you specify Isolation Level in your database profile, the PowerScript syntax displays on the Preview tab in the Database Profile Setup dialog box. You can copy the syntax from the Preview tab into your script.