Jay, your question is quite hard to comprehend. If you follow the
TellTheDetails, or atually all of the
HowToAskQuestionsOnJavaRanch advices (just click these links), you'll make it easier for fellow ranchers to answer your questions.
I've understood that your external file contains two types of records: 'H' and 'F'. You need to extract different columns at different positions for these two types of records - is that right?
If this is the case, there are (at least) two ways to do it. I'm not sure whether one is better than the other. I also assume you get this file from somewhere and do not create it on your own. If you create the file yourself, the best way would be to create two files instead, one containing only headers and the other containing only footers. It would take less processing by the database.
1) Create one external table. Let it have a column, say, TYPE at position 1:1, and another column to keep the rest of the record. Create two views which will select only rows of the desired type from the external table and use the
SUBSTR function to extract proper columns for each of your views. If there are different columns than VARCHARs, use
to_number or
to_date (with proper formatting masks and/or decimal symbols) to convert them. Disadvantage is that badly formatted dates or numbers will not be rejected by the loading mechanism, you'll have to deal with them in
your code the definition of the view.
2) Create two different external tables pointing to the same file. Declare one table to match records of type F and corresponding columns, and another table to match records of type H and corresponding columns. You can declare the columns in their proper type (number, date etc.) and have the records violating these types rejected.
Either way, you'll end up with two tables/views. It's actually the right way, since they're supposed to have different columns.
You had your syntax right, so I assume these pointers will suffice to you, but if this is not all that clear, I can elaborate a little bit