Reading text file from stored procedure

Hi
I have a text file coming daily. I need to read the file.
1st line contain the file source
Last line contain the no of records in the file.
I need to count all the lines in text file compare with the number of lines mentioned in the last line of the file.
Can any one help me in achieving the above task.
Thanks a lot in advance.
KLSRAO

Re: UTL_FILE Examples

Similar Messages

  • Read XML file into stored procedure

    hi to all, i have this stored procedure :
    create or replace
    PROCEDURE INSERTXML(
                                          p_xml_in CLOB,
                                          p_table IN VARCHAR2 ) AS                                     
      insCtx DBMS_XMLStore.ctxType;
      v_rows NUMBER;
    BEGIN
      insCtx := DBMS_XMLStore.newContext(p_table); -- get saved context
      dbms_xmlstore.setRowTag(insCtx,'Row');
      DBMS_XMLStore.clearUpdateColumnList(insCtx); -- clear the update settings
      -- set the columns to be updated as a list of values
      DBMS_XMLStore.setUpdateColumn(insCtx,'ORDERNUMBER');
      DBMS_XMLStore.setUpdateColumn(insCtx,'PLANT');
      DBMS_XMLStore.setUpdateColumn(insCtx,'MATERIAL');
      DBMS_XMLStore.setUpdateColumn(insCtx,'LINENUMBER');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'NOMSPEED');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'STARTDATE');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'FINISHDATE');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'TARGETQTY');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'UNIT');
      DBMS_XMLStore.setUpdatecolumn(insCtx,'SYSTEMSTATUS');
      v_rows := DBMS_XMLStore.insertXML(insCtx, p_xml_in);
      -- Close the context
      DBMS_XMLStore.closeContext(insCtx);
    END;
    that passes xml file and puts in table but SAP Mii have the limitation that the maximun value of strings is 4000..how can i pass this limitation?!?! someone have some ideia?!?!...i have now to read XML file to stored procedure...could someone help me??
    regards and thanks in advance

    hello Michael thanks for your help but appear to me some strange errors, i created this package in Oracle SQL Developer...
    create or replace PACKAGE PACKAGE_XML AS
      type return_cur IS ref CURSOR;
      procedure INSERTXML4(
        xmlDoc IN CLOB,
        tableName IN VARCHAR2,
        myRC IN OUT return_cur
    END PACKAGE_XML;
    and compile and everthing is ok, then i changed my SP and it looks like this:
    create or replace PROCEDURE INSERTXML4
      (xmlDoc in CLOB, tableName in VARCHAR2, refcur in out package_xml.return_cur)
    AS
      insCtx dbms_xmlsave.ctxType;
      rowcnt number;
    BEGIN
      insCtx := dbms_xmlsave.newContext(tableName);
      dbms_xmlsave.setignorecase(insCtx,1);
      rowcnt := dbms_xmlsave.insertxml(insCtx, xmlDoc);
      dbms_xmlsave.closecontext(insCtx);
      OPEN refcur FOR SELECT rowcnt AS cnt FROM dual;
    END INSERTXML4;
    but i cant compile...it throws this errors:
    Error(5,10): PLS-00201: identifier 'DBMS_XMLSAVE.CTXTYPE' must be declared
            Error(5,10): PL/SQL: Item ignored
            Error(8,3): PLS-00320: the declaration of the type of this expression is incomplete or malformed
            Error(8,3): PL/SQL: Statement ignored
            Error(9,3): PL/SQL: Statement ignored
            Error(9,30): PLS-00320: the declaration of the type of this expression is incomplete or malformed
            Error(10,3): PL/SQL: Statement ignored
            Error(10,13): PLS-00201: identifier 'DBMS_XMLSAVE.INSERTXML' must be declared
            Error(11,3): PL/SQL: Statement ignored
            Error(11,29): PLS-00320: the declaration of the type of this expression is incomplete or malformed
    do you could help..
    regards
    Mário

  • How can I read text files from LAN if I only know the hostname?

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    <p>1. How can I read text files from LAN if I only know the hostname, or IP address?
    <p>2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.
    (ex. how can I read the 120th line?)
    <p>Please help!
    <p>sorry for the bad english

    I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
    1. How can I read text files from LAN if I only know the hostname, or IP address?You need to know the URL of the file. You need to know the hostname, port, protocl and relative path.
    The hostname is server, not file.
    2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.Use the seek() to get to a random byte.
    (ex. how can I read the 120th line?)The only way to find the 120th line is to read the first 120 lines. You can use other file formats to find the 120th line without reading the whole file but to need to be able to detremine where the 120th line is

  • HI,,,How to read text file from my emulators root

    hi friends,
    Actully i m having problem with file connection i.e. i cant read text file from my root of the emulator.....
    i have tried like this...
    plz help me out
    String uri = "file:///C:/WTK22/appdb/DefaultColorPhone/filesystem/root1/New Folder/main.txt";
    InputConnection conn = (InputConnection)Connector.open( uri,Connector.READ );
    InputStream in = conn.openInputStream();
    conn.close();
         for(int j=0;j<12;j++)
         ch=in.read();
         str.append((char)ch);
    par1=str.toString();
    in.close();
         screen4.append(par1);
         display.setCurrent(screen4);

    still its not working.........
    String uri = "file:///C:/WTK22/appdb/DefaultColorPhone/filesystem/root1/readme.txt";
                        FileConnection conn = (FileConnection)Connector.open( uri,Connector.READ);
                        InputStream in = conn.openInputStream();
                        conn.close();
                   String ss="";
                   String str1="";     
                   int ch=0;
                   byte b[]=new byte[753];     
                             ch=in.read(b,0,753);
                             str1= new String(b,0,ch);
                                  ss=str1.substring(493,501);                     
                        screen4.append(ss);
                        display.setCurrent(screen4);
                        }catch(IOException io){}

  • Reading text file from database server in OA Page

    Hi Guys,
    I am trying to embed an applet with in an OA Page. The applet is used to mainly for showing Gantt chart. I have to pass my connection details from OA Page to applet, I dont pass directly the connection details to the applet so i am placing all the server details, user name and password in a text file on the database server.
    So from the OA Page i have to read the contents of the file on the database server and pass them to the applet using the <PARAM> tag. My question is how to read the text file from the database server.Any Inputs?
    Thanks in advance for your help.
    Regards,
    Nagesh Manda.

    If the file to be read is on the database, then it makes sense to use the pl/sql code to read the file. Make a call to this pl/sql code from page controller to get back the values.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                           

  • Can we able to call .bat file from Stored procedure?

    My actual requirement is to import an csv file(where it contains a table) into oracle Database from the front end screen when the csv file location is given.
    Where in the screen (designed by dotnet) a browse option will be present and I will give the csv file location and this will be passed into stored procedure as an input parameter.
    Now I need a stored Procedure that can Import my csv file table data into Oracle database10g.
    I shoudnot use the import option present in the physical Oracle Database.
    Can any one please provide me the stored Procedure?

    NGK246 wrote:
    My actual requirement is to import an csv file(where it contains a table) into oracle Database from the front end screen when the csv file location is given.
    Where in the screen (designed by dotnet) a browse option will be present and I will give the csv file location and this will be passed into stored procedure as an input parameter.
    Now I need a stored Procedure that can Import my csv file table data into Oracle database10g.You do not seem to understand the basic concept of client-server. If you supply a file location for the server code, and that location is not on the server, how do you expect the server to access that file in that location?
    You cannot expect the server to hacks its way across the network, crack open a remote file system somewhere, and steal that file from that location.
    As the client has access to that location and file, the client needs to read that file and supply that file's content to the server. This is how the server receives a file from a client. With Oracle. With FTP. With SCP. With SFTP. With HTTP. With SMTP and file attachments to e-mails. Etc.
    This is not specific to Oracle. This is a fundamental concept. So the problem here is your ignorance of client-server and not a problem with Oracle and not a problem with PL/SQL.
    I shoudnot use the import option present in the physical Oracle Database.Not sure what this mean, but the basic statement that "+we should not use feature 123 or feature ABC of Oracle+", is invariable an utterly idiotic statement to make. Kind of like buying a car and then making the statement that groceries may not be put into the truck as the car's trunk should not be used.
    Can any one please provide me the stored Procedure?Very arrogant of you to assume that others will spend their free time writing code for you - with you copying-and-pasting that code and providing it to your employers, as your work...

  • How to get tab delimited text file when Stored Procedure executes ?

    Hello Everyone,
    I have a stored procedure which returns 1 result set as an output.
    I want the output as a Tab Delimited Text file.
    I know that I can use SSIS and get the same output but I am not allowed to use SSIS in this case.
    Is there any other ways ?
    I will be really appreciate If someone can answer with, How many different ways I can get Tab delimited text file ?
    Thanks in advance
    Henary

    you can do that by using SQLCMD
    http://blog.sqlauthority.com/2013/03/05/sql-server-exporting-query-results-to-csv-using-sqlcmd/
    you can also use BCP 
    EXEC master..xp_cmdshell 'bcp "select * from tempdb.dbo.orders" queryout "c:\output.txt" -c -T'
    EXEC master..xp_cmdshell 'bcp "exec usertest.dbo.proctest" queryout "c:\output.txt" -c -T'
    --Prashanth

  • Reading text file from forms6i

    hi all ,
    i want to read a text file how can i classify its coordinates (columns) to insert it into different columns of a table .
    i want that first ten characters of text file will go in first column of table , next 5 characters will go into 2nd column and so.
    but how to identify the characters from - to for columns.
    Message was edited by:
    Najeeb ur Rehman

    declare
    v_line varchar2(2000);
    v_text_io TEXT_IO.FILE_TYPE;
    begin
    v_text_io:= TEXT_IO.FOPEN(c:\temp\file.txt,'r');
    LOOP
    TEXT_IO.GET_LINE(v_text_io, v_line);
    v_first_column:= SUBSTR(v_line,1,10);
    v_second_column:= SUBSTR(v_line,11,5);
    INSERT INTO your_table VALUES(v_first_column, v_second_column);
    END LOOP;
    EXCEPTION
    WHEN no_data_found
    THEN
    TEXT_IO.FCLOSE(v_text_io);
    END;
    You can also try it with the sql-loader.
    tom

  • Reading Text File from selection Screen and populating table (Urgent)

    Hi All,
    I have some requirment like i in my report i have to initial my Input feild from text file is it good to populate a internal table or range.
    I have three feild in a excel file that entry can more then 500
    data example
    Matnr Date             Day
    A1     10.07.2007    12
    B1     10.07.2007    10
    A1     19.07.2007    15
    C1     20.08.2007    30
    E1     11.09.2007    12
    This report for Price Protection claim.
    even u can help me out with proper table plz this is urgent.

    Hi..
    <b>parameters:</b>
      p_file(50) type c.
    <b>data:</b>
      begin of itab occurs 0,
         matnr type vbak-matnr,
         date type sy-datum,
         day(2) type n,
      end of itab.
    <b>at selection-screen on value-request for p_fname.</b>
      perform get_path.
    <b>start-of-selection.</b>
    <b>CALL FUNCTION 'GUI_UPLOAD'</b>
      <b>EXPORTING
        FILENAME                      =  p_fname
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'</b>
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
    <b>  TABLES
        DATA_TAB                      = itab</b>
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    This Sub routine is used to get the file name
    *There are no interface parameters passed to this subroutine.
    FORM get_path .
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
       DEF_FILENAME            =  P_FNAME
      DEF_PATH               = ' '
      MASK                   = ' '
      MODE                   = ' '
      TITLE                  = ' '
    IMPORTING
       FILENAME                =  P_FNAME
      RC                     =
    EXCEPTIONS
       INV_WINSYS             = 1
       NO_BATCH               = 2
       SELECTION_CANCEL       = 3
       SELECTION_ERROR        = 4
       OTHERS                 = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " get_path
    data:

  • How to execute .sql file in Stored Procedure?

    Hi,
    I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
    This .sql file will have set of update statement. I need to pass value to this update statement.
    Kindly please help me.
    Regards,
    Irfan

    This is required as part of Data Migration where  i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
    How have you determined that it's "better" to have seperate scripts?  I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
    So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
    Question: Why do you have tables with different names that all need the same process doing to them?
    Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
    e.g.
    create procedure update_table(tbl_name varchar2) is
    begin
      execute immediate 'update '||tbl_name||' set lastupdate = null';
    end;
    As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer.  Please do take the time to read the FAQ and post appropriate details so people can help you.

  • Can I save and read text files on a server that I host?

    Hello everyone,
    I am a java hobbiest. I was wondering if I set up my own server, running out of my house, could I have my applets save to my computer and read from my computer without having to learn JDBC and a DATABASE language. In other words could i just have my applet save and read text files from and to my server?
    I'm trying to set up a sight for my 5th grade class where parents can log into. Thanks for your time.
    Oh yeah, which is easier, learning how to set up a server or learning JDBC and a DATABASE language?
    If you have any other good idease please tell me them
    Thank you, Bryan

    Short answer: This isn't gonna work
    Long answer: For this to work, the first thing you're going to need is a static IP address and a DNS name registered -actually you don't necessarily need #2 but you're probably gonna want it and it's by far the easier of the steps.
    As far as I know to get a fixed IP address you've either gotta be directly attached to a larger network (ie university network) or get a leased line from an ISP.
    Once you've got that done come back to us.

  • Producing text file from PL/SQL procedure (UTL_FILE)?

    Hi,
    I need to produce a text file from a PL/SQL procedure. My output should be a little over 38K records and my query has 70 fields. I'd like to separate the fields by pipe delimiters in the text file. I can either concatenate all 70 fields into one variable for each record or send all 70 fields over with a pipe, whichever is easier. It looks like I can't spool within PL/SQL but UTL_FILE might be an option from what I'm reading. Does anyone have any good, simple example(s) to produce a text file using this package in calling multiple fields from a LOOP? Our os is UNIX and db is Oracle 9i.
    Also, I've read that UTL_FILE has a record output of 1,023 bytes. Is this for each record line or the whole file size? I belive the max # of characters for each line wouldn't exceed 500 characters. The 38K rows I have for the data set would be well over 1MB. If this is the case, is there a work around to produce a larger text file?
    Any suggestions and/or examples would be greatly appreciated.
    Thanks,
    Eric

    Assuming the goal is to create a text file on the database server, you can use UTL_FILE here. Each line can be 1023 characters, but you can have as many lines as you'd like.
    Tom Kyte has an example here
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:235814350980
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Reading and writing to a text file from an Applet

    I'm a novice java programming with very little formal programming training. I've pieced together enough knowledge to do what I've wanted to do so far...
    However, I've been unable to figure out how to read and write to a text file from an Applet (I can do it from a normal java program just fine). Here is a simple example of what I'd like to do (you can also look at it on my website: www.stat.colostate.edu/~leach/test02/test02.html). I know that there is some problem with permission/security but I'm not smart enough to understand what the error messages are telling or understand the few books I have. If anyone can tell me how to get this applet to work, or direct me to some referrences that would help me out I'd really appreciate it.
    Thanks,
    Andy
    import java.applet.Applet;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    public class test02 extends Applet {
    public Button B_go;
    public GridBagConstraints c;
    public void init() {
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    B_go = new Button("GO");
    c.gridx=1; c.gridy=0; c.gridwidth=1; c.gridheight=1;
    c.weightx = c.weighty = 0.0;
    B_go.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    print_stuff();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.add(B_go,c);
    public static void print_stuff() {
    try{
    File f = new File("test02.txt");
    PrintWriter out = new PrintWriter(new FileWriter(f));
    out.print("This is test02.txt");
    out.close();
    }catch(IOException e){**/}
    }

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

  • Reading a text file from a URL

    I am having problems trying to read a text file from a URL.
    This is the code i have been using:
    package Java;
    import java.net.*;
    import java.io.*;
    public class Main_1 {
    public static void main(String[] args) throws Exception {
         URL myAddress = new URL("http://www.geocities.com/simonrobinson1/java/farrago.txt");
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        myAddress.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    but it returns an error saying:
    java.net.NoRouteToHostException: Operation timed out: no further information
    at java.net.PlainSocketImpl.socketConnect(Native Method) .....etc etc.
    Is this just a problem due to my network or is there something wrong with my code ????

    Altho you can access the file by typing the URL in a browser, geocities being a free web-hosting service don't like you to access the materials without seeing their ads. You have to find a way to trick it into thinking that you are indeed coming in from a web browser even tho you aren't.
    V.V.

  • Read a text file from DB directly (don't use PLSQL).

    how can I Read a text file from DB directly (don’t use PLSQL). ?

    If there is a known structure, you could use External Table access and query that "file" as any table.
    Nicolas.

Maybe you are looking for

  • Why am I being charged an extra $20 on my current bill?

    I just upgraded to the iPhone 5S in the middle of December and in doing so had to give up my unlimited data plan. My new plan is the 4GB with mobile hot spot plan, and my regular monthly bill is now supposed to be $94.99 after changing phones and pla

  • Question - making rummy card game applet

    Hi, I am not sure if this is the right place to be putting this, if not please let me know. I'm trying to make an applet for the card game rummy for my final project for school. I was wondering if I could get some help on how to load a card image fro

  • How to view photos in alphabetical order

    Well I have about 300 photos that need to be ordered alphabetically but my iPod touch does it by the date taken I believe and so this is no good for me so is there any program that will allow me to batch change date taken, on photos and with time/dat

  • Export-Mailbox, error code: -2147221219

    Hi Guys When I try to export a mailbox from our Exchagne 2010 Rollup 4 environment (not sp1 or sp2) I recieve the following error: [PS] C:\Windows\system32>Export-Mailbox -Identity ad.local\user -PSTFolderPath c:\temp\user.pst Error was found for USE

  • ** Is it possible to run a windows .bat script job from ODI between server?

    Hello Friends, We have ODI 10.1.3.5 on a Win2003 Server. Have a windows Batch script job .bat(this is a related to a different program - DRM) on a different Windows 2003 server...is it possible to execute .bat job thru ODI between servers? Appreciate