Using Application Express

APEX, formerly known as HTML DB, is a rapid Web application development tool requiring little or no programming experience. The applications you develop with APEX connect to any Oracle database, including Oracle Database XE, and therefore automatically inherit the scalability and security features inherent in an Oracle database.

APEX is completely menu driven. You use application wizards to create a new application or even convert an old application to a more robust platform. For example, you can easily import a single-user Microsoft Excel spreadsheet into APEX to not only make it a Web application available to any user with a Web browser, but also to import the data into Oracle Database XE. This makes your data more available and reliable; instead of residing on a user's local hard disk, the data resides in Oracle Database XE where it is backed up and available to a wider user audience.

You can develop APEX applications at the Oracle Database XE home page; however, APEX is updated more often than Oracle Database XE, so to get the latest features available in APEX, navigate to http://www.oracle.com/technology/products/database/application_express/index.html and click the download link to get the latest version.

■Note As of the writing of this book, the current stand-alone version of APEX was 3.0, and the version of APEX integrated with Oracle Database XE was 2.1.

Even though you cannot integrate a more recent version of APEX with your installation of Oracle Database XE, you can easily create an application in the current version of APEX installed in a different database and migrate the application to Oracle Database XE, and vice versa, with a high level of compatibility.

In the example starting with Figure 29-4, you create a simple APEX application to maintain the LOCATIONS table. Connect to Oracle Database XE as the HR user and click the Application Builder link on the Oracle Database XE home page. You'll see the Create Application page shown in Figure 29-4. As you proceed through the development of your application, the current step name in the process is highlighted on the left-hand side of the page.

Figure 29-4. Create Application start page

Since you're going to create an application using an existing table, accept the default selection, Create Application. Click the Next button. On the next page, specify an application name and number. In this example, the application name is Location Maintenance and the application number is 100. Since you're creating a new application, select the From Scratch radio button. Click the Next button.

On the Pages phase of Create Application shown in Figure 29-5, select the Tabular Form radio button to use the default template for editing rows in the LOCATIONS table. In the Table Name text box, enter LOCATIONS as the table you will maintain, or select the LOCATIONS table using the list box selector to the right of the text box.

Figure 29-5. Create Application Page Type page

Click the Add Page button to add this page to the list of application pages. The new page appears at the top of the Create Application page in the page list. Click the Next button. On the Tabs step, select the No Tabs radio button and click the Next button. On the Shared Components page—you don't have any shared components (yet!)—select the No radio button and click Next.

On the Attributes step shown in Figure 29-6, you can specify how you will authenticate with this application as well as what language preferences you want. You can use the existing database authentication (your Oracle Database XE username and password) or another layer of authentication provided by Application Express. In this example, accept the default, Database Account. Click Next.

Figure 29-6. Create Application attributes page

In the User Interface step, choose a theme for your application—in other words, how you want the colors to look on the page as well as the general look and feel. In this example, select Theme 9 and click Next.

The next page, the Confirm step, summarizes the attributes you have selected so far and gives you one more chance to revise them. You also have the option to save this application definition as a template for future applications by selecting the checkbox at the bottom of the page. Since everything looks fine, click the Create button. APEX builds your application and leaves you at the home page for the application: Application 100.

Click Run Application to start it. Enter a username and password on the next page; since you're going to edit the LOCATIONS table, enter the HR username and password since you know that the HR user owns the LOCATIONS table. However, you can supply any username that can view and edit the LOCATIONS table.

Figure 29-7 shows the LOCATIONS table maintenance page. You can edit, update, or delete existing locations. To add new rows, click the Add Row button. When you are done making changes and want to save them to the database, click the Submit button.

LOCATIONS HR ! Logout j

LOCATIONS ismwi u.mmm i^mn

□ LOCATION_ID_DISPLAY Street Address Postal Code City State Province Country Id

□ 1100 |93091 Calls dslla T |10934 ~ |Venice J |rr

□ 1200 |2017 Shinjuku-ku |1689 |Tokyo |Tokyo Prefecture |jP

□ 1400 |2014 Jabberwocky F [26192 [southlake |Texas |US

□ 1500 [2011 Interiors Blvd [99236 |South San Francisc [California fus

□ 1600 |2007Zagora St [50090 |South Brunswick |New Jersey |US

□ 1700 |2004 Charade Rd [98199 |Seattle [Washington |us

□ 1800 [l 47 Spadina Ave |M5V2L7 [Toronto foirtario [CA

□ 1900 |6092 Boxwood St |YSW 9T2 |Whitehorse |Yukon [CA

| Edit Application | Edit Page 1 | Create | Session | Debug | Show Edit Links |

Figure 29-7. Using the LOCATIONS maintenance application

Using PHP

Last, and certainly not least, you use PHP and your Apache Web server to access your Oracle database, using PHP scripts with calls to functions from Oracle's OCI8 client library. We provide an introduction to PHP's Oracle functionality in Chapter 32 and provide numerous examples throughout the rest of the book.

If your primary role is as a PHP developer, you will most likely be using the PHP/Oracle client libraries to connect to Oracle Database XE. However, don't forget about the other methods we presented earlier in this chapter. If something does not work right when your PHP code is trying to access Oracle, you will most likely try the same operation in SQL Developer or even SQL*Plus to help you narrow down the problem.

In Chapter 27, we enabled access to Oracle Database XE by removing a single semicolon in your PHP configuration file php.ini:

extension=oci8.so

In Chapter 32, we cover the methods you will use as a PHP developer to connect to Oracle Database XE, either as a native Oracle database call or via an abstraction layer to make it easy to port your PHP applications to another database platform if required by your target environment.

Was this article helpful?

0 0

Post a comment