Zhasulan Berdibekov
Zhasulan Berdibekov

Reputation: 1087

Reading text file line by line in SQL*Plus

How to read a text file from Oracle SQL*plus?

If there is a way to read from a bat file and pass the variable as a single line of text file, and simultaneously called from SQL*plus sql file, this option is ok.

Upvotes: 0

Views: 6853

Answers (2)

ceth
ceth

Reputation: 45295

You can try to use Oracle External Tables.

For example, you have next file:

$ cat employee.dat

smith   clerk       800
scott   analyst     3000
adams   clerk       1100
miller  clerk       1300

Create external table:

create table employees (
ename varchar2(10),
title varchar2(10),
salary number(8))
organization external(
type oracle_loader default directory work_dir
    access parameters (record delimited by new line fields(
        ename char(10), title char(10), salary char(8)))
location ('employee.dat'))
parallel

Now you can use this file as SQL-table:

select * from employees;

Upvotes: 2

Richard Kuhler
Richard Kuhler

Reputation: 1

If the list is already comma separated in the test file, then you can probably do something as simple as this in SQL*Plus ...

get id.txt append ) 0 select * from my_table where id in ( /

Upvotes: 0

Related Questions