Why this error in writing string to text file using utl_file?

HI Friends,
Iam trying to write procedure to add one line of text in text file using UTIL package. But getting error.
create or replace procedure Add_To_File() is
OutFile utl_file.file_type;
l_err_code NUMBER(10);
l_err_msg VARCHAR2(2000);
vNewLine VARCHAR2(4000);
vdir varchar2(200):='UTIL_DIR';
begin
OutFile:=utl_file.fopen(vdir,'out.txt','w','32000');
vNewLine:='Loading is successfull';
utl_file.put_line(OutFile,vNewLine);
EXCEPTION
WHEN OTHERS THEN
l_err_code := SQLCODE;
l_err_msg := SUBSTR(SQLERRM,1,128);
Dbms_output.put_line(l_err_code || l_err_msg);
end;
when i execute above procedure iam getting this error.
LINE/COL ERROR
1/23 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
<an identifier> <a double-quoted delimited-identifier>
current delete exists prior
Please suggest me where iam wrong.
Thanks,
Venkat Vadlamudi

868591 wrote:
HI Friends,
Iam trying to write procedure to add one line of text in text file using UTIL package. But getting error.
create or replace procedure Add_To_File() is
OutFile utl_file.file_type;
l_err_code NUMBER(10);
l_err_msg VARCHAR2(2000);
vNewLine VARCHAR2(4000);
vdir varchar2(200):='UTIL_DIR';
begin
OutFile:=utl_file.fopen(vdir,'out.txt','w','32000');
vNewLine:='Loading is successfull';
utl_file.put_line(OutFile,vNewLine);
EXCEPTION
WHEN OTHERS THEN
l_err_code := SQLCODE;
l_err_msg := SUBSTR(SQLERRM,1,128);
Dbms_output.put_line(l_err_code || l_err_msg);
end;
when i execute above procedure iam getting this error.
LINE/COL ERROR
1/23 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
<an identifier> <a double-quoted delimited-identifier>
current delete exists prior
Please suggest me where iam wrong.
Thanks,
Venkat Vadlamudibelow works for me
  1  CREATE OR replace PROCEDURE Add_to_file
  2  IS
  3    outfile       utl_file.file_type;
  4    l_err_code NUMBER(10);
  5    l_err_msg  VARCHAR2(2000);
  6    vnewline   VARCHAR2(4000);
  7    vdir       VARCHAR2(200) := 'UTIL_DIR';
  8  BEGIN
  9    outfile := utl_file.Fopen(vdir, 'out.txt', 'w', '32000');
10    vnewline := 'Loading is successfull';
11    utl_file.Put_line(outfile, vnewline);
12  EXCEPTION
13    WHEN OTHERS THEN
14            l_err_code := SQLCODE;
15            l_err_msg := Substr(sqlerrm, 1, 128);
16            dbms_output.Put_line(l_err_code
17                           || l_err_msg);
18* END;
SQL> /
Procedure created.

Similar Messages

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

  • To read text file using utl_file

    I would like to read test_file_out.txt which is in c:\temp folder.
    create or replace create or replace directory dir_temp as 'c:\temp';
    grant read, write on directory dir_temp to system;
    then when i execute the below code i get the error .
    // to read text file using utl_file
    DECLARE
    FileIn UTL_FILE.FILE_TYPE;
    v_sql VARCHAR2 (1000);
    BEGIN
    FileIn := UTL_FILE.FOPEN ('DIR_TEMP', 'test_file_out.txt', 'R');
    UTL_FILE.PUT_LINE (FileIn, v_sql);
    dbms_output.put_line(v_sql);
    UTL_FILE.FCLOSE (FileIn);
    END;
    ERROR:
    invalid file operation
    i would like to use ult_file only and also can you let me know to read the text file and place its contents in tmp_emp table?

    Are you trying to read the contents of the file into the local variable? Or write the contents of the local variable to the file?
    Your text talks about reading the file. And you open the file in read mode. But then you call the UTL_FILE.PUT_LINE method which, as SomeoneElse points out, attempts to write data to the file. Since the file is open in read-only mode, you cannot write to the file.
    If the goal is really to read from the file, replace the UTL_FILE.PUT_LINE calls with UTL_FILE.GET_LINE. If the goal is really to write to the file, you'll need to open the file in write mode ('W' rather than 'R' in the FOPEN call).
    Justin

  • Can't read text file using UTL_FILE

    Hi All,
    how can I read notepad file using UTL_FILE package.I have specified the UTL_FILE_DIR in the init.ora file.My objective is to when a button is clicked, the contents of the file will display in a text item.Here is my code written in WHEN_BUTTON_PRESSED trigger.
    DECLARE
         file_handle UTL_FILE.FILE_TYPE;
    data_line Varchar2(100);
    BEGIN
         file_handle := UTL_FILE.FOPEN('E:\vimal','abc.txt','R');
              message('directory created');
         UTL_FILE.GET_LINE(file_handle, data_line);
         :block2.t1 := data_line;
         UTL_FILE.FCLOSE(file_handle);
    END;

    Why don't you use text_io? Don't forget that UTL_FILE is reading directories from the database point of view. The E drive for the database is a different E then on your client pc. I presume your database is on a different computer. Are you getting any errors?

  • Counting records in text file using utl_file

    Hi
    i have an input file as below
    0010 asp
    0020 fdp
    0030 hfg
    0030 hfg
    0040 fdh
    0050 dfh
    0010 sjh
    0020 hjd
    0030 feh
    0030 jhj
    0030 seb
    0040 jnj
    0050 njj
    each group starts with 0010 & ends with 0050.
    I have to count the no. of 0030 records in each group.
    Here my output should be
    1~2
    2~3
    mean in the 1st group the number of records starting with 0030 is 2 & that in 2nd group is 3
    Please give a solution to count them..
    [Updated on: Thu, 10 January 2008 12:07]

    Hi,
    Below example using External Table Feature.
    create a directory on the server where your database is installed and copy your data file(text file) in that directory. In the below example Oracle directory name is "text_file" and the physical directory on the server is "D:\TEXT_FILE\". The file name of data file is "data.txt".
    create directory text_file as 'D:\TEXT_FILE\';
    DROP TABLE load_a;
    CREATE TABLE load_a
    (a1 varchar2(200))
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY text_file
    ACCESS PARAMETERS
    (FIELDS TERMINATED BY ','
    LOCATION ('data.txt')
    select * from load_a;
    now you can use
    select id||'~'||ctr from
    (select substr(a1, 3, 1) id, count(*) ctr from load_a group by substr(a1, 3, 1));
    Sachin Chauhan
    http://sach1607.blogspot.com

  • Why this error message with certain texts?

    Why do i get this error message only with certain texts?  I have entered only a ten digit number, have deleted conversations and resent messages and still?

    Oh, the error message is "
    error invalid number please re-send using valid 10 digit mobile number or valid short code."

  • I just upgraded to the latest edition of firefox for mac and I am getting this error message Textarea Backup] Existing text detected in 'add_comment_text', overwrite with this backup how can I get it to go away?

    I updated to Firefox 8.0 for Mac and when ever I try to log on to Facebook I get this error message Textarea Backup] Existing text detected in 'add_comment_text', overwrite with this backup? and then it says yes and gives you the choice of either canceling or ok and it doesn't go away when you click either button...What is going on?

    It is working now. I no longer get the message about the item not being available in the US and I can access the store.

  • Could not complete your request because it is not a valid photoshop document why this error coming p

    could not complete your request because it is not a valid photoshop document why this error coming photoshop cs5

    Thanks for clarifying. 
    My bad. I thought you had an even older Mac Pro1,1 like mine, which will not run Mountain Lion.  I should have payed closer attention to your RAM specs.

  • I am facing an issue " Denied connection per minute from one ip address" why this error occur and how to resolve it? is it really harmful for my TMG Server or not??

    I am facing an issue " Denied connection per minute from one ip address" why this error occur and how to resolve it? is it really harmful for my TMG Server or not??
    Error Description:
    The number of denied connections from the source IP address 10.0.0.X exceeded the configured limit. This may indicate that the host is infected or is attempting an attack on the Forefront TMG computer. 
    electrifying

    Hi,
    this may be a false/positive log record.
    First check the services and applications on the effecting machine (NETSTAT -ANO) to see which connections the machine has established or tries to establish.
    Check the machine against viruses and spyware.
    if you don't find any viruses / spyware or "mysterious" connections, create a connection exception limit in the flood mitigation settings on your TMG Server:
    http://www.isaserver.org/articles-tutorials/configuration-security/TMG-Firewall-Flood-Mitigation-Part1.html
    regards Marc Grote aka Jens Baier - www.it-training-grote.de - www.forefront-tmg.de - www.galileocomputing.de/3276?GPP=MarcGrote

  • Why this error display "Adobe Flash Player has stopped potentially unsafe operation"

    why this error display "Adobe Flash Player has stopped potentially unsafe operation"
    In message box following message display:
    The following local application on your computer or network: null
    is trying to communicate with this internet-enabled location : www.ajaxcdn.org

    I get the same message and I already have the latest version (20.0.1) installed. Any other suggestions? Please and thank you!

  • I keep getting this error when I publish the SWF file.

    I keep getting this error when I publish my SWF file.
    Fonts should be embedded for any text that may be edited at runtime, other than text with the "Use Device Fonts" setting. Use the Text > Font Embedding command to embed fonts.
    ReferenceError: Error #1065: Variable TLFTextField is not defined.
    And these compiled errors
    Symbol 'Symbol 6', Layer 'Layer 1', Frame 1
    Warning: The instance name 'staff' is declared on an object of type fl.text.TLFTextField but there is a conflicting use of the instance name 'staff' on an object of type flash.display.InteractiveObject.
    Scene 1, Layer 'action', Frame 1, Line 7
    1061: Call to a possibly undefined method gotoAndPlay through a reference with static type fl.motion:AnimatorFactory.
    Scene 1, Layer 'action', Frame 1, Line 3
    1061: Call to a possibly undefined method addEventListener through a reference with static type fl.motion:AnimatorFactory.
    This is the only action script 3.0 script that I wrote.
    import flash.events.MouseEvent;
        skipbtn.addEventListener(MouseEvent.CLICK, btnClick);
    function btnClick (event:MouseEvent):void{
        skipbtn.gotoAndPlay("home");

    the first line is a warning, not an error.
    and you have more actionscript than you think.  open the movie explorer panel and toggle the actionscript only button to find all the actionsript in your fla.

  • I cant install or uninstall my itunes. I get this error 'the feature you are trying to use is on a network resource that is unavilable' Now ive seen the solutions on here but im using windows 8.1. Ive tried all options so please can someone help?

    I cant install or uninstall my itunes. I get this error 'the feature you are trying to use is on a network resource that is unavilable' Now ive seen the solutions on here but im using windows 8.1 and none of them work for me. Ive tried all options so please can someone help?

    That doesnt work for me. I removed itunes through the windows cleaner method as shown in other posts and re-installed itunes. Now im getting this error
    iTunes was not installed correctly. Please reinstall iTunes
    Error 7 (Windows error 126)
    Also my Microsoft office has stopped working after i deleted Itunes which is really strange.
    Can somebody provide me a solution please....

  • I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro.... The operation can't be completed because an unexpected error occurred (error code -50)

    I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro....
    The operation can’t be completed because an unexpected error occurred (error code -50)

    I would get an external drive today and copy all your stuff off the TC.. forget trying to load more onto it. There is a good chance after 3years (A 2TB should be only about 2years tops), the disk or the TC itself is on the way out. Do it immediately. If TM is also failing to backup you need to recognise symtoms of impending doom.
    Unfortunately the error messages are archane and it is hard to discover their meaning.
    You also cannot verify a network drive.. you can verify the TM sparsebundle though so do that.
    A5. http://pondini.org/TM/Troubleshooting.html
    Reboot the whole network from off.. certainly if you run later OS it can simply lose the drive..
    If you still fail to be able to copy to the TC.. then get that external and copy off it. Tell us if you can do that.

  • (Administration - Marketing - Import), you can set a parameter value "Import mode" for what to do in case of duplication as "update existing records", "Import new records". The final report of this import is presented as a text file that can be viewed in

    Administration - Marketing -> Import, you can set a parameter value "Import mode" for what to do in case of duplication as "update existing records", "Import new records". The final report of this import is presented as a text file that can be viewed in Business Administration - Marketing -> Import -> Exceptions. Whatever the exception, including duplication import occurs during import and recorded in a text file.   What are the fields that determine the duplicity? How I can I can change those?

    You will be returned anything that is in the option's value parameter. What is displayed in the dropdown and what is put in the value attribute do NOT need to be the same, so maybe you should start there.

  • I'm getting this error message: "User not registered for online use" when i'm trying to download music/ track names from a CD into ITunes on my Windows 8 PC.  I'm registered and my itunes account/ appleID are all correct and working.

    I'm getting this error message: "User not registered for online use" when i'm trying to download music/ track names from a CD into ITunes on my Windows 8 PC.  I'm registered and my itunes account/ appleID are all correct and working.

    The ""not recognized for on-line use". error is associated with the Gracenote service that iTunes uses to look up and retrieve metadata for CDs.  Some users have reported that this error occurs when trying to import from CD, subsequent to upgrading to version 12.  A number of slightly different solutions have been reported (though all of a similar nature).
    Try walking through the following steps - before starting you may have to enable hidden files and folders to be viewed - in Windows 7 / Windows Explorer select Organize > Folder and search options, then on the View tab make sure that Show hidden files, folders and drives is selected.  Without this you won't see the AppData folder in C:\Users\username\
    Exit iTunes
    In Windows Explorer, go to the folder C:\Users\username\AppData\Roaming\Apple Computer\iTunes
    Delete the following files:
    CD Info.cidb
    com.apple.iTunes.Gracenote.plist
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If this doesn't work:
    In iTunes, select Edit > Preferences and make a note (or take a screenshot) of your preferences settings in all relevant tabs
    Exit iTunes
    In Windows Explorer, go to the folder C:\Users\username\AppData\Roaming\Apple Computer\iTunes
    Delete the following file:iTunesPrefs.xml
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If this second procedure does work, you'll need to restore other iTunes preferences settings to those that you noted in step 1.
    If this one didn't work:
    Exit iTunes
    Check the following folders:
    C:\Users\username\AppData\Local\Apple Computer\iTunes
    C:\Users\username\AppData\LocalLow\Apple Computer\iTunes
    Delete any copies of the following files:
    CD Info.cidb
    com.apple.iTunes.Gracenote.plist
    iTunesPrefs.xml
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    Again, if this procedure does work, you'll need to restore other iTunes preferences settings to those that you noted in step 1 of the second procedure. If you're still not able to retrieve CD info:
    Exit iTunes
    In Windows, select Start > Control Panel > Programs and Features.  Find the entry for iTunes, right-click and select Repair.
    When this process has finished, restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If none of these have worked (and almost everything I've seen suggests you should be OK by this point), you may have an issue with the installation and configuration of iTunes itself.  If you have got this far, see turingtest2's notes on Troubleshooting issues with iTunes for Windows updates for advice on how to remove and replace of all components of iTunes.

Maybe you are looking for

  • Samsung S5 camera images have vertical bars/gradient in them. Has anyone seen this before?

    Low light conditions produce vertical bars in the image, see attached. I downloaded another camera app and it too produces these bars. It would seem that there is a hardware issue with the sensor. In outdoor images these are not noticeable but I beli

  • Syncing issues with 4S since iOS 8 Update

    Any iPhone 4S owners having issues syncing to iTunes since "upgrading" to iOS 8?  I have a 32 GB phone and I've had make almost 12 GB available to even get the phone to sync.  I had to delete half my music library and a bunch of apps!!  I'm ******! 

  • How do I successfully uninstall Dealfly?

    Every time I go to Amazon, Ebay, etc to search Dealfly pops up at the bottom of the Mozilla screen. I'm on windows 8.1, Firefox 30.0, did not agree to the use of this and the uninstall directions on dealfly's website do not work. I contacted them and

  • AS can't generate WSDL

    Hi, I have the following problem. I have Oracle AS 10.1.3.3 installed and I am trying to generate the WSDL from WSDD file, which is a part of an application deployed on the server. The server was able to generate WSDL for a Hello World WebService, bu

  • Changing server IP and name

    Hello, I need to change the IP and name of my server. I can see the impact on tnsnames, listener but is there any other side effect on Oracle installed on this machine ? I'm running 9iR2 on W2K. Thanks a lot for any advice. Regards, GL