Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Defining an input file in a PL/SQL program
Maria G wrote:
>
> I am looking for a way to define an input file in a PL/SQL program.
>
> I was able to code a PL/SQL program to read a record from a file and
> write this record to a file using the UTL_FILE package. The problem
> I'm having isI would like to make the program a little more
> intelligent and process the input record based on different fields
> within the record (i.e. employees last name -- positions 20 to 50;
> employees first name -- positions 51 to 61, etc.). Is there any way
> within PL/SQL to define the record layout of the input file? The
> documentation I've found only shows how to read an entire line of data
> from the file into the line buffer using the GET_LINE procedure. It
> doesn't show how to redefine this entire line of data into individual
> fields based on the positioning of the data (i.e. employees last name
> -- positions 20 to 50; employees first name -- positions 51 to 61,
> etc.).
>
> Thanks for your help!!
Without having tried this, I suppose one way would be:
for i in 1 .. num_fields loop field_value := substr(row_of_data, def(i).start_pos, def(i).field_len); end loop;
You get the basic idea...
HTH
--