Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Specifying the WHERE clause for update/delete – PB Docs 80 – PowerBuilder Library

Specifying the WHERE clause for update/delete – PB Docs 80

Specifying the WHERE clause for update/delete

Sometimes multiple users are accessing the same tables at
the same time. In these situations, you need to decide when to allow
your application to update the database. If you allow your application to
always update the database, it could overwrite changes made by other
users:

aacu06.gif

You can control when updates succeed by specifying which columns PowerBuilder includes
in the WHERE clause in the UPDATE or DELETE statement used to update
the database:

note.gif Using timestamps Some DBMSs maintain timestamps so you can ensure that users are
working with the most current data. If the SELECT statement for
the DataWindow object contains a timestamp column, PowerBuilder includes
the key column and the timestamp column in the WHERE clause for
an UPDATE or DELETE statement regardless of which columns you specify
in the Where Clause for Update/Delete box.

If the value in the timestamp column changes (possibly due
to another user modifying the row), the update fails.
To see whether you can use timestamps with
your DBMS, see Connecting to Your Database
.

Choose one of the following in the Where Clause for Update/Delete
box (the results are illustrated by an example following the table):

Option Result
Key Columns The WHERE clause includes the key columns
only (these are the columns you specified in the Unique Key Columns
box)The values in the originally retrieved key columns for the
row are compared against the key columns in the database. No other comparisons
are done. If the key values match, the update succeeds

note.gif Caution Be very careful when using this option. If you tell PowerBuilder only
to include the key columns in the WHERE clause and someone else
modified the same row after you retrieved it, their changes will
be overwritten when you update the database (see the example following
this table)

Use this option only with a single-user database or if you
are using database locking. In other situations, choose one of the
other two options described in this table

Key and Updatable Columns The WHERE clause includes all key and
updatable columnsThe values in the originally retrieved key columns and the originally
retrieved updatable columns are compared against the values in the
database. If any of the columns have changed in the database since
the row was retrieved, the update fails
Key and Modified Columns The WHERE clause includes all key and
modified columnsThe values in the originally retrieved key columns and the
modified columns are compared against the values in the database.
If any of the columns have changed in the database since the row
was retrieved, the update fails

Example

Consider this situation: a DataWindow object is updating the Employee
table, whose key is Emp_ID; all columns in the table are
updatable. Say the user has changed the salary of employee 1001
from $50,000 to $65,000. This is what happens
with the different settings for the WHERE clause columns:

  • If you choose Key Columns
    for the WHERE clause, the UPDATE statement looks like this:

    This statement will succeed regardless of whether
    other users have modified the row since your application retrieved
    the row

    . For example, if another user had modified the
    salary to $70,000, that change will be overwritten when
    your application updates the database.

  • If you choose Key and Modified Columns for the WHERE
    clause, the UPDATE statement looks like this:

    Here the UPDATE statement is also checking the original value
    of the modified column in the WHERE clause. The statement will fail
    if another user changed the salary of employee 1001 since your application retrieved the
    row.

  • If you choose Key and Updatable Columns for the
    WHERE clause, the UPDATE statement looks like this:


    Here the UPDATE statement is checking all updatable columns
    in the WHERE clause. This statement will fail if any of the updatable
    columns for employee 1001 have been changed since your application retrieved
    the row.

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x