Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development

> ## Refreshing the database query

> One of the most important things to keep in mind when using SDOs is that they always operate on a temp-table that is a snapshot of the database at the time the temp-table was built. This represents a compromise of some of the immediacy that older Progress applications could take advantage of. In an older host-based or client/server application, you always knew that the database record you were looking at was one you were actually positioned to, and that you could lock a record while you worked on it. The realities of distributed applications require us to design record processing in which the client is not so tightly coupled to the database.

> If you want to be able to run your application in a distributed environment, with databases on numerous machines in different locations, your client objects cannot sit on the actual database record, which is in a database they are not even connected to.

> Therefore, you sometimes need to refresh the `RowObject` query your client objects are looking at. For example, a part of the application might be using a row when another part of your application signals that a row has been modified. One way to do this is simply to invoke the `openQuery` function. This reopens the database query and reloads the `RowObject` temp-table. If you wish, you can save off the `RowIdent` of the row your client is currently positioned to and reposition to that record after the query is reopened, using code similar to that in our mark and return example above.

> If you simply want to refresh the row your client is currently looking at, you can refer to the third example in the sample reposition window. The Modify Row and Refresh Row buttons modify and then refresh a database record. The code under the Modify Row button simulates the situation of having a database record changed by another user while you are looking at it. It retrieves the current `Customer` record and changes the name, as shown:

>     /* ON CHOOSE OF Modify-Btn */
>     DO:
>       FIND customer WHERE customer.custNum = INT(Cust-Field:SCREEN-VALUE)
>          NO-ERROR.
>       IF AVAILABLE(Customer) THEN
>           Customer.NAME = Customer.NAME + " MOD!".
>     END.

> Note: Keep in mind that this is just a test procedure. In a real application window you would not do a database retrieval like this directly.

> You do not see this change because it does not immediately affect your `RowObject` dataset. If you want to confirm that you are looking at the latest values for a record, you can select the Refresh Row button. This runs the refreshRow procedure, which re-reads the current `RowObject` row out of the database and writes its current field values into the `RowObject` table, as shown:

>     /* ON CHOOSE OF Refresh-Btn */
>     DO:
>       RUN refreshRow IN h_dcust.
>     END.

> It also publishes the `dataAvailable` event, so that your viewer requests those fresh values and redisplays them. Select the dataAvailable button to see the `“MOD!”` to the `Customer` record, as shown:

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095