UTL_FILE vs Oracle Tables

Hi Oracle Gurus,
I have a question, My team is using UTL_FILE to write process logs to physical files. My thinking is that if they use Direct tables to Insert process log its going to be faster compared to UTL_FILE. Am I right to think so?
Thanks,
Faisal.

But the output is different. How can you compare the two solutions? Of cause inserting into a table is faster then writing to the file. As with each rule there are exceptions, like locking conflicts, out of tablespace, etc.
But afterwards you do have no file. If you need a file, then use utl_file. If not then not.
Also backup strategies tend to play a role when dealing with large anmount of data. You might want those logs independent from the database or maybe you don't.
Message was edited by:
Sven W.

Similar Messages

  • Import Text File to Oracle Table

    Hi Guys,
    Just needed some advice on how to approach this project. I need to set up an automated schedule to import a text file into an oracle table. There will be a folder set up, where a file is put every day for me. The file will have a name such as Name_Extract_<Date>. It will always start with the words Name_extract_ and the date appended to it. I need to import this text file into oracle, then perhaps copy the file to another folder when import is finished.
    What will be the best method to use to accomplish this?? SQl Loader, UTL_FILE package? Any help will be appreciated.

    Not much details but depending on versions etc of your Oracle database I'd look into external tables. Perhaps even leverage DBFS (only available in 11.2).
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/tablecls.htm#CNCPT1141
    -Andy

  • Generating an excel sheet from an oracle table

    Hi,
    What is the easiest way to generate an .xls report from oracle i.e. when the user for example views some records in an oracle table using SQL_FORMS I want to then give them a button where they get a simple .xls report of the records in the table.
    I have heard 'ole' method is one way, is that the best method and how is it done exactly...?
    Thanks

    Have you tried this?
    CREATE OR REPLACE procedure print_reports is
    cursor c_mgr is
    select
    t1.ename,
    t1.empno
    from
    emp t1
    where exists
    (select
    'x'
    from
    emp t2
    where
    t1.empno=t2.mgr);
    cursor c_direct_reports (cv_mgr number) is
    select
    empno,
    ename,
    job,
    hiredate,
    sal
    from
    emp
    where
    mgr=cv_mgr;
    wfile_handle utl_file.file_type;
    v_wstring varchar2 (100);
    v_header varchar2(100);
    v_file varchar2(100);
    v_date varchar2(20);
    begin
    select
    to_char(sysdate,'dd_mon_yyyy')
    into
    v_date
    from
    dual;
    v_header :='empno'||chr(9)||'ename'||chr(9)||'job'||chr(9)||'hiredate'||chr(9)||'sal';
    for r_mgr in c_mgr loop
    v_file := r_mgr.ename||'_direct_reports_'||v_date||'.xls';
    wfile_handle := utl_file.fopen ('REPORTS',v_file, 'W');
    utl_file.put_line(wfile_handle,v_header);
    for r in c_direct_reports(r_mgr.empno) loop
    v_wstring := r.empno||chr(9)||r.ename||chr(9)||r.job||chr(9)||to_char(r.hiredate,'dd/mm/yyyy')
    ||chr(9)||r.sal;
    utl_file.put_line(wfile_handle,v_wstring);
    end loop;
    utl_file.fclose (wfile_handle);
    end loop;
    end print_reports;
    Reference:
    http://www.orafusion.com/art_excel.htm

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • How to read RMAN data into an ORACLE Table?

    Hallo,
    With regards to RMAN, how should we store the data into a database table, from the commands which can run only on RMAN prompt without using Recovery Catalog?
    For Example:
    RMAN> Report need backup days 3;
    RMAN DATA:
    RMAN-03022: compiling command: report
    Report of files whose recovery needs more than 3 days of archived logs
    File Days Name
    1 1203 D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF
    2 1203 D:\ORACLE\ORADATA\TEST\RBS01.DBF
    3 1203 D:\ORACLE\ORADATA\TEST\USERS01.DBF
    Should it done via UTL_FILE?
    If so, could someone give simple example/code how to do that, in order to write this RMAN data into an Oracle Database table?
    I also set the utl_file_dir parameter to a particular directory in my database.
    Thanks
    W.Benvort

    Actually, I am not using Recovery Catalog, so the views like RC_database, Rc_tablespaces etc , which are specific to recovery catalog are not available.
    r.- this make sense at 100% because those views belong to the recovery catalog.
    So, I wanted that these information, which we can get via using the commands like above, transfer into an Oracle table
    r.- If you want to access the views of the Recovery Catalog to store part of that information in tables you have to have the database registered in a Recovery Catalog.
    Should we keep the Recovery Catalog in Control file? Instead of using separate Schema.
    r.- I recommend you to create a catalog for your database because the space the controlfile to store information regarding RMAN is reused and you can lose important information about your backups.
    Can we run Catrman.sql script as a sys in order to keep the recovery catalog in sys schema?
    r.- As you know, this is not recommended at all.
    Conclusion : Create a Recovery Catalog and you will be able to perform all that you want regardind what you mentioned above.
    I have a thread for this:
    RMAN ( CATALOG CREATION ) STEP BY STEP by Joel Pérez
    Joel Pérez
    http://otn.oracle.com/experts

  • 1.is it possible to read a .xls file and load it into an oracle table

    1.is it possible to read a .xls file and load it into an oracle table, using oracle database or oracle forms i.e. either utl_file, or text_io, or any other oracle tool.
    As far as I know we need a csv file or a txt ( tab delimited) file ?
    2.Are there any windows tools for the same

    Hi,
    If you want to use the DDE package to read the XLS file then yes, you will neeed to know the number of rows and columns in the input file.
    i.e. How will you know :
    1) How many columns are there in the input file.
    If I have a XLS file with the following data :
    R1C1 R1C2 R1C3 R1C4 R1C5 R1C6 R1C7
    xxx xx x
    Where R represents row and C represents column, then how will you know the each row has 7 columns. If you know the answer upfront, then it's not a issue.
    Using the DDE apprach, you will have to specify the RowNum and the ColumnNo of each idividual cells to read/write data from xls sheet.
    Look at the syntax in my ealier post.
    using the other approch (i.e. comma delimited text file - CSV file) , you need not know the number of columns as you can loop thru the input record till the last column is read.
    All you have to do is to look for the 'n' occurances of the field delimiter say ',', do a substr from the current position to the point where the ',' was found.
    This process is to be repeated in a loop till all columns are read.
    The TEXT_IO package can trap for EOF (End Of File).
    Hope I made myself clear.
    -- Shailender Mehta --

  • Import data from Oracle table into flat file

    How to import the data in the oracle table into flat file using UTL File of PL/SQL....
    I am new in PL/SQL..
    can someone help me in writing query?

    Note : Not Tested.
    DECLARE
    V1 VARCHAR2(32767);
    F1 UTL_FILE.FILE_TYPE;
    cursor c1 is select ename,empno from emp;
    r_c1 c1%rowtype;
    BEGIN
    -- In this example MAX_LINESIZE is less than GET_LINE's length request
    -- so the number of bytes returned will be 256 or less if a line terminator is seen.
    open c1;
    F1 := UTL_FILE.FOPEN('MYDIR','MYFILE','W',256);
    loop
    fetch c1 into r_c1;
    v1:= r_c1.ename||''||To_char(r_c1.empno);
    UTL_FILE.PUT_LINE (F1, v1,TRUE);
    v1:= null;
    Exit when c1%not found;
    end loop;
    UTL_FILE.FCLOSE(F1);
    END;
    http://download.oracle.com/docs/cd/B19306_01/appdev.102
    ------------------------------------------------------------------

  • IMPORT EMAILS BODY INTO ORACLE TABLE ;;; PLS HELP ME

    Hi Every Body,
    I would like to import the body of some Emails into one Oracle table in PLSQL Language,
    Can Someone help me and tell me how to do it?
    Thank you very much
    W

    Where is the email stored? If on the file system, you can use UTL_FILE to open the file.
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#ARPLS069

  • Is it possible to export (expdp) oracle table from client machine ?

    Is it possible to export (expdp*) oracle table from client machine, without using Remote desk top connection ?*
    1) Database-10g server is in America
    2) client machine is in India
    3) Oracle client-10g software is installed in my machine
    4) I am able to connect to the server, could see all tables
    5) one table is with 35 million record, I wanted to export this table using data pump, is it possible?
    note: without using Remort desk top connection.

    Hi
    I used the following syntax , but I am getting error
    6) connect sys as sysdba
    create directory test_dir as '/dbusr1/exp_test'
    grant read, write on directory test_dir to user1;
    7) expdp user1/pwd1@xyz tables=test_1 directory=test_dir dumpfile=test_file.dmp logfile=test_file.log
    8) Errors
    In linux prompt I am getting this error
    -bash: expdp: command not found
    In windows cmd prompt I am getting this error
    ORA-39002: invalid operation
    ORA-39070: Unable to open the log file.
    ORA-29283: invalid file operation
    ORA-06512: at "SYS.UTL_FILE";, line 488
    ORA-29283: invalid file operation
    9) why ?
    -- Does the user ( "user1") should have any system level privilege ? to export his own table?
    -- This folder ('/dbusr1/*exp_test'*) has write privilege in os level.
    Thanks in advance
    sbmk_design
    Edited by: sbmk_design on Aug 24, 2009 12:06 AM

  • Record .txt to oracle table

    I need moving records from .txt to oracle table. It is used in a System Oracle, then I can not use the utl_file or sql-loader. This moving will do step by step.

    funny, that you get that short error. I get:
    select * from test
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "nobadfile": expecting one of: "column, debug, exit, fields, records"
    KUP-01007: at line 1 column 1
    ORA-06512: at "SYS.ORACLE_LOADER", line 19
    ORA-06512: at line 1so, remove the unknown word "nobadfile", and it works fine. thank god that I have the verbose error handler!

  • Updating an oracle table with data from an xml string

    Hi - I need help with the following problem:
    We have a table in the database with a field of xml type. We are going to take each string that gets inserted into the xml type field in the 'xml table' and parse the data into another oracle table with corresponding fields for every element.
    once the record gets inserted into the 'real table' the user might want to update this record they will then insert another record into the 'xml table' indicating an update(with a flag) and then we need to update the 'real table' with the updated values that have been sent in.
    The problem that I am having is that I do not know how to create this update statement that will tell me which fields of the table need to be updated.(only the fields that need to be updated will be in the xml string in the 'xml table').
    Please help me with this - ASAP!

    Are you wanting to upload the file through an Oracle Form or just upload a file? If it isn't via forms, then you should probably post your question here: {forum:id=732}
    You also should post the version of Forms, Database, etc...
    As far as uploading files via a text file, I personally like to use Oracle External Tables even in Forms. You can Google that and there is plenty of information. If you search this forum, then you will see lots of people use UTL_FILE in forms, but you can Google that also for more information.

  • Convert oracle tables

    Hi,
    Is there any third party tool/source which will unload data from oracle tables into flat files? Iam talking few millions of records...
    thanks

    Hi,
    there are some possibilities. One is discussed in
    http://technet.oracle.com:89/ubb/Forum88/HTML/000862.html
    It is a sqlplus Script to produce the file.
    Another way is UTL_FILE from inside a PL/SQL Procedure
    Or use SQL Navigator from Quest http://www.quest.com . It works on my tables, but I don't have several million rows inside.
    HTH
    Detlev

  • Jython error while updating a oracle table based on file count

    Hi,
    i have jython procedure for counting counting records in a flat file
    Here is the code(took from odiexperts) modified and am getting errors, somebody take a look and let me know what is the sql exception in this code
    COMMAND on target: Jython
    Command on source : Oracle --and specified the logical schema
    Without connecting to the database using the jdbc connection i can see the output successfully, but i want to update the oracle table with count. any help is greatly appreciated
    ---------------------------------Error-----------------------------
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 45, in ?
    java.sql.SQLException: ORA-00936: missing expression
    ---------------------------------------Code--------------------------------------------------
    import java.sql.Connection
    import java.sql.Statement
    import java.sql.DriverManager
    import java.sql.ResultSet
    import java.sql.ResultSetMetaData
    import os
    import string
    import java.sql as sql
    import java.lang as lang
    import re
    filesrc = open('c:\mm\xyz.csv','r')
    first=filesrc.readline()
    lines = 0
    while first:
    #get the no of lines in the file
    lines += 1
    first=filesrc.readline()
    #print lines
    ## THE ABOVE PART OF THE PROGRAM IS TO COUNT THE NUMBER OF LINES
    ## AND STORE IT INTO THE VARIABLE `LINES `
    def intWithCommas(x):
    if type(x) not in [type(0), type(0L)]:
    raise TypeError("Parameter must be an integer.")
    if x < 0:
    return '-' + intWithCommas(-x)
    result = ''
    while x >= 1000:
    x, r = divmod(x, 1000)
    result = ",%03d%s" % (r, result)
    return "%d%s" % (x, result)
    ## THE ABOVE PROGRAM IS TO DISPLAY THE NUMBERS
    sourceConnection = odiRef.getJDBCConnection("SRC")
    sqlstring = sourceConnection.createStatement()
    sqlstmt="update tab1 set tot_coll_amt = to_number( "#lines ") where load_audit_key=418507"
    sqlstring.executeQuery(sqlstmt)
    sourceConnection.close()
    s0=' \n\nThe Number of Lines in the File are ->> '
    s1=str(intWithCommas(lines))
    s2=' \n\nand the First Line of the File is ->> '
    filesrc.seek(0)
    s3=str(filesrc.readline())
    final=s0 + s1 + s2 + s3
    filesrc.close()
    raise final

    i changed as you adviced ankit
    am getting the following error now
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 37, in ?
    java.sql.SQLException: ORA-00911: invalid character
    here is the modified code
    sourceConnection = odiRef.getJDBCConnection("SRC")
    sqlstring = sourceConnection.createStatement()
    sqlstmt="update tab1 set tot_coll_amt = to_number('#lines') where load_audit_key=418507;"
    result=sqlstring.executeUpdate(sqlstmt)
    sourceConnection.close()
    Any ideas
    Edited by: Sunny on Dec 3, 2010 1:04 PM

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

  • Insert /delete data from SAP Z table to Oracle table and opposite

    Hi,
    Can u help me write this FM from the SAP side?
    So, I have two tables ZTABLE in SAP and Oracle table ORAC.
    Let's put three columns in each of them, for example
    TEL1
    TEL2
    ADRESS
    NAME
    where TEL field is primary from ZTABLE to ORAC...
    (in FM there shoud be abap code for writing data in ZTABLE after we press some pushbutton made in sap screen painter..)
    for example, when we write new record in ZTABLE
    00
    112233
    Street 4
    Name1
    this data shoud be inserted in Oracle table ORAC.
    when we write new record in Oracle table for example
    01
    445566
    New Street
    Name2
    this data shoud be inserted in ZTABLE.
    Field TEL1 can be only of two values 01 or 02, other combination is not valid...
    I must have all data from Oracle table ORAC in ZTABLE and opposite.
    It should be the same scenario for DELETE...
    And this communication should be online between sap and table in oracle database...
    Can u help me from sap side? and give idea how to configure on oracle side??
    Thanks a lot,
    Nihad

    I dont know if we can directly connect to a oracle database ( wait for the answers from others on this )
    but in XI we have the JDBC adaptor to insert and retrieve data.
    so for the outbound from SAP the flow can be something like this (with XI in landscape):
    1) You have a screen to maintain a new entry / delete an entry
    2) On save , this record gets saved or deleted from the Ztable in SAP
    3)) In the same screen you can call a proxy class-method (generated using SPROXY transaction ) to send the record to XI.
    4) XI to format it and insert into the oracle table
    Mathews

Maybe you are looking for

  • Premier cc 2014, whole program lags when adding effects

    I have a problem that began after updating to cc 2014.   I work on projects that tend to have long complex multi  cam sequences (3 to 4 cameras) embedded into another sequence.  Premier pro handles it great no problems, until I try to color correct..

  • Suddenly very slow wifi access to App Store?

    A new problem just started for me last night: The speed of the App Store over wifi on both my iOS6 iPhone 5 and my wifi-only iOS5 iPad2 has dropped significantly.  An 8MB app takes several minutes to download over wifi.  On the phone, if I switch to

  • HANA- In Memory Computing

    Hi Experts, Does in India HANA implementation companies are there? Any HANA implementation happening? Because what i heard is that most of the HANA implemenation are in US, European, UK etc counries that too for only fortune 50 companies. Does in Ind

  • .csv file should not get insert sql query with report

    Hi Guys, the below sqlplus code giving both sql query and records report in csv format file. I want only records csv file report. SET LINESIZE 1000 TRIMSPOOL ON PAGESIZE 0 FEEDBACK OFF    SPOOL c:\oracle\extract\emp.csv    SELECT empno || ',' ||  ena

  • Files.copy java.nio.file.AccessDeniedException

    Hello everybody, I hope you are well, Me not. I use this method to unzip public void deziper(final Path zipFile, final Path destDir) throws IOException*           // On crée un FileSystem associé à l'archive :      try ( FileSystem zfs = FileSystems.