create an application with text file

5
 Oracle Application Express Tutorial 1 of 5 Week 5  Oracle Application Express Creating a Database-Centric Web Application Using Oracle Application Express (APEX) Purpose In this lab you will create an application. You will start with a text file that will be converted to tables in an Oracle database. From these tables, you will create an application. Topics This lab covers the following topics: Creating a Table from a Spreadsheet/Text file Normalize the database: Create a Related Table  Modifying a Table Creating an Application Editing Application Objects Applying a New Theme Examine the data set 1. Open the text file tasks.txt as an Excel spreadsheet. Note that the first row consists of column headings. There are 16 rows of data 2. Close the file. Creating a Table from a Text File To load the data for this tutorial from a text file, perform the following steps: 1. Login to the hosted Oracle site 2. To create the table based on a text file, click the down arrow next to Utilities > Data Load/Unload. 3. Click the down arrow next to Load, then click Text File . 4. Ensure that the import target (Import To) is set to New table. For Import From, select the Upload file (comma separated or tab delimited) option. Click Next >. 5. Click Browse.  6. Locate the tasks.txt file in the SQL Scripts directory and click Open. Because the data in the text file is tab delimited, enter \t in the Sepa rator field. The first row DOES contain the column names, so make sure that box is checked. Click Next >. 7. The Table Information page displays the columns in the table and their formats, as well as the data to be inserted into the table after the table is created. Verify that the fields have been imported correctly: the start_date and end_date fields have been accepted as date types and all others are character (VARCHAR2). There should be 16 rows of imported data. For Table Name, enter Tasks, and click Next >. 

Upload: joel-bautista

Post on 07-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Create an Application With Text File

8/4/2019 Create an Application With Text File

http://slidepdf.com/reader/full/create-an-application-with-text-file 1/5

  Oracle Application Express Tutorial

1 of 5

Week 5 – Oracle Application Express

Creating a Database-Centric Web Application Using Oracle Application Express(APEX)

Purpose

In this lab you will create an application. You will start with a text file that will beconverted to tables in an Oracle database. From these tables, you will create anapplication.

Topics

This lab covers the following topics:

Creating a Table from a Spreadsheet/Text file

Normalize the database: Create a Related Table 

Modifying a Table Creating an Application 

Editing Application Objects 

Applying a New Theme 

Examine the data set

1. Open the text file tasks.txt as an Excel spreadsheet. Note that the first row consists ofcolumn headings. There are 16 rows of data

2.  Close the file.

Creating a Table from a Text File

To load the data for this tutorial from a text file, perform the following steps:

1.  Login to the hosted Oracle site

2. To create the table based on a text file, click the down arrow next to Utilities > DataLoad/Unload.

3. Click the down arrow next to Load, then click Text File .

4. Ensure that the import target (Import To) is set to New table. For Import From, select theUpload file (comma separated or tab delimited) option. Click Next >. 

5. Click Browse. 6. Locate the tasks.txt file in the SQL Scripts directory and click Open. Because the data in the

text file is tab delimited, enter \t in the Separator field. The first row DOES contain the columnnames, so make sure that box is checked. Click Next >. 

7.  The Table Information page displays the columns in the table and their formats, as well as thedata to be inserted into the table after the table is created. Verify that the fields have beenimported correctly: the start_date and end_date fields have been accepted as date types and allothers are character (VARCHAR2). There should be 16 rows of imported data. For Table Nameenter Tasks, and click Next >. 

Page 2: Create an Application With Text File

8/4/2019 Create an Application With Text File

http://slidepdf.com/reader/full/create-an-application-with-text-file 2/5

  Oracle Application Express Tutorial

2 of 5

8.  Using the Primary Key page, you can add a system-generated primary key to your table andpopulate that column with a new sequence. Oracle uses sequences rather than Autonumberfields. This step saves a lot of manual coding because it automatically creates a primary keywith the generic name of ID. It also creates a new object, TASKS_SEQ and a primary keyconstraint named TASKS_PK. Review the default values, and click Load Data. 

9.  After the table is created and the data is loaded, you are left on the Files page. You can see thefile that you just uploaded with 16 rows successfully uploaded.

10. To view your new table, click Home and SQLWorkshop>Object Browser > Tables.

11. To view the table definition, click the Tasks table under the list of tables in the left navigator.

12. This page displays only the table definition. To view all the data in the table, click the Data tab. 

13. The rows of data are displayed.

Normalize the database: Create a related table

When you examine the table’s data you see that the description of the project isrepeated multiple times in the PROJECT column. This indicates that this table has notbeen normalized. The PROJECT column should be placed in a separate table along with

a project ID.

The Create Lookup Table feature in APEX easily performs this task for you. To create aseparate table on the Project column, perform the following steps:

1. Return to the Table Definition by clicking on the Table tab. 

2. Click Create Lookup Table button.

3. To specify the column on which the master table is to be created, select PROJECT - varchar2, and click Next > .

4. Enter the following values, and click Next >.

New Table Name: PROJECTS New Sequence: PROJECT_SEQ 

5. Click Finish. 

6. To see the definition of the new PROJECTS table, click PROJECTS in the Parent Tablecolumn.

7.  Note that the new PROJECTS table contains a numeric primary key along with the PROJECTcolumn.

8. Look again at the TASKS table and note that the PROJECT column is not in this table anymore – it moved to the PROJECTS table. The PROJECT column in the TASKS table has beenreplaced by the PROJECT_ID.

Modifying a Table

Now that you have the two main tables, enhance the PROJECTS table by adding aPROJECT LEAD column to it.To do this, perform the following steps:

1.  Make sure the PROJECTS table is selected. You are going to add a column to the table. ClickAdd Column.

Page 3: Create an Application With Text File

8/4/2019 Create an Application With Text File

http://slidepdf.com/reader/full/create-an-application-with-text-file 3/5

  Oracle Application Express Tutorial

3 of 5

2. Enter the following values, and click Next >. 

Add Column: PROJECT_LEAD Type: VARCHAR2 Length: 30

3. Click Finish. 

4.  You see the modified table definition with the new PROJECT_LEAD column added. Click theData tab to view the data.

5.  You see all the projects that were referenced in the TASKS table. You can change data from

here. Click the Edit icon ( ) on the left of Project Id for Public Website.

6. For Project Lead, enter your name. Click Apply Changes. 

7. You see the data that you added. To begin creating the application, click Home on thebreadcrumb menu. 

Creating an Application

To create the application, perform the following steps:

1. From the APEX home page, click the down arrow next to Application Builder > CreateApplication > Create Application.

2. For Name, enter Project Tasks Application. Keep the default value of From Scratch for theCreation Application, and click Next >. 

3. Select the Report Page Type and click the up arrow by Table_Name to select the table youwant the report to be based on.

4. Click PROJECTS. 

5. Select Classic for the Implementation

6. Click Add Page.

7. Select Report and Form Page Type and select PROJECTS(1) for Subordinate to Page. Then

click the up arrow by Table_Name to select the table.8. Click TASKS. 

9. Select Classic for the Implementation

10.Click Add Page. Your application should now look like this:

11.Click on the link Tasks for Page 2.

12. You need to link the PROJECTS Master Page with this page. The Projects table and the Taskstable are linked by the PROJECT_ID field. In the “Parent Page to This Page ColumnAssociations” section, select PROJECT for the Link Column, select PROJECT_ID for the parentreport column - column 1, select PROJECT_ID for the link to this report column - report column.Deselect the Use theme-specific edit button check box. The variable #PROJECT# shouldappear in the Link Text field. Click Apply Changes.

13.Select the PROJECTS link for Page 1. 

Page 4: Create an Application With Text File

8/4/2019 Create an Application With Text File

http://slidepdf.com/reader/full/create-an-application-with-text-file 4/5

Page 5: Create an Application With Text File

8/4/2019 Create an Application With Text File

http://slidepdf.com/reader/full/create-an-application-with-text-file 5/5

  Oracle Application Express Tutorial

5 of 5

between a displayed page and edit mode. This is very handy for editing, but be sure to ApplyChanges. Also note that you won’t see the changes in the displayed page unless you Refreshthe page in your browser!

9.  Click the Edit icon ( ) to the right of Start Date.

10. Under the Page Item section, select Date Picker (DD-MON-YYYY) from the Display As drop-down list. Click Apply Changes and then Cancel to close this edit page.

11. Click the Edit icon ( ) to the right of End Date.

12. Under the Page Item section, select Date Picker (DD-MON-YYYY) from the Display As drop-down list. Click Apply Changes and then Cancel to close this edit page.

13. Click the Edit icon ( ) to the right of Status.

14. Under the Page Item section, select Select List from the Display As drop-down list. From thelinks at the top of the page, click the LOV link.

15. Under the List of Values section, select STATUSES from the Named LOV drop-down list. Click

the Top icon ( ).

16. Click Apply Changes and then Cancel to close this edit page.

17. Click the Refresh button in your browser and notice the changes that occur. The Start Date andEnd Date format changes and the Status field use the List of Values. Click Hide Edit Links.Turn in a printout of this page

Applying a New Theme

When you created the application, you selected the red theme. You can change the lookand feel of the application by changing the theme. You first create a new theme byselecting one from the APEX Repository. To apply a new theme, perform the followingsteps:

1. Click the Application # link from the Developer Links at the bottom of the page.

2. Click the down arrow next to Shared Components > User Interface > Themes. 3. To create a new theme, click Create. 

4. Accept the default Repository and click Next >. 

5. From the Theme options, select the Theme 10 option. Click Next >. 

6. Click Create. 

7. To switch to the Sand theme, click Switch Theme. 

8. For Switch to Theme, make sure 10. Sand is selected. Click Next >. 

9.  Notice that the page displays the compatibility between the two themes. This utility checkswhether there is a template in the new theme to replace each of the templates in the currenttheme. The check marks in the Status column indicate that the templates are compatible. ClickNext >. 

10. To confirm the theme switch, click Switch Theme. 11. To see the new theme, click the Run Page icon ( ) at the top right of the page.

12. Notice that the entire appearance of your application has changed. The color scheme haschanged. Click Edit Application from the Developer Links at the bottom.

Turn-in Checklist:

  List of Projects page from Creating an Application Step 21 

  Tasks page with changes Edit Application Objects Step 17