Monday, March 16, 2015

PL/SQL code

I've been working on a project at work where I use pl/sql code to get information out of their Oracle database and write it out to a file. The file will later be used to load into a third party software package.

The SQL part of it was okay. I'm still learning what the many table names are and why they are used. The part that has been challenging is getting the data into a common text file. These files are generally called csv files. That stands for comma separated values files. Each piece of data is separated by a comma. One line represents a record.

For example, lets say you have a database table that has books in it. The columns or fields could be book title, number of pages, author name, and publisher name. One row or record in this table could be something like:

Title: A Memory of Light.
Number of pages: 950.
Author name: Robert Jordan
Publisher name: Tor

So if you read this record and stuck in a text file called books.csv it would look like this:
A Memory of Light,950,Robert Jordan,Tor

If you had fifteen books in your table, you would have fifteen lines in your csv file.

So, what's the problem?

The problem is trying to get PL/SQL to create this file on my local hard drive. Eventually the file will be created on whatever server itneeds to be on. But for right now I want it on my local drive so I can check to make sure the data is getting in there properly. It tells me I don't have permission. It looks like I will have to get with the database administrator and see if I can't get permission.