• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read File in PL/SQL

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using oracle 8i,
I am trying to read the first 10 character of the first line
I have define
br UTL_FILE.FILE_TYPE;

i changed from
UTL_FILE.GET_LINE(br, sLine);
to
UTL_FILE.GET_LINE(br, sLine, 10); - the first 10 characters of the file?
and i got this error:
PLS-00306: wrong number or types of arguments in call to 'GET_LINE'

br UTL_FILE.FILE_TYPE;
if I changed to
br := UTL_FILE.FOPEN_NCHAR (strFilePath, strFileName, 'r');
PL/SQL: Statement ignored
PLS-00302: component 'FOPEN_NCHAR' must be declared
UTL_FILE.GET_LINE_NCHAR (br, sLine)
PL/SQL: Statement ignored
PLS-00302: component 'GET_LINE_NCHAR' must be declared

are those function only in 9i?
appreciated your help.
=)
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Programs added with version 9i
FOPEN
FOPEN
FOPEN_NCHAR
FOPEN_NCHAR
GET_LINE_NCHAR
PUT_NCHAR
PUT_LINE_NCHAR
PUTF_NCHAR


I got this Revealnet's Knowledge base.
So it looks like those are for 9i. Sorry.
You just want the first ten characters. Here's a way.
Assumption #1. The first ten characters are always on the first line.
use GET_LINE, then in you next statement assign the first ten characters to another variable.
If you have

Something like that.
Or if the first ten characters are not always on the first line then you need to loop and continue reading lines until the length of trim(firstTen) = 10. Also you need to have an IF to make sure that the strBuffer is not more than ten and act accordingly in your assignment of firstTen, such that you don't try to add characters that make it go over it's 10 character limit.
Good Luck and I hope that helps.
Mark
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you post your total code.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

srikanth sankurthi wrote:can you post your total code.


The original post is from about 10 years ago, and refers to Oracle 8i, so the code may not be all that helpful these days!

The usual way to read file data in PL/SQL is with the UTL_FILE package, which is well documented on the Oracle website as well as via various examples on other sites. If you have a specific question, you can post it here or on the Oracle Technet forums.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic