DBA Tips Archive for Oracle
Loading Comma Delimited Data using PL/SQL
by Jeff Hunter, Sr. Database Administrator
Often times, the DBA will need to load variable length, comma delimited data into Oracle tables. There is an alternative to using SQL*Loader and that is to use PL/SQL.
There are many advantages to using a PL/SQL program to load data like having the flexibility to query data from any table, perform arithmetical statements on the data and having the ability to use any of the built-in Oracle functions on the data.
The following files are provided as examples to loading variable length, comma delimited data into the database.
Comma Delimited Example cr_dept_table.sqlThe following DDL script will create the DEPT table to load the data intodept01.csvExample datafile. The data in the file is comma delimited and contains three fields.cr_load_data_proc.sqlThe code for the "load_data" PL/SQL procedure.
Copyright (c) 1998-2014 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at firstname.lastname@example.org.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.