
Sometimes I need to use data from a csv (comma separated values) in an oracle procedure. The best way to do that is inserting the data into a db table using sqlloader and then reading it from the PL/SQL.
In this post I will show you how to use sql loader to load a csv file exported from excel into an oracle table.
Suppose that you got a XLS spreadsheet with contact data: first name, last name, security number, phone number.
First, create a table where the file will be loaded:
(first_name varchar2(200)
,last_name varchar2(200)
,security_number number
,phone_number varchar2(50)
);
In my xls (people.xls) I have the following info:
| First Name | Last Name | Secutiry Number | Phone Number |
| John | Doe | 00000001 | 11111123456 |
| John 01 | Doe | 00000002 | 11111123457 |
| John 02 | Doe | 00000003 | 11111123458 |
| John 03 | Doe | 00000004 | 11111123459 |
| John 04 | Doe | 00000005 | 11111123460 |
| John 05 | Doe | 00000006 | 11111123461 |
| John 06 | Doe | 00000007 | 11111123462 |



