PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The OWA_OPT_LOCK
package contains subprograms that impose optimistic locking strategies so as to prevent lost updates.
This chapter contains the following topics:
The OWA_OPT_LOCK package contains subprograms that impose optimistic locking strategies, so as to prevent lost updates.
It checks if the row that the user is interested in updating has been changed by someone else in the meantime.
The PL/SQL Gateway cannot use conventional database locking schemes because HTTP is a stateless protocol. The OWA_OPT_LOCK
package gives you two ways of dealing with the lost update problem:
These methods are optimistic. They do not prevent other users from performing updates, but they do reject the current update if an intervening update has occurred.
This data type is a PL/SQL table intended to hold ROWIDs.
TYPE VCARRAY IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER
Note that this is different from the OWA_TEXT
.VC_ARR DATA TYPE
.
Subprogram | Description |
---|---|
Returns the checksum value | |
Returns the ROWID value | |
Stores unmodified values in hidden fields for later verification | |
Verifies the stored values against modified values |
This function returns a checksum
value for a specified string, or for a row in a table. For a row in a table, the function calculates the checksum
value based on the values of the columns in the row. This function comes in two versions.
The first version returns a checksum
based on the specified string. This is a "pure" 32-bit checksum
executed by the database and based on the Internet 1 protocol.
The second version returns a checksum
based on the values of a row in a table. This is a "impure" 32-bit checksum based on the Internet 1 protocol.
OWA_OPT_LOCK.CHECKSUM( p_buff IN VARCHAR2) RETURN NUMBER; OWA_OPT_LOCK.CHECKSUM( p_owner IN VARCHAR2, p_tname IN VARCHAR2, p_rowid IN ROWID) RETURN NUMBER;
Parameter | Description |
---|---|
|
The nstring where you want to calculate the |
|
The owner of the table. |
|
The table name. |
|
The row in |
This function returns the ROWID
data type from the specified OWA_OPT_LOCK.VCARRAY
DATA
TYPE.
OWA_OPT_LOCK.GET_ROWID( p_old_values IN vcarray) RETURN ROWID;
Parameter | Description |
---|---|
|
This parameter is usually passed in from an HTML form. |
This procedure stores the column values of the row that you want to update later. The values are stored in hidden HTML form elements.
OWA_OPT_LOCK.STORE_VALUES( p_owner IN VARCHAR2, p_tname IN VARCHAR2, p_rowid IN ROWID);
Parameter | Description |
---|---|
|
The owner of the table. |
|
The name of the table. |
|
The row where you want to store values. |
Before updating the row, compare these values with the current row values to ensure that the values in the row have not been changed. If the values have changed, you can warn the users and let them decide if the update should take place.
The procedure generates series of hidden form elements:
old
_p_tname
", where p_tnam
e is the name of the table. The value of the element is the owner name.old
_p_tname
", where p_tname
is the name of the table. The value of the element is the table name.old
_p_tname
", where p_tname
is the name of the table. The value of the element is the column value.See also the VERIFY_VALUES Function.
This function verifies whether values in the specified row have been updated since the last query. Use this function with the STORE_VALUES Procedure.
OWA_OPT_LOCK.VERIFY_VALUES( p_old_values IN vcarray) RETURN BOOLEAN;
Parameter | Description |
---|---|
|
A PL/SQL table containing the following information:
The remaining indexes contain values for the columns in the table. Typically, this parameter is passed in from the HTML form, where you have previously called the STORE_VALUES Procedure to store the row values on hidden form elements. |
TRUE
if no other update has been performed, otherwise FALSE
.