Text_io.file_type

I need to create a package naming CLIENT_TEXT_IO which will duplicate the functionality of TEXT_IO package. The reason is I need the same form to be compiled in Forms 6i as well as in 9i(attaching webutil.pll). In this I face one problem regarding how to give the spec for text_io.file_type. I mean, I need to know how exactly is file_type declared in Text_IO package.Can u plz help me.

That's because TEXT_IO expects the TEXT_IO.FILE_TYPE subtype - not your own subtype (even if it's the same implementation).
If you use your own subtype in a separate context e.g.
declare
  type file_type is record(handle pls_integer);
  v_type file_type;
begin
  v_type.handle := 1;
end;You'll see that it compiles and works fine in 6i.

Similar Messages

  • Problem with reports in excel (using text_io)

    we are using Report Builder 6.0.5.28.0 with Oracle9i Enterprise Edition Release 9.2.0.1.0. in a client/server evironment. I'm using 'TEXT_IO' to write the report output to a csv file.
    The process runs ok but the only problem is that the first line of every page (other than the first) gets repeated.
    can anyone out there tell me how to get over this problem.
    Thanx in advance
    Adolph

    1. You first need to create a package in your report
    PACKAGE conv_text IS
    procedure fopen(fname varchar2);
    procedure fclose(fname varchar2);
    procedure fwrite_c(fname varchar2,
    var_c varchar2);
    procedure fline;
    END;
    PACKAGE BODY conv_text IS
    o_file TEXT_IO.FILE_TYPE;
    filename VARCHAR2(50);
    procedure fopen (fname varchar2) is
    begin
    filename := fname;
    o_file := TEXT_IO.FOPEN(filename,'W');
    end;
    procedure fclose (fname varchar2) is
    begin
    Text_IO.Fclose(o_file);
    end;
    procedure fwrite_c (fname varchar2, var_c varchar2) is
    begin
              Text_IO.Put(o_file,var_c);
    end;
    procedure fline is
    begin
         Text_IO.New_Line(o_file);
    end;
    2. In the "before report trigger" open the csv file (make sure the folder exists on the client m/c)
    conv_text.fopen(:filename);
    3. In the innermost frame(use the following,for all the fields u want in ur csv file) :
    filename VARCHAR2(50);
    begin
    filename := :filename;
    conv_text.fwrite_c(filename,:agency_name);
    conv_text.fwrite_c(filename,',');
    conv_text.fwrite_c(filename,:invoice_no);
    conv_text.fwrite_c(filename,',');
    conv_text.fline;
    4. In the after report, close the file
    conv_text.fclose(:filename);
    good luck and let me know if get thru with the problem of the repeating record.
    Adolph
    [email protected]

  • TEXT_IO.FOPEN not working on web deployed app FORMS 6i

    Hi all
    I have coded parsing file by using TEXT_IO.GET_LINE but it seems that my file even can't be opened.
    declare
    file1 text_io.file_type;
    filename1 varchar(256);
    linebuf varchar2(100);
    begin
    file1 := TEXT_IO.FOPEN(:CSV.CSV_PATH, 'r');
    Text_IO.Get_Line(file1, linebuf);
    if linebuf!='blablablablabla' then msg('line is OK!');
    else msg('Line is wrong!');
    end if;
    TEXT_IO.FCLOSE(file1);
    end;
    On local machine when i enter into :CSV.CSV_PATH "C:\details.txt" the file gets loaded because it gets processing, I can see messages.
    When I upload form onto remote web-deployed app server, I enter into path "D:\details.txt" (I cannot write on C:, the files are the same) nothing happens. Does it mean text_io won't work on Fomrs6i web-deployed? How can I investigate this issue.
    Thanks in advance
    Tome

    With Forms Server deployments. TEXT_IO writes the file on the Forms server not the local PC as it did in client-server mode.
    Here are some workarounds
    1) Download the WEBUTIL add-on from Oracle and use its TEXT_IO package to write to the local file.
    WebUtil is an essential add-on loaded with goodies such as a file browse dialog for local files. Its easy to use and is designed to be compatible with other oracle routines like TEXT_IO.
    Kudos to Duncan Mills at Oracle for this top add-on - dont leave home without it.
    www.oracle.com/technology/products/forms/htdocs/webutil/webutil.htm2) Use the original TEXT_IO (as you are now) to write to a file on the Forms Sever , then display it in a browser window using WEB.SHOW_DOCUMENT
    3) I remember seeing some some old Java scripts on OTN to write to local PC.
    MY APOLOGIES for #3. Most forum posts can be solved with that little gem of an answer. "My sink is blocked" ... "yeah I saw some java code to fix that"

  • TEXT_IO ...  replace first line

    Hello,
    i have a small Problem with the TEXT_IO.PUT_LINE builtin
    I want to write and read a .txt file with TEXT_IO
    It workes fine but if i use put_line to write something in, it replace all inside my .txt file
    My Question: Is it possible to replace only the first line inside my txt file
    Example Forms:
    Declare
         filename           varchar2(30) := 't:\test\Laufzettel.txt';
         file_handle TEXT_IO.FILE_TYPE;
         umrechnung number;
    BEGIN
    If :parameter.intervall is not null then
         file_handle := TEXT_IO.FOPEN(filename, 'W');
         umrechnung := :button.intervall;
         umrechnung := round(((umrechnung*60)*1000));
         TEXT_IO.PUT_LINE(file_handle,umrechnung);     
         TEXT_IO.FCLOSE(file_handle);
    end if;
    END;
    and the .txt file looks like this:
    6000
    CT
    CT2
    Mammo
    MR
    US
    Bestrahlung
    MRT
    NUK
    SD
    i want to replace the 6000 with another number without rewriting all the other entrys?!
    Sorry for my bad English :)
    Message was edited by:
    user628271

    If you are unix use grep command to replace the string. And this grep command can be called using host.
    If you are in Windows , create a new file from the original and while creating you
    can replace which ever line you needed.
    Once you create the new file , delete the original file using host command.
    Once you delete the old file, copy the new file to the original file name using host command.
    Rajesh Alex

  • How to read file WITHOUT full path using TEXT_IO?

    We have a scenario like this:
    -- We have a Telco application.
    -- That has 3 types of installations. English and Spanish
    -- We have 2 App Servers (Eng & Spa) for the 2 installation types.
    -- But there is only ONE DB. I.e. users logging into Eng or Spa AS versions login to the same DB.
    -- We have to maintain 2 login forms because of Eng and Spa, because the menu labels have to come in 2 langs.
    -- I am trying to have one tree menu for this.
    -- To do this I did this.
    -- Put a text file in the Forms directory of the AS.
    -- The file has just one line. ENGLISH or SPANISH.
    -- I read this file and find out the language and then show labels according the language.
    Problem is that when I used TEXT_IO and gave file name like this filename:=GET_FILE_NAME('Avabill_AS_Language.txt', File_Filter=>'Text Files (*.txt)|*.txt|');
    I get a error saying file not found.
    I found out that with TEXT_IO you need FULL PATH of the file. Thing is path of the installation depends of installation to installation. I cannot create a parameter in the DB since the DB is COMMON. I HAVE TO use a text file in the AS directory.
    Is there any other way like reading the Default.env file or FormsWeb.cfg? Is there a parameter in any of these files which specifies the forms directory absolute path. I studied both file but could not find an entry.
    Any workaround would be greatly appreciated.

    Thanks BaiG for the quick response.
    U r right about that GET_FILE_NAME.
    I removed that and put the file name only and tried. Still get the same error.
    FUNCTION Avabill_Deployment_Type RETURN VARCHAR2 IS
    v_language VARCHAR2(100);
    in_file Text_IO.File_Type;
    BEGIN
    in_file := Text_IO.Fopen( *'Avabill_AS_Language.txt'* , 'r');
    Text_IO.Get_Line(in_file, v_language );
    Text_IO.Fclose(in_file);
    RETURN v_language;
    EXCEPTION
    WHEN OTHERS THEN
    Text_IO.Fclose(in_file);
    ALERT_MESSAGE(1,'FILE NOT FOUND: ' || SQLERRM);
    RETURN 'Normal';
    END;
    I get this error:
    *302000: non-ORACLE exception*
    As for you query:
    -- We have 2 app servers. One English and One Spanish.
    -- So we have 2 sets of forms. One English with English labels in the forms and the other with Spanish Labels.
    -- So we HAVE to have 2 menu forms as well, don't we? When the menu form is run how does it know whether the app server is English or Spanish.
    -- There is no way to find out. We cannot use a DB variable since BOTH use the same DB (at the same time). Eng users will enter in English while Spanish users will enter in Spanish.
    I don't see how we can have one menu form for this purpose. Can u elaborate your method further please?

  • Reading data from flat file Using TEXT_IO

    Dear Gurus
    I already posted this question but this time i need some other changes .....Sorry for that ..
    I am using 10G forms and using TEXT_IO for reading data from flat file ..
    My data is like this :-
    0|BP-V1|20100928|01|1|2430962.89|27|2430962.89|MUR|20100928120106
    9|2430962.89|000111111111|
    1|61304.88|000014104113|
    1|41961.73|000022096086|
    1|38475.65|000023640081|
    1|49749.34|000032133154|
    1|35572.46|000033093377|
    1|246671.01|000042148111|
    Here each column is separated by | . I want to read all the columns and want to do some validation .
    How can i do ?
    Initially my requirement was to read only 2 or 3 columns so i did like this ...
    Procedure Pay_Simulator(lfile_type varchar2,lac_no varchar2,lcur varchar2,lno_item number,ltotal number,ldate date,lpay_purp varchar2,lfile_name varchar2)
    IS
    v_handle utl_file.file_type;
    v_filebuffer varchar2(500);
    line_0_date VARCHAR2 (10);
    line_0_Purp VARCHAR2 (10);
    line_0_count Number;
    line_0_sum number(12,2);
    line_0_ccy Varchar2(3);
    line_9_sum Number(12,2);
    line_9_Acc_no Varchar2(12);
    Line_1_Sum Number(12,2);
    Line_1_tot Number(15,2) := 0;
    Line_1_flag Number := 0;
    lval number;
    lacno varchar2(16);
    v_file varchar2(20);
    v_path varchar2(50);
    Begin
    v_file := mcb_simulator_pkg.GET_FILENAME(lfile_name); -- For the file name
    v_path :=rtrim(regexp_substr( lfile_name , '.*\\' ),'\'); For the Path
    v_path := SUBSTR (lfile_name,0, INSTR (lfile_name, '\', -1));
    v_handle := UTL_FILE.fopen (v_path, v_file, 'r');
    LOOP
    UTL_FILE.get_line (v_handle, v_filebuffer);
    IF SUBSTR (v_filebuffer, 0, 1) = '0' THEN
    SELECT line_0 INTO line_0_date
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 3;
    SELECT line_0 INTO line_0_Purp
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 4;
    SELECT line_0 INTO line_0_count
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 7;
    SELECT line_0 INTO line_0_sum
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 8;
    SELECT line_0 INTO line_0_ccy
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 9;
    ELSIF SUBSTR (v_filebuffer, 0, 1) = '9' THEN
    SELECT line_9 INTO line_9_Acc_no
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_9, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 3;
    SELECT line_9 INTO line_9_sum
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_9, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 2;
    ELSIF SUBSTR (v_filebuffer, 0, 1) = '1' THEN
    line_1_flag := line_1_flag+1;
    SELECT line_1 INTO line_1_sum
    FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_1, ROWNUM rn
    FROM DUAL
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
    WHERE rn = 3;
    Line_1_tot := Line_1_tot + line_1_sum;
    END IF;
    END LOOP;
    DBMS_OUTPUT.put_line (Line_1_tot);
    DBMS_OUTPUT.PUT_LINE (Line_1_flag);
    UTL_FILE.fclose (v_handle);
    END;
    But now how can i do ? Shall i use like this select Statement for all the columns ?

    Sorry for that ..
    As per our requirement ...
    I need to read the flat file and it looks like like this .
    *0|BP-V1|20100928|01|1|2430962.89|9|2430962.89|MUR|20100928120106*
    *9|2430962.89|000111111111|*
    *1|61304.88|000014104113|*
    *1|41961.73|000022096086|*
    *1|38475.65|000023640081|*
    *1|49749.34|000032133154|*
    *1|35572.46|000033093377|*
    *1|246671.01|000042148111|*
    *1|120737.25|000053101979|*
    *1|151898.79|000082139768|*
    *1|84182.34|000082485593|*
    I have to check the file :-
    Validation are 1st line should start from 0 else it should raise an error and insert that error into one table .
    The for 2nd line also same thing ..it should start from 9 else it should raise an error and insert that error into one table .
    Then the 3rd line should start from 1 else it should raise an error and insert that error into one table .
    After that i have to do a validation like i will read the 1st line 2nd column .. It should be like this BP-V1 else raise an error and insert that error to a table . Then i will check the 3rd column which is 20100928 , it should be YYYYMMDD format else same thing ERROR.
    Then like this for all columns i have different validation .......
    Then it will check for the 2nd line 3rd column . this is an account no .1st i will check it should be 12 char else ERROR .Then I will check that what user has imputed in the form.Like for example User putted 111111111 then i will check with this 000111111111 which is there in the 2nd line . I have to add 000 before that Account no which user imputed .
    Then the lines which is starting from 1 , i have to take all the 2nd column for all the lines which is starting from 1 and i have to do a sum . After that i have to compare that sum with the value in the 1st lines ( Starting from 0) 6th column . It should be same else ERROR ...
    Then same way i have to count all the lines which is starting from 1 . Then i have to compare with the 7th column of 1st line . It should be same . Here in this file it should be 9.
    MY CODE IS :-
    Procedure Pay_Simulator(lfile_type varchar2,lac_no varchar2,lcur varchar2,lno_item number,ltotal number,ldate date,lpay_purp varchar2,lfile_name varchar2)
    IS
    v_handle TEXT_IO.file_type;
    v_filebuffer varchar2(500);
    line_0_date VARCHAR2 (10);
    line_0_Purp VARCHAR2 (10);
    line_0_count Number;
    line_0_sum number(12,2);
    line_0_ccy Varchar2(3);
    line_9_sum Number(12,2);
    line_9_Acc_no Varchar2(12);
    Line_1_Sum Number(12,2);
    Line_1_tot Number(15,2) := 0;
    Line_1_flag Number := 0;
    lval number;
    lacno varchar2(16);
    v_file varchar2(20);
    v_path varchar2(50);
    LC$String VARCHAR2(50) ;--:= 'one|two|three|four|five|six|seven' ;
    LC$Token VARCHAR2(100) ;
    i PLS_INTEGER := 2 ;
    lfirst_char number;
    lvalue Varchar2(100) ;
    Begin
    v_file := mcb_simulator_pkg.GET_FILENAME(lfile_name); For the file name
    v_path :=rtrim(regexp_substr( lfile_name , '.*\\' ),'\'); For the Path
    --v_path := SUBSTR (lfile_name,0, INSTR (lfile_name, '\', -1));
    Message(lfile_name);
    v_handle := TEXT_IO.fopen(lfile_name, 'r');
              BEGIN
                        LOOP
                        TEXT_IO.get_line (v_handle, v_filebuffer);
                        lfirst_char := Substr(v_filebuffer,0,1);
                        --Message('First Char '||lfirst_char); 
                                  IF lfirst_char = '0' Then
                                  Loop
                                  LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
                                  Message('VAL - '||LC$Token);
                                  lvalue := LC$Token;
                                  EXIT WHEN LC$Token IS NULL ;
    i := i + 1 ;
    End Loop;
                                  Else
                                       Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (9999,'0002','First line should always start with 0');
                                       Forms_DDL('Commit');
                                       raise form_Trigger_failure;
                                  End if ;
                        TEXT_IO.get_line (v_handle, v_filebuffer);
                        lfirst_char := Substr(v_filebuffer,0,1);
                        LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
                        --Message('Row '||LC$Token);
                             IF lfirst_char = '9' Then
                                  Null;
                             Else
                                  Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (8888,'0016','Second line should start with 9');
                                  Forms_DDL('Commit');
                                  raise form_Trigger_failure;
                             End IF;
                        LOOP
                        TEXT_IO.get_line (v_handle, v_filebuffer);
                        lfirst_char := Substr(v_filebuffer,0,1);
                        LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
                        --Message('Row '||LC$Token);
                                  IF lfirst_char = '1' Then
                                  Null;
                                  Else
                                       Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (7777,'0022','The third line onward should start with 1');
                                       Forms_DDL('Commit');
                                       raise form_Trigger_failure;
                                  End if;
                        END LOOP;
                        --END IF;
                        END LOOP;
              EXCEPTION
                   When No_Data_Found Then
              TEXT_IO.fclose (v_handle);
              END;
    Exception
         When Others Then
         Message('Other error');
    END;
    I am calling the FUNCTION which you gave SPLIT as mcb_simulator_pkg.Split.

  • Using Text_IO in Oracle Reports 6.0

    Hi.
    I ask again, perhaps someone can help me:
    I want to add a function to a column to write every row to a file (such as a .log-file).
    In Example i can simply write into a file like this:
    "Trigger - after parameter form":
    file_out Text_IO.File_type;
    BEGIN
    file_out:= Text_IO.Fopen('log.txt', 'w');
    Text_IO.put (file_out,'test');
    Text_IO.Fclose(file_out);
    END;
    But i want to write to this file from the function, placed in a column.
    So i cant open this file at every row (open, write, close)...
    Perhaps someone can tell me, how i can do this: To open a File before Report, write into the File from the function and close the file after the report.
    Thank you again.

    Hello,
    You need to create a client-side PL/SQL package as Program Units for your report. In this package you can define a package variable to hold and share your file handle, and create functions to open, write, and close the file. You can call these functions from the Before Report, Formula, and After Report triggers in your report.
    Regards,
    The Oracle Reports Team --skw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Text_IO in Oracle Reports 6.0 ?

    Hi all !
    I've build a Report with Report Builder 6.0.
    Now i want to write every row i get, in a file.
    So i want to use Text_IO. The Question is, how can i use a global (User) Variable with type "Text_IO.File_Type". I can only create a user variable with type "char, date, number".
    At the begin of Report i want to use the trigger "After parameter form" to open the file.
    Then i want to use a function where every row will be written to the file.
    At the end i want to close the file in trigger "after report"
    Perhaps someone can help me ?
    (Hope i had explained it easy, my english is not the best).
    Thank you.

    hello,
    you will have to create a package specifications that has the definition of this variable in it.
    you can than access the var using <packagename>.<varname> (e.g. myGlobals.myFile) from all PLSQL within your report (e.g. the after parameterform trigger).
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • TEXT_IO.PUT_LINE Restrictions?

    Hi,
    The spec for TEXT_IO.PUT_LINE is:
    PROCEDURE Text_IO.Put_Line
    (file file_type,
    item VARCHAR2);
    Does anyone know what the maximum size of the varchar2 is? It appears to be 1000 characters.
    Thanks,
    Simon.

    Don't think it's 1000.
    As Database Table Column the limitation is 4000 Byte, In PL/SQL VARCHAR2 can be 32767 byte if memory serves:
    declare
         xFile text_io.file_type;
         vText varchar2(32000);
    begin
         for i in 1..32000 loop
              vText := vText || '1';
         end loop;
         xFile := text_io.fopen('c:\temp.txt', 'w');
         text_io.put_line(xFile, vText);
         text_io.fclose(xFile);
    end;I have 32000 '1' in my file...

  • TEXT_IO/cursor problem - Appropriate SELECT...INTO.. returns no rows!

    Hi,
    I have a button on a form which, when pressed, uses the built-in "GET_FILE_NAME" to locate a comma-delimited flat file. I use TEXT_IO to open the file and process the rows in a FOR LOOP. In the loop, I parse each comma delimited field into it's own variable. One of these fieldsis a week-ending-date, which is converted to a DATE variable. I need to get the year and week # from a support table called "Week" (I could justget the year from the date, but the week number is arbitrary when crossing over years). I have tried using a SELECT..INTO statement and an explicit cursor with the same results - none. The select into I use is:
    SELECT year, week
    INTO v_year, v_week
    FROM schema1.week
    WHERE TRUNC(end_date) = TRUNC(v_edate);
    --where v_year and v_week are the same %TYPE as their corresponding columns
    -- and v_edate is the week-ending-DATE from the flat file
    When I do this from SQL*PLUS, it comes out fine, but no data is found when run in the form. I don't get it... if there is nothing wrong with the syntax, shouldn't this work in both places? Or is there some limitation on using cursors while processing a TEXT_IO file? If anyone knows the why of this or can think of a workaround, please let me know.
    Oracle Version: 8.1.7.0.0
    Server: IRIX - Unix
    Forms Version: 6.0.5.35.3
    Client: Win 98
    Thanks much,
    Jason

    DECLARE
         v_filename VARCHAR2(100);
         temp_file TEXT_IO.File_Type;
         linebuff VARCHAR2(1800);
         v_edate DATE;
         v_year schema1.week.year%TYPE;
         v_week schema1.week.week%TYPE);
         str_start NUMBER;
         str_end     NUMBER;
         CURSOR week_cur (p_edate IN DATE) IS
              SELECT year, week
              FROM schema1.week
              WHERE TRUNC(end_date) = TRUNC(p_edate);
    BEGIN
         v_filename := GET_FILE_NAME ('c:\files\');
         temp_file := TEXT_IO.Fopen (v_filename, 'R');
         FOR i IN 1..3 LOOP
              TEXT_IO.Get_Line (temp_file, linebuff);
              IF i > 1 THEN
                   GO_BLOCK ('DATA_DUMP');
                   NEXT_RECORD;
              END IF;
              str_end := INSTR(linebuff, ',') - 1;
              :DATA_DUMP.stnum := SUBSTR (linebuff, 1, str_end);
              str_start := str_end +2;
              str_end := INSTR(linebuff, ',', 1, 2);
              :DATA_DUMP.dnum := SUBSTR (linebuff, str_start, str_end - str_start);
              str_start := str_end +1;
              str_end := INSTR(linebuff, ',', 1, 3);
              :DATA_DUMP.spp := SUBSTR (linebuff, str_start, str_end - str_start);
              str_start := str_end +1;
              str_end := INSTR(linebuff, ',', 1, 4);
              v_edate := TO_DATE (SUBSTR(linebuff, str_start, str_end - str_start), 'MM/DD/YYYY');
              str_start := str_end +1;
              str_end := INSTR(linebuff, ',', 1, 5);
              :DATA_DUMP.lbs_land := SUBSTR (linebuff, str_start, str_end - str_start);
              str_start := str_end +1;
              str_end := LENGTH(linebuff);
              :DATA_DUMP.date_in := TO_DATE (SUBSTR(linebuff, str_start, str_end - str_start), 'MM/DD/YY HH:MI');
              OPEN week_cur (v_edate);
                   FETCH week_cur INTO v_year, v_week;
              CLOSE week_cur;
              :DATA_DUMP.year := v_year;
              :DATA_DUMP.week := v_week;
         END LOOP;
    END;          

  • Questio about TEXT_IO package

    dear friends
    I've created a procedure that copy the data from database like this:
    PROCEDURE P_LOAD2TEXT(P_STOCK GN_STOCKS.STOCK_CODE%TYPE)
    IS
    CURSOR DAILY_TRADE_CUR IS
    SELECT TO_CHAR(THE_TIME,'HH24:MI:SS') TRADE_TIME,PRICE,QTY
    FROM LV_DAILY_TRADES
    WHERE STOCK_CODE = P_STOCK;
         vFILE           TEXT_IO.FILE_TYPE;
         vFILENAME      VARCHAR2(255);
    BEGIN
              Vfilename := 'X:\SE\chart\intraday_ascii\'||:trade.stock_code||'.txt';
              vFILE := TEXT_IO.FOPEN(vFILENAME ,'W');
              FOR I IN DAILY_TRADE_CUR LOOP
              TEXT_IO.PUT_LINE(vFILE,I.TRADE_TIME||','||I.PRICE||','||I.QTY);          
              END LOOP;
              TEXT_IO.FCLOSE(vFILE);
    END;
    the procedure works fine .
    But i need to validated first if the file exists, delete this file first.
    my question is
    Is it possible to delete file from hard disk from within form builder?
    I can tried to make a batch file that clears all files with in the folder but the problem is the the command prompt window is displyed and asking me the following question
    x:\del*.*
    x:\*.*, are you sure(Y,N)
    and i must press Y to delete the files
    my knowedge in making batch file is limited and i do not know how to pass 'Y' to the command prompt.
    please help

    There are two choices:
    - Add the /q switch to the del command, i.e. del *.* /q
    Or use the delete_file procedure from the win_api_utility package available from the d2kwutil library (if using Forms 6i).
    Be carefull howver when using the del *.* to make sure you are in the proper folder.

  • Text_io problem

    Hi everyone,
    I have a problem which I would like to share here.
    I want to make a text file from a table in Form 5.0.
    spool is not acceptable. I have made a procedure for
    that but it is working up ok point. If I left the rest
    columns then it is ok. otherwise it gives a window
    message "F50dbg32 Illigal operation" and terminates.
    PROCEDURE make_text IS
    in_file Text_IO.File_Type;
    out_file Text_IO.File_Type;
    linebuf VARCHAR2(132);
    cursor c1 is
    select * from emp;
    begin
    out_file := Text_IO.Fopen('echo.txt', 'w');
    for c1rec in c1
    LOOP
    Text_IO.New_Line(out_file,1);
    Text_IO.Putf(out_file,to_char(c1rec.empno));
    Text_IO.Putf(out_file,' '); -- for gap between columns
    Text_IO.Putf(out_file,c1rec.ename);
    Text_IO.Putf(out_file,' ');
    Text_IO.Putf(out_file,c1rec.job);
    Text_IO.Putf(out_file,' ');
    ----ok -- upto here
    Text_IO.Putf(out_file,to_char(c1rec.mgr));
    Text_IO.Putf(out_file,to_char(c1rec.hiredate));
    Text_IO.Putf(out_file,to_char(c1rec.sal));
    Text_IO.Putf(out_file,to_char(c1rec.comm));
    Text_IO.Putf(out_file,to_char(c1rec.deptno));
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    Text_IO.Fclose(out_file);
    END;
    Other requirement is the text in the file gets zig zag.
    I want to start every column from a fixed column in the
    text file.
    My text looks like this :-
    7499 ALLEN SALESMAN
    7521 WARD SALESMAN
    7566 JONES MANAGER
    requirement is :-
    7499 ALLEN SALESMAN
    7521 WARD SALESMAN
    7566 JONES MANAGER
    7654 MARTIN SALESMAN
    7698 BLAKE MANAGER
    If someone have solution pl suggest asap.
    thanks
    [email protected]

    I think you can try to use your own buffer to construct a text line. For example:
    buf varchar2(4000);
    LOOP
    buf:=
    to_char(c1rec.empno) || ' ' ||
    c1rec.ename || ' ' ||
    to_char(c1rec.deptno);
    text_io.put_line( buf );
    END LOOP
    I think It may solve the problem.
    I want to start every column from
    a fixed column in the text file.You could use the LPAD or RPAD functions. For example:
    buf:=
    lpad( to_char(c1rec.empno), 10, ' ' ) || ' ' ||
    lpad( c1rec.ename, 50, ' ' ) || ' ' ||

  • A text_io problem: ORA-302000

    Hi,all:
    I have 2 apps on form.
    The first one is to read from file, and the second is to write on the file.
    Firstly, i have created the file on the server, and the file(abc.txt)'s permission is rwxr--r--.
    Then i tested the first one, it can read from file well.
    But when i tested the second, it throwed a exception: ORA-302000.
    I was so confused. why it can read from file with text_io, but can not write?
    Can anyone help me to solve this problem, Thanks so much.
    Here's my code:
    1.WHEN-BUTTON-PRESSED(to read): works fine
    DECLARE
         in_file text_io.file_type;
         line_bufer varchar2(80);
         lv_strtmp varchar2(100);
         errnum NUMBER                := ERROR_CODE;
         errtxt VARCHAR2(80) := ERROR_TEXT;
         errtyp VARCHAR2(3)      := ERROR_TYPE;
    BEGIN
         in_file := text_io.fopen('/home/cn01278/abc.txt', 'r');
         text_io.Get_Line(in_file,line_bufer);
         lv_strtmp := substr(line_bufer, 1,10);
         :blk_text.txt_content := :blk_text.txt_read_err || lv_strtmp;
         text_io.Fclose(in_file);
    END;
    2.WHEN-BUTTON-PRESSED(to write): thown an exception
    DECLARE
              out_file text_io.file_type;
              line_bufer varchar2(80);
              lv_strtmp varchar2(100);
              lv_content varchar2(100);
              errnum NUMBER := ERROR_CODE;
              errtxt VARCHAR2(80) := ERROR_TEXT;
              errtyp VARCHAR2(3) := ERROR_TYPE;
    BEGIN
         message('111',acknowledge);
              out_file := text_io.fopen('/home/cn01278/abc.txt', 'w');
              message('222',acknowledge);
              text_io.put('123');
              text_io.new_line;
              text_io.put_line(out_file, 'abcd...');
         text_io.fclose(out_file);
    END;
    3.ON-ERROR Trigger
    DECLARE
         errnum NUMBER := ERROR_CODE;
         errtxt VARCHAR2(80) := ERROR_TEXT;
         errtyp VARCHAR2(3) := ERROR_TYPE;
    BEGIN
    message('error:',acknowledge);
         Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt,acknowledge);
         --:blk_text.txt_err := errtyp||'-'||TO_CHAR(errnum)||': '||errtxt;
         text_io.fclose(out_file);
         RAISE Form_Trigger_Failure;
    END;
    -----------------------------------------------------------------------------------

    Thanks for attension.
    the problem is resolved, it's a access/right problem with the file(abc.txt).
    after i change the file permission from rwxr--r-- to rwxrw-rw-, then it works fine.
    But I have some confuse about it.
    1.The file must exist firstly. if not, then read or wirte the file will cause the ORA-302000 error. Can the file not exist? Can anyone tell me how to create file(abc.txt) with text_io if the file not exist.
    2.If the file was created by A, and A have rw rights, but the group owner have no rw rights, then you run the form by A(connect DB by A), it would cause ORA-302000 error too(both read and write).Why the group owner must have rw rights, or the form can not works fine?
    By the way, my DB account and my App server(Linux) account are same(both A).

  • Importing large character string using Text_io

    Hi,
    I have been using text_io and/or client_text_io on forms 10G, DB= 9i succesfully for a while to both read (parse) and write csv files. Today I ran across a problem. The csv file has two columns, one a short character string ( v_name varchar2(25)) and the other a character field that is usually less than 3000 characters but can be as high as 15000 characters (actually DNA sequences). Apparantly, the text_io is not working when this field is >~4000 characters. The database column that this is loading in to is a CLOB and the variable (v_seq) itself is set for varchar(15000) whereas the string (str) loaded with text_io.getline can be up to 32000 characters. The code below works fine If the second column in the csv is less than ~4000 characters. I tried to set the str and v_seq variables to CLOB but that did not run at all. Can anybody tell me how I can load longer character strings from csv files?
    Thanks
    Larry Solomon
    DECLARE
    file_name varchar2(100);
    file1 TEXT_IO.FILE_TYPE;
    str VARCHAR2(32000);
    v_comma number;
    v_comma2 number;
    v_name varchar2(25);
    v_seq     varchar2(15000);
    BEGIN
    DEBUG.SUSPEND;
    file_name := :control.orf_file_name;
    file1 := client_TEXT_IO.FOPEN( file_name,'r' );
    loop client_TEXT_IO.GET_LINE( file1, str );
    v_comma := instr(str, ',');
    v_name := substr(str,1, v_comma-1);
    v_seq := substr(str,v_comma+1, length(str)-v_comma);
    insert into ibase( name, orf)
    values ( v_name, v_seq);
    END LOOP ;
    client_TEXT_IO.FCLOSE( file1 );
    commit;

    I believe the largest allowable size of a varchar2 is 8000 now on 10.2 of the database. We don't use 10.2 RSFs so we have a upper limit of 4000 in our client side PLSQL.
    That will surely be a problem in your code. You probably need to rewrite to make chunks out of your data and insert in chunks into the database.

  • Barcode report is not working in linux

    hi,
    i am running the report using the barcode, which is running perfectly in the windows server - i meant in the report builder.
    but when i try run the same report in linux server through application, i am getting the below mentioned error:
    Terminated with error:
    REP-1401: 'beforereport': Fatal PL/SQL error occurred. ORA-39565: Message 39565 not found; product=RDBMS; facility=ORA
    below mentioned is the code written in beforereport trigger:
    globals.barcode_to_use := BarCodeConstants.BAR_CODE_128;
    globals.bcobj := barcodemaker.new();
    i have include the jar file path /ora/u01/oracle/v101/ds1/reports/jlib/oraclebarcode.jar both in class path and report_path, but still its not working.
    any one had solve this issue?...pls help me out
    for you info:
    CLASSPATH=/ora/u01/oracle/v101/ds1/j2ee/OC4J_BI_Forms/applications/formsapp/formsweb/WEB-INF/lib/frmsrv.jar:/ora/u01/oracle/v101/ds1/jlib/repository.jar:/ora/u01/oracle/v101/ds1/jlib/ldapjclnt10.jar:/ora/u01/oracle/v101/ds1/jlib/debugger.jar:/ora/u01/oracle/v101/ds1/jlib/ewt3.jar:/ora/u01/oracle/v101/ds1/jlib/share.jar:/ora/u01/oracle/v101/ds1/jlib/utj.jar:/ora/u01/oracle/v101/ds1/jlib/zrclient.jar:/ora/u01/oracle/v101/ds1/reports/jlib/rwrun.jar:/ora/u01/oracle/v101/ds1/forms/java/frmwebutil.jar:/ora/u01/oracle/v101/ds1/reports/jlib/oraclebarcode.jar
    RW=$ORACLE_HOME/reports; export RW
    REPORTS_PATH=$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo:$ORACLE_HOME/reports/integ:$ORACLE_HOME/reports/printers:${REPORTS_PATH}; export REPORTS_PATH
    REPORTS_TMP=/tmp; export REPORTS_TMP
    REPORTS_NO_DUMMY_PRINTER=TRUE; export REPORTS_NO_DUMMY_PRINTER
    REPORTS_TAGLIB_URI=/WEB-INF/lib/reports_tld.jar; export REPORTS_TAGLIB_URI
    REPORTS_CLASSPATH=$ORACLE_HOME/reports/jlib/rwbuilder.jar:$ORACLE_HOME/reports/jlib/rwrun.jar:$ORACLE_HOME/jlib/zrclient.jar:$ORACLE_HOME/j2ee/home/oc4j.jar:$ORACLE_HOME/j2ee/home/lib/ojsp.jar:$ORACLE_HOME/reports/jlib/oraclebarcode.jar; export REPORTS_CLASSPATH
    repserver.conf file setting:
    <engine id="rwEng" class="oracle.reports.engine.EngineImpl" initEngine="1" maxEngine="1" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="90000" jvmOptions="-Xms512m -Xmx512m" classPath="/ora/u01/oracle/v101/ds1/reports/jlib/oraclebarcode.jar">
    <property name="sourceDir" value="/ora/u02/oraadmin/config/as2/app_qits_run"/>
    <property name="tempDir" value="/ora/u02/oraadmin/config/as2/app_qits_tmp"/>
    </engine>
    <engine id="rwURLEng" class="oracle.reports.urlengine.URLEngineImpl" initEngine="1" maxEngine="1" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="60000" classPath="/ora/u01/oracle/v101/ds1/reports/jlib/oraclebarcode.jar"/>
    thanks
    renjish

    Hello,
    The first step if to find the PL/SQL line causing the error in 'cf_1formula':
    create a procedure Trace in your Reports : (modify the line trace_file := Text_IO.Fopen('d:\temp\rep_trace.txt', 'A'); to adapt the filename to your system)
    PROCEDURE Trace (trace_string in varchar2) IS
    trace_file Text_IO.File_Type;
    BEGIN
    trace_file := Text_IO.Fopen('d:\temp\rep_trace.txt', 'A');
    Text_IO.Put_Line(trace_file, trace_string);
    Text_IO.Fclose (trace_file);
    END;
    Then, add some calls to this procedure in the program unit 'cf_1formula'
    trace('Before line 1';
    <PL/SQL code of line 1>
    trace('Before line 2';
    <PL/SQL code of line 2>
    trace('Before line 3';
    <PL/SQL code of line 3>
    Excecute the Reports and find in the file 'd:\temp\rep_trace.txt' the last line executed.
    Regards

Maybe you are looking for

  • How to use alias in "From" field when I send a mail with utl_smtp ?

    Hi all, I'm using a PL/SQL package with an Oracle 11G database to send mails. It works fine but instead of use of my mail in "From" field like "[email protected]" as sender E-mail address, I would like to have "Toto" in the sender address. I tryied t

  • Mac book pro -intel duo  - will my old software work with it?

    Not sure if I should get the 2.4 GHZ Intel Core 2 Duo Mac book pro as I have heard old software will not work on it and I really do not want to have to buy new software, just to add on to the cost. Can anyone help. The software I have that I want to

  • Message Mapping (user-defined function)

    Hi all, Is there anyway to determine the XML message ID using an user-defined function in Message Mapping? When I go to SXI_MONITOR I see that all messages have an unique ID, but I'm having some difficulties to understand if there is any way to get t

  • Which macbook for video

    I am buying myself an apple macbook pro next week. It will be a 15inch but I am wondering what version I should pick. I will be editing video for internet, managing blog and website, working on photoshop.. so quite a lot of media stuff. I am not doin

  • I can't turn my Ipad2 on, what can I do?

    I can't turn my Ipad2 on, what can I do?