Utl_file linesize question

I'm tring to write a file using uti_file pkg. The linesize is 3607 characters. Though Oracle claimes that the maximum size is 32767, I continue get the problem (error: numeric or value error) after pass the size of 3570. Does anybody know the problem and how to fix it?
Greatly appreciate any comments/suggestions.
Ping

hi,
when you open the file, do you specify the linesize?
otherwise it is limited to 1023 I think
rgds

Similar Messages

  • Utl_file.open_file question to check if a file exists and is not empty

    Hello,
    I am trying to write a code where in 3 seperate files are created based on some parameter condition for the extract call.
    Say the parameters are NULL, 'A' and 'B'.
    When Null condition is passed to the extract call then it should create file A and B if records are found. If not it should create empty files.
    It is possible that the parameter to the extract is just 'A' then it would create A with say non zero file and B with zero file.
    Now when the extract is called with 'B' parameter and if the file A already exists and is not empty then I should not touch/overwrite it with empty records.
    Is there any simple way that I can do this to check if a file exists and is non empty?
    I am using
    open_file
    ( gv_utl_file_path
    ,lv_file_name
    ,lv_file_handle
    Please help.
    Thanks

    @OP : No Need to open
    SQL> declare
      2   lb_file_exist boolean;
      3   ln_size number;
      4   ln_block_size number;
      5  begin
      6   sys.utl_file.fgetattr('TEST_DIR','a.txt',lb_file_exist,ln_size,ln_block_size);
      7   if lb_file_exist then
      8    dbms_output.put_line('a Exists');
      9    dbms_output.put_line(to_char(ln_size));
    10   else
    11    dbms_output.put_line('a Not Exists');
    12   end if;
    13   sys.utl_file.fgetattr('TEST_DIR','b.txt',lb_file_exist,ln_size,ln_block_size);
    14   if lb_file_exist then
    15    dbms_output.put_line('b Exists');
    16    dbms_output.put_line(to_char(ln_size));
    17   else
    18    dbms_output.put_line('b Not Exists');
    19   end if;
    20   sys.utl_file.fgetattr('TEST_DIR','c.txt',lb_file_exist,ln_size,ln_block_size);
    21   if lb_file_exist then
    22    dbms_output.put_line('c Exists');
    23    dbms_output.put_line(to_char(ln_size));
    24   else
    25    dbms_output.put_line('c Not Exists');
    26   end if;
    27  end;
    28  /
    a Exists
    0
    b Exists
    3
    c Not Exists
    PL/SQL procedure successfully completed.Edited by: jeneesh on Mar 30, 2012 1:21 AM

  • UTL_FILE questions

    UTL_FILE questions
    1) I want to insert a blank line using utl_file. I am using oracle 10gr2. should I just use below or is there another way to do this.
         UTL_FILE.PUT_LINE(file_handle,'');
    2) Also I am trying to insert a line >1024 characters in a single line. can someone direct me with a command to specify a MAX linesize for a line.
    Thanks.

    Hi,
    Those questions are covered in the PL/SQL Packages and Types manual:
    http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/u_file.htm#BABGGEDF
    To write 1 or more blank lines, use the NEWLINE procedure.
    To set a maximum line size, use the optional 4th argument to FOPEN.

  • Question around UTL_FILE and writing unicode data to a file.

    Database version : 11.2.0.3.0
    NLS_CHARACTERSET : AL32UTF8
    OS : Red Hat Enterprise Linux Server release 6.3 (Santiago)
    I did not work with multiple language characters and manipulating them. So, the basic idea is to write UTF8 data as Unicode file using UTL_FILE. This is fairly an empty database and does not have any rows in at least the tables I am working on. First I inserted a row with English characters in the columns.
    I used utl_file.fopen_nchar to open and used utl_file.put_line_nchar to write it to the file on the Linux box. I open the file and I still see English characters (say "02CANMLKR001".
    Now, I updated the row with some columns having Chinese characters and ran the same script. It wrote the file. Now when I "vi" the file, I see "02CANè¹æ001" (some Unicode symbols in place of the Chinese characters and the regular English.
    When I FTP the file to windows and open it using notepad/notepad++ it still shows the Chinese characters. Using textpad, it shows ? in place of Chinese characters and the file properties say that the file is of type UNIX/UTF-8.
    My question : "Is my code working and writing the file in unicode? If not what are the required changes?" -- I know the question is little vague, but any questions/suggestions towards answering my question would really help.
    sample code:
    {pre}
    DECLARE
       l_file_handle   UTL_FILE.file_type;
       l_file_name     VARCHAR2 (50) := 'test.dat';
       l_rec           VARCHAR2 (250);
    BEGIN
       l_file_handle := UTL_FILE.fopen_nchar ('OUTPUT_DIR', l_file_name, 'W');
       SELECT col1 || col2 || col3 INTO l_rec FROM table_name;
       UTL_FILE.put_line_nchar (l_file_handle, l_rec);
       UTL_FILE.fclose (l_file_handle);
    END;
    {/pre}

    Regardless of what you think of my reply I'm trying to help you.
    I think you need to reread my reply because I can't find ANY relation at all between what I said and what you responded with.
    I wish things are the way you mentioned and followed text books.
    Nothing in my reply is related to 'text books' or some 'academic' approach to development. Strictly based on real-world experience of 25+ years.
    Unfortunately lot of real world projects kick off without complete information.
    No disagreement here - but totally irrevelant to anything I said.
    Till we get the complete information, it's better to work on the idea rather than wasting project hours. I don't think it can work that way. All we do is to lay a ground preparation, toy around multiple options for the actual coding even when we do not have the exact requirements.
    No disagreement here - but totally irrevelant to anything I said.
    And I think it's a good practice rather than waiting for complete information and pushing others.
    You can't just wait. But you also can't just go ahead on your own. You have to IMMEDIATELY 'push others' as soon as you discover any issues affecting your team's (or your) ability to meet the requirements. As I said above:
    Your problems are likely:
    1. lack of adequate requirements as to what the vendor really requires in terms of format and content
    2. lack of appropriate sample data - either you don't have the skill set to create it yourself or you haven't gotten any from someone else.
    3. lack of knowledge of the character sets involved to be able to create/conduct the proper tests
    If you discover something missing with the requirements (what character sets need to be used, what file format to use, whether BOMs are required in the file, etc) you simply MUST bring that to your manager's attention as soon as you suspect it might be an issue.
    It is your manager's job, not yours, to make sure you have the tools needed to do the job. One of those tools is the proper requirements. If there is ANYTHING wrong, or if you even THINK something is wrong with those requirements it is YOUR responsibility to notify your manager ASAP.
    Send them an email, leave a yellow-sticky on their desk but notify them. Nothing in what I just said says, or implies, that you should then just sit back and WAIT until that issue is resolved.
    If you know you will need sample data you MUST make sure the project plan includes SOME means to obtain sample data witihin the timeline needed by your project. As I repeated above if you don't have the skill set to create it yourself someone else will need to do it.
    I did not work with multiple language characters and manipulating them.
    Does your manager know that? If the project requires 'work with multiple language characters and manipulating them' someone on the project needs to have experience doing that. If your manager knows you don't have that experience but wants you to proceed anyway and/or won't provide any other resource that does have that experience that is ok. But that is the manager's responsibility and that needs to be documented. At a minimum you need to advise your manager (I prefer to do it with an email) along the following lines:
    Hey - manager person - As you know I have little or no experience to 'work with multiple language characters and manipulating them' and those skills are needed to properly implement and test that the requirements are met. Please let me know if such a resource can be made available.
    And I'm serious about that. Sometimes you have to make you manager do their job. That means you ALWAYS need to keep them advised of ANY issue that might affect the project. Once your manager is made aware of an issue it is then THEIR responsibility to deal with it. They may choose to ignore it, pretend they never heard about it or actually deal with it. But you will always be able to show that you notified them about it.
    Now, I updated the row with some columns having Chinese characters and ran the same script.
    Great - as long as you actually know Chinese that is; and how to work with Chinese characters in the context of a database character set, querying, creating files, etc.
    If you don't know Chinese or haven't actually worked with Chinese characters in that context then the project still needs a resource that does know it.
    You can't just try to bluff your way through something like character sets and code conversions. You either know what a BOM (byte order mark) is or you don't. You have either learned when BOMs are needed or you haven't.
    That said, we are in process of getting the information and sample data that we require.
    Good!
    Now make sure you have notified your manager of any 'holes' in the requirements and keep them up to date with any other issues that arise.
    NONE of the above suggests, or implies, that you should just sit back and wait until that is done. But any advice offered on the forums about specifics of your issue (such as whether you need to even worry about BOMs) is premature until the vendor or the requirements actually document the precise character set and file format needed.

  • UTL_FILE question

    Hello:
    IS this possible to achieve below:
    PROCEDURE 1:
    BEGIN
    UTL_FILE.fopen (p_directory, l_file_name, 'w');
    CALL PROCEDURE 2;
    utl_file.fclose( ... )
    END PROCEDURE 1;
    PROCEDURE 2 (l_output_file in variable type):
    BEGIN
    utl_file.put_line(l_output_file, l_string);
    insert into TABLE_XXX
    END PROCEDURE 2;
    My goal is to be able to generate an output file and in the meanwhile, save same data into table.
    So we want to combine 'utl_file.put_line" & insert into table FUNCTION as one call. IS this possible ? (I'm currently having problem to define
    l_output_file in variable type in PROCEDURE 2.
    Please help!
    Thank you.

    Hi,
    Check out the sample code below:
    ================================
    CREATE OR REPLACE procedure PROCEDURE_2( fp utl_file.file_type)
    AS
    BEGIN
    utl_file.put_line(fp, 'abcd');
    END PROCEDURE_2;
    CREATE OR REPLACE procedure PROCEDURE_1
    AS
    fp utl_file.file_type ;
    l_file_name Varchar2(10) := 'temp';
    BEGIN
    fp:=UTL_FILE.fopen ('P_DIRECTORY', l_file_name, 'w');
    procedure_2(fp);
    utl_file.fclose(fp);
    END PROCEDURE_1;
    ================================
    ~Vinod

  • How to create/delete files from filesystem using PL/SQL ? UTL_FILE?

    Greetings,
    I will start by explaining what i intend to do.
    I have an application made in APEX. This application will have among other purposes the managment of pdf files which will reside in the filesystem.
    I have questioned the person in charge to keep the pdf files in the database and not in the filesystem but without success.
    So the pdf files reside in the filesystem and there is a record in a database table about them. A table keeps all info about the pdf, their location , size and name, creation date etc.
    The APEX application will have a mecanism to allow the deletion of the pdf files if an administrator decides.
    So it should be possible for an administrator to schedule the deletion of all pdf files whoe creation date is older than 2008 for example
    So, how can i achieve that?
    After some research i foudn about the UTL_FILE package which seems to have it takes to perform the task in issue.
    My idea was to have a script in the operating system which runs nightly and reads a file containing all file names of the pdf to be erased.
    The file which contains the names of the pdfs to be erased will be generated by the database a few minutes before.
    If there are no pds files to be erased than the file containing the names will simply be empty
    Are there any other viable solutions out there?
    And as for opening/creating the file withn the pdf names, i use:
    UTL_FILE.FOPEN (
    location IN VARCHAR2,
    filename IN VARCHAR2,
    open_mode IN VARCHAR2,
    max_linesize IN BINARY_INTEGER)
    RETURN file_type;
    And as for writing lines (a pdf name per line ), i use;
    UTL_FILE.PUT_LINE (
    file IN FILE_TYPE,
    buffer IN VARCHAR2,
    autoflush IN BOOLEAN DEFAULT FALSE);
    is there a better solution?
    thanks all.
    -> My Homepage <-
    Edited by: Igor Carrasco on Apr 14, 2009 3:11 PM
    Edited by: Igor Carrasco on Apr 14, 2009 3:12 PM

    Greetings,
    I have read that link above, some questions still though.
    I will provide some more information.
    -First the database is in a windows server.
    The windows server has a virtual drive mounted as z:\ <-- this points to a directory in virtual machine, i can manually access/create/delete files manually,i tested.
    -Second utl_file_dir is defined as * , in t that enough to cover mounted drives? ( i can't change the init.ora and reboot the db right now :( gotta wait.. )
    Do i explicitly have to define utfl_file_dir = z: ?
    -Third haven't had the chance to test it on linux or any other operating system, assuming a virtual unit is mounted successfully and that the issues above are solved i should be able to operate on any mounted drive whatever the os, right?
    Best regards

  • Error writing data in a flat file using UTL_FILE feature

    Hi All,
    I have written a package which fetches data from four different cursors and inserts into a temporary table.
    Now this temporary table is used to write data in a file using the UTL_FILE feature.
    fhandler :=
    UTL_FILE.fopen (l_path,'Demand_Transactions_'
    || TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
    || '.txt',
    'w',
    max_linesize => 32767
    This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
    Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.
    Any help in this would be highly appreciated.
    Regards,
    Shruti

    891330 wrote:
    Hi All,
    I have written a package which fetches data from four different cursors and inserts into a temporary table.
    Now this temporary table is used to write data in a file using the UTL_FILE feature.
    fhandler :=
    UTL_FILE.fopen (l_path,'Demand_Transactions_'
    || TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
    || '.txt',
    'w',
    max_linesize => 32767
    This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
    Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.Max linesize is the number of characters in a line before a newline has to be issued, not the number of rows written.
    The error would indicate that you have a character to number conversion going on somewhere but the characters are not numeric so it's failing that conversion.
    This doesn't sound like a UTL_FILE issue, but more to do with how you are building up your strings to output to the file.
    You would need to show us your code that builds up the lines you are writing out, with details of the datatypes of any of the columns/variables included in that.

  • Spool Error capture question

    Hi,
    I am trying to spool data from tables into flat files. I am using the following scripts to accomplish it
    1. A cmd file (windows) that makes a call to a sql file
    2. The SQL file which generates another query file at the run time, depending upon the table name passed to it
    3. The run time query file , that executes the final query and spools the data into a txt file | delimited
    For eg:
    Actual command passed C:\Spool_utility\spool_utility TABLE_NAME
    Eg of the spool utility file :
    @echo off
    SET dbuser=XX@YY
    SET dbpw=xxxx
    echo %date% - %time% - Start > %1%log.txt
    echo START
    sqlplus -s %dbuser%/%dbpw% @spool_utility.sql %1>%1.txt
    echo %date% - %time% - Done >> %1%log.txt
    echo DONE
    Eg of the spool_utility.sql
    set echo off
    SET newpage 0
    SET feedback off
    SET linesize 32767
    set pagesize 0
    SET wrap off
    SET recsep off
    SET con off
    SET trim on
    SET trims on
    set verify off
    SET doc off
    SET termout off
    SET arraysize 5000
    SET HEADING off
    set colsep "|"
    spool &1.sql;
    Prompt Select * from &1 where some condition
    spool off
    set termout ON
    @ &1
    EXIT
    The above file generates a table_name.sql file with the actual table name at run time and gets executed and the output is written to the table_name.txt file.
    This works perfectly fine. But the issue is when someone passes some wrong table name or if there is a actual run time error while executing the query , the error with details itself itself gets written to the end spool file.
    For eg : if i do this just to generate an error and execute it from command line, the query generates an error and writes the error to the spool file , but at the command prompt where I executed the command I do not see any error and the process seems to have run perfectly well
    set xxx on xxx off as above
    spool &1.sql;
    Prompt Select * from &1 where rownum><10---this will cause the issue
    spool off
    set termout ON
    @ &1
    EXIT
    Eg of spool file generated :
    from     table_name WHERE rownum><=10 *
    ERROR at line 62:
    ORA-00936: missing expression
    My question is, is there any way i can capture this runtime error and return this error to my calling sql script spool_utility.sql and then propagate it to the calling command file and do some tasks for eg removing the spool file and writing the actual error to a log file . Basically any way to know at my OS calling level that the entire spooling operation was unsuccessful.
    Thanks

    Thanks for the reply.
    Querying the data dictionary will work only when the issue is a invalid table name. My question is can i capture any run time error, not only incorrect table name.
    If there is any run time error (for eg the one I showed where I used a >< sign which is a invalid operator) the error gets written to my spool file, but there is no way I am able to capture that in my calling sql script and subsequently in the calling command file so that I can do something with the error. For eg if a spool file may get written with error messages, some batch process or user may pick up the spool file and start processing which i dont want to happen. i would like to trap that error or at least be notified of the error at my outer calling sql file or outer command file level, so that I can write the error to a log file and delete the erroneous spool file etc.

  • Little help needed on utl_file

    Hi
    I am trying to write a small stored procedure for recording some information to a text file, and I need a little help. However, beforehand, let me give you what I have done:
    procedure create_record (order_id IN VARCHAR2) IS
    l_dir VARCHAR2(10) 'c:/orders';
    l_filename VARCHAR2(25) := 'orderlist';
    l_datetime DATE := sysdate;
    l_output utl_file.file_type;
    begin
    l_output := utl_file.fopen(l_dir, l_filename, 'w');
    if !utl_file.fopen(l_output) THEN
    utl_file.put_line(l_output, l_datetime || order_id);
    utl_file.fclose(l_output);
    else
    utl_file.fclose(l_output);
    l_output := utl_file.fopen(l_dir, l_filename, 'a');
    end if;
    end;
    Now for questions, firstly, I am not entirely sure that the if statement for checking to see if an existing text file exists is the correct way, and would welcome some help on this, and correction.
    Secondly, I need to add a second statement to the if, which if the file exists and the date on that file is the same as the system date, then to open and append some information to it, else create a new file.
    Unfortunately, for me, I am not sure how to do this.
    Can anyone show me how this can be done?
    Thanks

    Hope you can read my coding correctly.
    ps: not tested
    DECLARE
    myFileExist BOOLEAN;
    myFileLength NUMBER;
    myFileBlockSize BINARY_INTEGER;
    myText VARCHAR2(1000):= NULL;
    myInstr NUMBER;
    l_dir VARCHAR2(10) 'c:/orders';
    l_filename VARCHAR2(25) := 'orderlist';
    l_datetime DATE := trunc(sysdate);
    l_output utl_file.file_type;
    BEGIN
    utl_file.fgetattr(l_dir, l_filename, myFileExist, myFileLength, myFileBlockSize);
    if not myFileExist then -- file not exist
    <ul>l_output := utl_file.fopen(l_dir, l_filename, 'w');
    utl_file.put_line(l_output, l_datetime || order_id);</ul>
    else --file exist
    <ul>
    l_output := utl_file.fopen(l_dir, l_filename, 'r');
    LOOP
    <ul>
    --------------------------------------------------------------------start loop
    UTL_FILE.GET_LINE(l_output,myText) ;
    SELECT instr(UPPER(myText),UPPER(trunc(SYSDATE))) into myInstr FROM dual;
    IF myText IS NULL THEN
    <ul>
    EXIT;
    </ul>
    END IF;
    if myInstr > 0 then
    <ul>
    utl_file.fclose(l_output);
    l_output := utl_file.fopen(l_dir, l_filename, 'a');
    </ul>
    else
    <ul>
    utl_file.fclose(l_output);
    l_filename:='newfilename';
    l_output := utl_file.fopen(l_dir, l_filename, 'w');
    </ul>
    end if;
    --------------------------------------------------------------------end loop
    </ul>
    END loop;
    utl_file.put_line(l_output, l_datetime || order_id);
    </ul>
    end if;
    utl_file.fclose(l_output);
    END;
    Edited by: Lie Ching Te on 12-Feb-2010 12:34 PM
    Edited by: Lie Ching Te on 12-Feb-2010 1:01 PM

  • UTL_FILE, Extra CRFL's, possible OS interpretation problem.

    Greetings,
    DISCLAIMER:
    I am an oracle noob so if I make a mistake in forum etiquette or have not checked all available documentation or have made an assumption that is incorrect ( or noobish ) or am unaware of a tool better suited to the task I am trying to accomplish..
    Please don’t flame me, I am learning. Give me constructive replies and I will learn, I promise.
    My environment: 10G XE DB running on Server 2k3. Developing in SQLDEV 1.54
    I am attempting to dump the contents of a CLOB to a file on the OS disc. Due to formatting restrictions, the contents of the file written to disc must be EXACTLY the contents of the CLOB, character per-per character, verbatim.
    Here is an example anon block that will give you the essentials of the way I am attempting to accomplish this:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Hello my name is George!' || chr(13) || chr(10) ;
    l_clob:= l_clob || 'Would you like to play a game?' || chr(13) || chr(10);
    l_clob := l_clob || 'It will be fun, I promise..' || chr(13) || chr(10);
    dbms_output.put_line( dbms_lob.getlength(l_clob));
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    Here you can see where I put a few lines into my clob, I manually append the CRLF using the CHR function, since I cant accurately reproduce a non-printable character in a string value. This is important because the Clob I am attempting to write to disc contains CRLF’s as part of its data, these must be preserved. Also note that I am writing this to the file using utl_file.PUT not PUT_LINE, again, because the disk file must be the clob verbatim, I cant use put_line because it adds a “new line character” at the end of the data it writes.
    Ignore the DMBS_OUTPUT line , I will get back to that in a bit.
    I execute this bit of code and get a file text.txt. What I expected to see was:
    “'Hello my name is George!
    Would you like to play a game?
    'It will be fun, I promise..”
    What I actually got was:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp001.jpg!
    Looking at this in notepad++ we can expose the non-printable chars:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp002.jpg!
    Using notepad ++ we can see that an extra CR ( CHR(13)) has been pre-pended to the CRLF. We can confirm this is not an artifact of viewing this in notepad by looking at the file size of the output file and comparing it to the size of the clob.
    The DBMS_OUTPUT line indicates ( in my test case) clob size of 87 characters. If you take the time to count you will see this is correct. 81 printable characters that we see, and the 6 non-printable chars to accomplish the CRLF’s.
    However if we look at the file size:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp003.jpg!
    So that’s 87 + our 3 “ninja ” CR’s.
    For my purposes this is a deal-breaking problem. The contents of my output file must be exactly the contents of my clob, byte for byte. So this extra CR is a big big problem.
    Where is it coming from? I started thinking about the “new line character” that the PUT_LINE procedure uses and, had a hunch that perhaps since the DB is OS independent, it might be passing one of the non-printable chars to the OS as “new line” and letting the os worry about what that means on disk. With that in mind I did some further testing:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Incoming lf->'|| chr(10) ;
    l_clob:= l_clob || 'Incoming cr->' || chr(13);
    clob:= lclob || 'Incoming CRLF->' || chr(13) || chr(10);
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    This code results in:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp004.jpg!
    Looking at this it becomes obvious that the CHR(10) is being written to disc as TWO characters ( CR LF). So my assumption must be correct, that the DB is passing CHR(10) to the OS as “newline” and the OS ( Windows in my case ) is interpreting this as ‘CRLF.’
    This makes sense since it seems to be widely known ( though not to me , I am shaky on this part ) that “newline” in unix is just CHR(10), and in windows its CHR(10)||CHR(13).
    So I seem to have isolated my problem. Now finally my question.. How to I get around this?
    Google searches and searches on this forum yeilded only marginal help, something about passing this file through an FTP server.. ?. The only marginal help was in post # 3298335. Nothing that really answers my question though.
    Is there a setting my DBA can set to change this behavior? Is there a different way ( PLSQL) to write the file that might mitigate this? Don’t say put the DB on unix, that’s not an option.
    Let me know what you think…
    -VAF

    Hi,
    Also you should check that the directory name is enclosed between '. TEST_DIR is an Oracle directory object that maps a real directory path in the filesystem (check privileges).
    Like:
    DECLARE
        l_clob CLOB;
        l_output_file utl_file.file_type;
    BEGIN
        l_clob := 'Hello my name is George!' || CHR(13) || CHR(10);
        l_clob := l_clob || 'Would you like to play a game?' || CHR(13) || CHR(10);
        l_clob := l_clob || 'It will be fun, I promise..' || CHR(13) || CHR(10);
        dbms_output.put_line(dbms_lob.getlength(l_clob));
        l_output_file := utl_file.fopen('TEST_DIR', 'test.txt', ' W', max_linesize => 32767);
        utl_file.put(l_output_file, l_clob);
        utl_file.fflush(l_output_file);
        utl_file.fclose(l_output_file);
    END;Tip: to post formatted code you must enclose it between {noformat}{noformat} tags (start and end tags are the same).
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL and External table question

    Hello averyone,
    I have a file to be read as an external table part of it is below:
    ISO-10303-21;
    HEADER;
    FILE_DESCRIPTION((''),'2;1');
    FILE_NAME('BRACKET','2005-07-08T',('broilo'),(''),
    'PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2004400',
    'PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2004400','');
    FILE_SCHEMA(('CONFIG_CONTROL_DESIGN'));
    ENDSEC;
    DATA;
    #5=CARTESIAN_POINT('',(5.5E0,5.5E0,-5.1E1));
    #6=DIRECTION('',(0.E0,0.E0,1.E0));
    #7=DIRECTION('',(-1.E0,0.E0,0.E0));
    #8=AXIS2_PLACEMENT_3D('',#5,#6,#7);
    The first question is: how to ignore the lines until the DATA; line or SQL already does it for me?
    The second question is: since the fields of interest are separated by commas and the first field does not interest me (it is solved with a varchar2) how can I read the following fields as numbers ignoring the (,# and ) characters please?
    Thanks for any help.
    Sincerely yours,
    André Luiz

    The SKIP option can be used with SQL*Loader to skip a certain number of lines before starting to load. Off hand I cannot see any easy way to load the data in the format given. The format does not resemble a typical CVS format. You can look at the test cases provided for SQ*Loader in the Oracle® Database Utilities guide - or simply write PL/SQL code to load this data manually using UTL_FILE.

  • Broken korean characters while using utl_file.fopen

    Hi,
    I have korean data in a table and I need to extract it out.
    Am using utl_file.fopen for this. It extracts, but korean characters are coming broken...
    Is there some setting (NLS_LANG etc) that I need to do? I tried NLS_LANG korean_korea.KO16KSC5601 but didn't help...
    Thanks,
    Sachin

    Please post this question in the Database forum for an appropriate response: General Database Discussions
    Regards,
    OTN

  • Error while using UTL_FILE.FOPEN

    sir,
    when i write procedure using utl_file.fopen i am getting error as it must be declared PLS-00201. what mistake, i am doing.
    yours
    dr.s.r.bhattachar

    i was under the impression that there will be a moderator who will redirect the question even by mistake we post? is it not?Absolutely not. On the APEX forum we are in the fortunate position of having members of Oracle's APEX team actively involved, but neither they nor any of the other contributors perform the role of moderator or have administrative access to the forum system. The OTN team who do only really perform "moderation" when there has been a breach of the OTN Terms and Conditions.
    If your question has obviously been posted in the wrong forum, or someone thinks you will get a better response elsewhere then generally they'll suggest this, as above.

  • Utl_file.file_type / ora01041:hostdef does not exist

    Hello all,
    I have got a problem with ora01041:hostdef does not exist.
    My package compiles well untill he reaches a procedure with an declaration with the utl_file.
    I get above error and Oracle terminates unexpectedly.
    The stranges thing is that this only happens when executed in batch.
    When I start SQL and then execite this part of the procedure everything goes well.
    Help!!!

    After disabling Contribute compatability I changed the name
    of the site root and renamed it so that it is not the same as what
    is found on the remote server. I am still receiving the error
    message, even after the name change and re-applying Contribute
    compatability. It should not ... not... be this difficult.
    When I uploaded an html file from the local site (on my PC)
    to the server (an a different device) i received this error
    message. I checked the server and there IS a contribute.xml file
    within the _mm directory within the remote site structure. The date
    and time stamp on the contribute.xml file within the _mm folder
    indicates that it (the contribute.xml file) was indeed updated
    today (at the same time as the html file being uploaded). Therefore
    it shows that the file IS being located, recognized, updated and
    saved with a new date/time stamp. It is not missing. That makes me
    question the validity of the response received to this inquiry.
    Also, the response is proactive in nature. It indicates what
    should not be done in advance of creating a site. The response does
    not provide the steps necessary to resolve the error once it has
    occured.
    Any other suggestions or do I just have to live with this
    flaw in the software? This is really, really annoying as I have to
    be sure to click No each time a file is uploaded and the error
    message is received. Do I have to remove Contribute from my PC and
    all files from the server that are Contribute related and reinstall
    Contribute? Re-create all user profiles? I've had to do that with
    another problem that I had with a different site that used
    Contribute, all to no avail. in that case the only (only) way I
    could get a specific end user set up and working in Contribute was
    to make them an administrator (which is not acceptable though we
    are living with *that* condtion as well). I am quickly losing
    confidence in this product!

  • Get a files creation date with UTL_FILE or DBMS_BACKUP_RESTORE.SEARCHFILES

    Hello gurus!
    I have a number of files in the filesystem and i need to find out the names and creation dates of these files. Please do not suggest Java as that is not an option.
    So far i get the names of the files from the SYS side with a procedure that I can call from the user side. The procedure returns an XML string:
    create or replace procedure list_directory(directory varchar2, retResultSet OUT VARCHAR2) is
         ns          VARCHAR2(1024);
         v_directory VARCHAR2(1024);
    BEGIN
          v_directory := directory;
          SYS.DBMS_BACKUP_RESTORE.SEARCHFILES(v_directory, ns);
          retResultSet := '<list>';
          FOR each_file IN (SELECT fname_krbmsft AS name FROM x$krbmsft) LOOP
              --DBMS_OUTPUT.PUT_LINE(each_file.name);
              retResultSet := retResultSet  || '<file>' ||each_file.name|| '</file>';
          END LOOP;
          retResultSet := retResultSet || '</list>';
    end list_directory;Question 1:
    Something like each_file.creation_date would be perfect but it seems like the filename is the only attribute available here from x$krbmsft. Am i wrong? Any other way on the SYS side to get the date?
    Question 2:
    On the users side i could use UTL_FILE to get filesize but not much more valuable information. Can i get the creation date somehow with UTL_FILE or similar?
    Any help is appreciated!

    Anyone got any ideas?Maybe a method as described in Re: Read all file names from Directory. may help (Shows also FileCreationDate).

Maybe you are looking for

  • R6870 - too hot?

    ok so i've made some observations and here they are: 1) when i run the card by itself, it gets hotter than my sapphire 6870, which is odd because the twin frozr should run cooler. i average mid-high 80s when playing games like BF3. 2) also an interes

  • Keynote on OS X Lion Issue.

    Hello Apple Community, So I have been using the 30 days trial version of Keynote and its finally expired. Then i purchased the Mac os X lion last night. However, the Keynote 09 is still on "EXPIRED 30 days trial". isnt it keynote is included in OS X

  • Create client copy

    Hi all, How to create client copy within system? Can you help me?? Thanks

  • Any hope for Passbook on iPad 2?

    I know Passbook isn't on the iPad 2 - which I was extremely disappointed - but I wonder if there is any hope that an update might come out to put Passbook on the iPad 2?  I have read forums that talk about this being the NFC for apple and the iPad do

  • Restoring iPod after two years of setting on the shelf

    I plugged in my iPod to my computer. All of my music was listed on the screen and everything seemed to work fine as long as I was attached to the computer. After several hours the fully charged icon displayed. When the iPod is disconnected from the c