 |
|
Oracle Database Tips by Donald Burleson |
Examining APEX's Automatic Row Processing (DML)
It is also important to understand what the
Automatic Row Processing is doing for us. Navigate to the Process Row
of CONFERENCE_RSVP page process by clicking on the link in the
Processes section under Page Processing. Not to diminish the
importance of the other regions, the most important region in the
Automatic Row Processing (DML) process in the Source region as shown
in Figure 8.5. For the rest of the discussion, Automatic Row
Processing will be referred to as ARP.
The ARP dynamically performs SQL INSERTs, UPDATEs,
and DELETEs. Page items can either be set to participate in the
dynamic SQL statements or not. Adding a page item to participate in
the dynamic SQL statements is explained later in the section, Adding a
Page Item to a Form. The ARP is set to a process point of On Submit - After Computations and Validations. That way validation for all page
items can be performed before attempting to update the data in the
database.
§
The values here indicate the types
of dynamic SQL that can be utilized by this ARP. For example, if the
developer does not want to allow any DELETE operations, the Delete
option would be unchecked. Many database systems today do not do
DELETEs; they simply mark the row as an inactive row. In that case, a
custom page process would be created to update the database record.
§
During
an INSERT process, there may be triggers that populate the primary key
columns during INSERT. The value returned will be based on the column
identified in the Primary Key Column above and will be returned into a
page item entered here. In the example in Figure 8.5, the value
inserted in the id column
would be returned and the session state would be set for the item
entered in the Return Key Into Item field. The value returned could
then be used by subsequent page processes.
§
These are
REQUEST values that will cause the ARP to generate and execute the
dynamic UPDATE statement. Developers need to know this if they create
their own buttons on a page. The REQUEST for the button must be set
to one of these values if the developer wants the button to cause the
ARP to perform an UPDATE.
§
These are REQUEST values that will cause the
ARP to generate and execute the dynamic INSERT statement. Set the
REQUEST for any user created buttons to one of these values to cause
the button to drive the ARP to perform an INSERT.
§
These are REQUEST values that will cause the
ARP to generate and execute the dynamic DELETE statement. Set the
REQUEST for any user created buttons to one of these values to cause
the button to drive the ARP to perform an DELETE.
Special Note About
REQUEST and Database Action
The previous section mentioned the Valid … Request
Values. The Database Action was also mentioned earlier. Either one
of these can cause the Automatic Row Processing (DML) to produce
dynamic SQL.
If
we were to change the name of the SAVE button to SAVESOMETHING, the
ARP would still perform an UPDATE because the Database Action is set
to SQL UPDATE action. At that point, the Database Action takes
precedence over the name of the button. In fact, the SQL UPDATE
action sets the REQUEST to SAVE.
If
we kept the button name as SAVE and removed the Database Action, the
ARP would again work because the REQUEST is set to a value matching
the name of the button. In this case, the REQUEST would be SAVE.
Since SAVE is one of the Valid Update Request Values, the ARP will
still produce a dynamic UPDATE statement.
It is apparent that there is more than one way to
cause the ARP to produce dynamic SQL.
The above book excerpt is from:
Easy HTML-DB
Oracle Application Express
Create
Dynamic Web Pages with OAE
ISBN 0-9761573-1-4
Michael Cunningham & Kent Crotty
http://www.rampant-books.com/book_2005_2_html_db.htm |