Create a CSV File
In this example, the PL/SQL examination results for an elite group of programmers, which
may include a few cats, are stored in a CSV file.
- The CSV file contains header records which identify each stats project, followed by data for that project.
- The header record must start with the word "PROJECT" and be followed by a description.
- The data records consist of a description for the data value, followed by its numeric value.
- You can have data for multiple projects in the CSV file.
PROJECT,PL/SQL Exam Results
Fred,90
Jim,93
Ann,97
Ian,98
Steve F,100
Bruce Scott,99
Tiger,95
Mary,91
Connor McD,100
Seyi,96
Harsh,98
Peter,89
Doris,85
Winston,92
Charlie,91
Morse,90
Import CSV Data into Oracle
Next we will import the data into Oracle tables STATS_PROJECT which identifies each project using a unique PROJECT_ID, and STATS_DATA which contains its data.
- Copy the CSV file to DATA_HOME/received
- Run script APP_HOME/com/import_stats

import_stats.bat
The import_stats script will process the CSV files in the Received directory:
- If the data is valid it will be loaded into the Oracle tables.
- A new Project ID is generated to identify the imported stats data, and this is displayed.
- The statistics are calculated from the imported data.
- A CSV file containing the statistics is created; DATA_HOME/data_out/stats_[ProjectID]_YYYYMMDD_HHMMSS.csv
XEPDB1\APPSDEMO>import_stats
XEPDB1\APPSDEMO>ECHO OFF
Enter the password for DEMO_CONNECT: **********
CSV FILE FOUND: d:\user_data\XEPDB1\APPSDEMO\data\RECEIVED\stats_demo.csv
1 file(s) copied.
SQL*Plus: Release 21.0.0.0.0 - Production on Tue Mar 24 16:27:29 2026
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Last Successful login time: Tue Mar 24 2026 14:47:44 +00:00
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
old 2: v_filename plsql_constants.filenamelength_t := '&1';
new 2: v_filename plsql_constants.filenamelength_t := 'stats_demo.csv';
Data Import from file: stats_demo.csv
Stats data imported OK for Project ID=148
Statistics exported to file: stats_148_20260324_160331.csv
PL/SQL procedure successfully completed.
Disconnected from Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
XEPDB1\APPSDEMO>
Run SQL Report to Display Project Stats Data
Run the SQL report /sql/stats_data to display your project data, Project ID is 148

stats_data.sql
Bond and Pollard Limited
========================
Project Statistics Data Page: 1
Project ID Description Data ID Data Project ID Data Description Value Check
---------- -------------------- ------- --------------- -------------------- ------------ ----------------------------
148 PL/SQL Exam Results 702 148 Fred 90
148 PL/SQL Exam Results 703 148 Jim 93
148 PL/SQL Exam Results 704 148 Ann 97
148 PL/SQL Exam Results 705 148 Ian 98
148 PL/SQL Exam Results 706 148 Steve F 100
148 PL/SQL Exam Results 707 148 Bruce Scott 99
148 PL/SQL Exam Results 708 148 Tiger 95
148 PL/SQL Exam Results 709 148 Mary 91
148 PL/SQL Exam Results 710 148 Connor McD 100
148 PL/SQL Exam Results 711 148 Seyi 96
148 PL/SQL Exam Results 712 148 Harsh 98
148 PL/SQL Exam Results 713 148 Peter 89
148 PL/SQL Exam Results 714 148 Doris 85
148 PL/SQL Exam Results 715 148 Winston 92
148 PL/SQL Exam Results 716 148 Charlie 91
148 PL/SQL Exam Results 717 148 Morse 90
16 rows selected.
Generate the Statistics Report
Run the SQL report /sql/stats_project to display the statistics for your project: Project ID is 148.

stats_project.sql
----------------------------------------------------------
FREQUENCY TABLE
----------------------------------------------------------
KEY=85 Frequency=1
KEY=89 Frequency=1
KEY=90 Frequency=2
KEY=91 Frequency=2
KEY=92 Frequency=1
KEY=93 Frequency=1
KEY=95 Frequency=1
KEY=96 Frequency=1
KEY=97 Frequency=1
KEY=98 Frequency=2
KEY=99 Frequency=1
KEY=100 Frequency=2
----------------------------------------------------------
STATISTICS
Sum=1504
N Total=16
Distinct N=12
Mean=94.0000
Median=94.0000
Mode 1 = 90
Mode 2 = 91
Mode 3 = 98
Mode 4 = 100
Lowest=85
Highest=100
Range=15
Variance Population=19.0000
Variance Sample=20.2667
Standard Deviation Population=4.3589
Standard Deviation Sample=4.5019
Interquartile Range=7.250
Percentile Discrete ( 0.80)=98.0000
Percentile Continuous ( 0.80)=98.0000
Export Stats to a CSV file
Run the SQL report /sql/stats_project_csv to display the statistics, and export the results to CSV files.

stats_project_csv.sql


