Re: importing ascii into oracle tb

From: Kenneth C Stahl <BluesSax_at_Unforgettable.com>
Date: Tue, 06 Jul 1999 10:48:39 -0400
Message-ID: <37821747.69D015EC_at_Unforgettable.com>


Quick and dirty? Here goes:

  1. Log into sqlplus and create a table something like this:

create table mytable (col1 varchar2(80));

(of course, the size of the column should be >= the largest record in the file)

2. Then write a shell script with something like this in it:

#! /bin/ksh
exec 3<myfile
if [ $? -ne 0 ];then

    print -u2 "Unable to open input file";     exit 2;
fi
while read -u3 Buff;do

    sqlplus -s scott/tiger <<-sqlEOF
    whenever sqlerror exit failure;
    insert
    into mytable (col1)
    values (${Buff});
    exit success;
sqlEOF

    if [ $? -ne 0 ];then

        print -u2 "Fatal error";
        exit 2;

    fi
done
exec 3<&-;
exit 0;

Not terribly efficient. Perhaps not even worth doing in the long run, but it will do the task you described "quick and dirty" without a lot of development time.

Ken

Timothy Bowen wrote:

> Is there a quick & dirty way to import an ascii text file into an oracle
> table. Or do I need a special tool for that?
> Thanks.
>
> -**** Posted from RemarQ, http://www.remarq.com/?c ****-
> Search and Read Usenet Discussions in your Browser
Received on Tue Jul 06 1999 - 16:48:39 CEST

Original text of this message