Database Tutorial

Course Tutorial Site

Site Admin

CIT325: Lab 9 Instructions

without comments

Lab #9: Oracle Assignment

Objectives

The lab is designed to teach you how to work with large text and binary files, and how you can load and access them in an Oracle database. The SQL and PL/SQL programming language don’t manage images, which means we limit the discussion to large text files.

You will write an anonymous PL/SQL block that dynamically reads the content of an external file directory to match and upload large text source files:

  • Learn how to position large text files for upload to a database application.
  • Learn how to read and upload text files into an Oracle database.
  • Learn how to work external tables with preprocessing instructions.
  • Learn how to leverage application library procedures to solve a programming problem.

Help Section

The following small articles cover points in a narrower scope than the external articles provided in this section. The lab presumes that you read the externally referenced articles before examining these smaller tutorial and lab targeted points. You can think of the external articles as setting your context and knowledge base, and these small help sections as guides to like related tasks necessary to complete the lab.

The lab builds on work done in the Lab 7 and Lab 8. It does not use any of the code other than the setup code provided to you from the course Oracle Database 12c PL/SQL Programming textbook. The lab has you load large text files from a directory in the operating system.

You will copy files into a local directory on the operating system, configure a virtual directory inside the Oracle database, and develop an external table that leverages preprocessor. The supporting documentation to understand the process of creating external tables and external tables with preprocessing are:

An external table with preprocessing lets you read a list of tables from the file system into an external table. You can then read list of files via a SQL cursor and loop through the result set while calling the load_clob_from_file procedure to write the large file from a file iinto a CLOB column. This is the technique that is most often used when writing large text files into an Oracle database. Similar approaches exist in other commercial databases.

The trick to making these types of uploads work, often requires adding or maintaining what are sometimes called targeting columns. A targeting column in an upload holds the file name or a fully qualified file name. A file name is simply the file name a dot (.) and file extension. A fully qualified file name is a path, a file name, a dot (.), and file extension. Oracle’s use of virtual directories lends itself to simple file names because the path is resolved when you create a virtual directory in the Oracle database.

Oracle’s solution is complex from an architectural perspective but simple from a programmer’s perspective. The Database Administrator (DBA) is typically responsible for creating virtual directories and the System Administrator (SA) is typically responsible for creating the physical directory and making sure it and the files have the correct system privileges.

Your Lab 7 script should run the following two scripts, or your Lab 8 script should run the following two scripts. However, if both labs fail to run the necessary pre-reqs for Lab 9, you can call these two scripts:

@/home/student/Data/cit325/oracle/lib/cleanup_oracle.sql
@/home/student/Data/cit325/oracle/lib/Oracle12cPLSQLCode/Introduction/create_video_store.sql

Assuming your Lab 8 includes calls to both scripts, you should call your apply_plsql_lab8.sql script to set the pre-reqs for Lab 9:

@/home/student/Data/cit325/oracle/lab8/apply_plsql_lab8.sql

The lab has one part.

Lab Description

[25 points] Click the Lab Instructions link to open the instructions inside the current webpage.

Test Case

Click the Test Case Instructions link to open the test case instructions inside the current webpage.

Written by michaelmclaughlin

November 6th, 2016 at 2:35 pm

Posted in