Search code examples
sqloracle11gcursororacle-sqldeveloper

Oracle SQL Develop: inserting txt file to sql table by cursor


I just start to learn Oracle SQL develop.

I am thinking to write CURSOR to read text file line by line and insert to the SQL table.

However, I am not really sure the folder that I need to put text file.

Where should I put the text file ?

and

I just started to learn CURSOR... can you give me simple example about cursor?

thanks


Solution

  • A cursor is a way to handle results of queries whithin plsql, so basically, reading a file with a cursor doesn't really make sense...

    There are some ways how to read a text file from plsql and insert it into a table. In most cases it should start with:

    1. Put the file in a specific directory in the file system
    2. Create a DIRECTORY db object that references that file system directory.

    Now you can use UTL_FILE, or (IMHO, nicer) external tables.