Creating an update application

This section shows how to create an application that updates the database.

NoteThis tutorial demonstrates using connection cache to sampledb when creating database elements. An alternate approach is to use a direct JDBC connection to sampledb, as demonstrated in “Multipage mobile application tutorial”.

StepsCreating the update application

  1. From Mobile Web Studio, select Applications in the left pane, select New in the Application Manager Status menu, and click New. The Application Builder launches.

  2. Create a database element:

    1. Click the down arrow to the right of Add, and select Database Element.

    2. On the Database Element Definition window, make sure the Connection Cache option is selected.

    3. In Conn Cache Name, select sampledb from the drop-down list.

    4. In SQL Query String, enter this query for update (you can copy and paste this code from an electronic source):

      update sales_order_items set quantity =
      @OP["quantity"="13"]where id = @OP["id"="-1"]
      and prod_id = @OP["prod_id"="-1"]
      

      NoteThis SQL code updates the database, so no preview is available.

    5. Click Next. The Define window displays.

    6. Click Next. The Filter window displays.

    7. Click Next. The Configure Parameters window displays, with a list of the parameters used to create the database table.

    8. On the Configure Parameters window, make these modifications (accept the defaults for all others):

      • Quantity – click the Variable box, and from the Kind drop-down list, select Update.

      • Click the Variable box next to the other two parameters and accept the defaults.

    9. Click Next. The Window Preview window displays.

    10. In Element Name, enter updateOrder, and click Finish.

  3. In Application Builder, click Save.

  4. In the Finish window, click the Data Validation tab and make these changes to set up data validation for the Quantity field:

    1. Common Expressions – select Number Only from the drop-down list. The expression ^[0-9]*$ displays in the Validation Expression box.

    2. Click Test to test the expression you entered. The Regular Expression Tester window displays.

    3. In Test Value, enter 10, then click Test. The Test Result field displays Valid.

    4. Click Save to close the window.

    5. Detailed Instructions – optionally enter instructions for the user, such as Enter the quantity.

    6. Error Message – optionally enter a brief error message, such as You must enter a number.

      Figure 4-1: Data validation tab

  5. Click Finish to save the application.

  6. Click OK in the confirmation pop-up window.

  7. Click Close to exit the Application Builder.

  8. When you return to the Mobile Web Studio main window, select New from the Application Builder Status menu. The updateOrder application displays in the detail pane.

  9. In Mobile Web Studio, right-click the updateOrder application in the detail pane, and select Approval Status | Approved.

    Click OK.

  10. Select Approved from the Application Manager Status menu. You see the newly approved updateOrder application in the detail pane.