Add new data to the table in a log file

Hi all. I am new to Oracle and I need to also write new data table in a logfile on Linux in order to live in the display screen. My first thought was to write a trigger, and after some research on googled around, I finally came to this:

create or replace trigger foo_insert
After Insert on foo
for each line
declare
f utl_file.file_type;
s VARCHAR2 (255);
Start
s: =: new.udate | '-' || : new.time | ' ' || : new.foo | ' ' || : new.bar | ' ' || : new.xyzzy | ' ' || : new.frobozz | ' ' || : new.quux | ' ' || : new.wombat;
f: = utl_file.fopen ('BLAH_BLAH', 'current.log', ' a');
UTL_FILE.put_line (f, s);
UTL_FILE.fclose (f);
end foo_insert;

It seems properly to add new data in the log file as new inserts occur, but open and close the file each time are of course not optimal.
In the app real new lines could have inserted every second or two. How can I optimize it? In addition, the log file will be archived and turned every day, so there must be a way to effectively report the relaxation of the oracle to reopen the case.


Thank you!

>
I would like to pursue the optimization of the trigger
>
As Ed suggested you need to think this through a few others and refine the requirements.

You said "I am new to Oracle. So you may not realize that anything a trigger didn't REALLY EVEN HAPPEN! The transaction can still be restored by Oracle or by the appellant. Want that all the 'hiccups' look too? If this isn't the case, then you can not use a trigger to do this. You need the process that translates the trigger being called to do logging after the data is stored.

It should be noted that this requirement is before we can offer solutions to a problem.

Assuming you want the trigger record all attempts change the data, then the best way I know to do that is to minimize the work does the trigger.
Another fundamental principle is to follow the advice of the Ed and have a clear separation and distinction between "what" should be done and 'how' to do it.

To minimize the trigger work change proposed Nicosa approach. Create an AUTONOMOUS_TRANSACTION stored procedure that handles the 'how' and just have the trigger to transfer data to the stored procedure values. The trigger provides data; He doesn't know, or care, what is done with the data.

The stored procedure is then free to use the files, a table, write to a file or any other method is proving to be the best. You can change the methods without affecting the trigger.

A queue or table may contain data, but again once you need to think about the obligation. Do you need fair access to data only once? Now, you want a "tail". But what happens if this requirement change tomorrow? You won't have to redesign the architecture.

With a queue once you delete the queue data it won't here later if you want to get it again. With a table you can take as long as you want.

I would like to start by using a table to store the data. If you use a sequence number or "insert_date" value, you can always query the data of interest. The table just collects data. He does not care how to use data.

So, by using proven design principles and knowing that the requirements are for the most part unknown and may change unexpectedly, I would be:

1. create an AUTONOMOUS_TRANSACTION stored procedure that accepts the parameter data and the thicket in a simple logging table.
2. change your trigger to call the procedure to step #1
3. create another procedure that performs a query of 'tail' for you will depend on 'insert_date' number or sequence. This query can write data to a file or return a cursor ref that your script can use to provide data for display.

The approach described above takes each step in the process relatively independent of the other stages.

Until put you the finishing touches to the requirements that you do not want to lock up your initial design.

Tags: Database

Similar Questions

  • Add new records to the table of the ADF

    Hello

    I use Jdev 11.1.1.3.0.
    I have a Page of the ADF with detail Table of form - master, I want to add new records to the table reflecting in DB. Is it possible to do? pointers or demo?


    Thank you
    MB

    What are the components are used in your table? When you created the table originally, you specified as a table read-only? If your table contains components of af: outputText, then you will need either manually change components entry way, or remove the table and re-drop-the-in the form of table (not read-only)

    John

  • adding new data in the table property variant

    Hello guy,

    I have a Qml property

    property variant placeName:[]
    

    I would now like to add data in this property at run time.

    I checked this link:

    http://Qt-project.org/doc/Qt-4.8/QML-Variant.html

    but there, I found that we can "Update" the property data.

    What to add new data?

    Please help me as soon as possible...

    property real estate to qml aren't real javascript arrays, so to mutate them you need a reallocation.
    as
    var tmp = placeName;
    tmp.push (a);
    placeName = tmp;

  • Is it possible to see/get the data from the table to a dump file

    I have files dmp generated using expdp on oracle 11 g...

    expdp_schemas_18MAY2013_1.dmp

    expdp_schemas_18MAY2013_2.dmp

    expdp_schemas_18MAY2013_3.dmp

    Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.

    VI test1.par

    USERID = "/ as sysdba".

    DIRECTORY = DATA

    dumpfile=expdp_schemas_18MAY2013%S.dmp

    SCHEMAS = USER1, USER2

    LOGFILE = user_dump_data.log

    SQLFILE = user_dump_data. SQL

    and impdp parfile = test1.par.

    No,

    DataPump cannot retrieve a dumpfile data in a flat file.

    Dean

  • Insert and add data to the table to a batch file

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE Production 11.1.0.7.0
    AMT for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production


    My patch to input file looks like this:

    A0397990002000001
    A0459380377000075
    A1291115796000002
    C0483110026000080
    D0491114923000004
    A0348400660000000
    G0209111373-

    Separate columns look like this:

    A0397 990002 000001

    account amount of IDN


    I'm new to PL/SQL and having a problem changing or adding a record in a table. Don't know how to check if a record exists in the table change if not
    Insert the record.

    If the quantity is 000000 or - the record should be deleted. I have code in place to do this however, don't know how to handle change or add the part.

    Here is the code I have so far and thanks for looking:

    Set serveroutput on
    create or replace directory user_dir as 'c:\dataformats\incoming\ ';


    DECLARE


    v_filename VARCHAR2 (100); -The name of the data file
    v_file_exists boolean;
    number of v_file_length;
    number of v_block_size;
    f utl_file.file_type;
    s varchar2 (200);
    lineString varchar (200);

    -not used c_ *.
    c_account ID_REQ_STG.account%TYPE;
    c_IDN ID_REQ_STG. IDN % TYPE;
    c_quantity ID_REQ_STG.quantity%TYPE;

    ID_REQ_TUPLE ID_REQ_STG % ROWTYPE;

    v_account varchar (5);
    v_IDN varchar (6);
    V_quantity varchar (6);

    BEGIN
    v_filename: = ' PTCLICK. MANUAL.12SERIES.TXT';


    DBMS_OUTPUT. Put_line (v_filename); -the name of the file


    UTL_FILE.fgetattr ("USER_DIR", v_filename, v_file_exists, v_file_length, v_block_size);

    IF v_file_exists THEN

    dbms_output.put_line ("'File Exists");

    f: = utl_file.fopen ("USER_DIR", v_filename, "R");

    IF utl_file.is_open (f) THEN

    LOOP
    BEGIN
    UTL_FILE.get_line (f, s);
    lineString: = s;

    dbms_output.put_line (lineString);

    v_account: = substr (lineString, 1, 5);
    v_IDN: = substr (lineString, 6, 6);
    V_quantity: = substr (lineString, 12.6);


    dbms_output.put_line (v_account);
    dbms_output.put_line (v_IDN);
    dbms_output.put_line (V_quantity);

    -REMOVE

    IF v_quantity = '000000' GOLD v_quantity = '-'
    THEN
    REMOVE FROM ID_REQ_STG
    WHERE account = v_account and
    IDN = v_IDN;
    commit;
    dbms_output.put_line ('Deleted the folder' | v_account |) «and» | v_IDN);
    END IF;


    -CHANGE



    -ADD



    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    dbms_output.put_line ("' no data found");
    EXIT;
    END;

    END LOOP;

    END IF; -is open

    UTL_FILE.fclose (f);


    ON THE OTHER

    dbms_output.put_line ('file does not exist');

    END IF; -file exists

    EXCEPTION

    WHEN UTL_FILE. THEN ACCESS_DENIED
    DBMS_OUTPUT. Put_line ("' no access!");
    WHEN UTL_FILE. INVALID_PATH THEN
    DBMS_OUTPUT. PUT_LINE ('PATH DOES NOT EXIST');
    WHILE others THEN
    DBMS_OUTPUT. PUT_LINE ("SQLERRM: ' |") SQLERRM);



    END;
    /

    Hello

    Looks like a good candidate for a MERGER with an external table.

    The external table:

    create table ext_table (
     account varchar2(5),
     idn number(6),
     quantity varchar2(6)
    )
    organization external (
      type oracle_loader
      default directory user_dir
      access parameters (
        records delimited by newline
        fields (
          account position(1:5) char(5),
          idn position(6:11) char(6),
          quantity position(12:17) char(6)
        )
      )
      location ('test.txt')
    )
    reject limit unlimited;
    

    Then a simple MERGER should perform all your needs:

    MERGE INTO id_req_stg t
    USING (
     SELECT account,
            idn,
            decode(quantity, '-', 0, to_number(quantity)) as quantity
     FROM ext_table
    ) v
    ON ( t.account = v.account AND t.idn = v.idn )
    WHEN MATCHED THEN
      UPDATE SET t.quantity = v.quantity
      DELETE WHERE t.quantity = 0
    WHEN NOT MATCHED THEN
      INSERT (account, idn, quantity)
      VALUES (v.account, v.idn, v.quantity);
    

    Documentation related to the MERGER: http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_9016.htm#SQLRF01606
    and on the outdoor tables: http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/tables013.htm#ADMIN12896

    Published by: odie_63 on June 10, 2010 14:26 (added docs)

  • Whenever I call a VI I get old data with new data in the table

    I selected 'clear indicators when it is called' in my properties VI, execution. Yet, whenever I call the VI, the table of data is growing. My main VI implements my USE, and then call the sub - VI, which sets up an instrument measurements, then reads the results and transmits data. I then change the UUT to the next State and repeat the same task sub - VI to get again the same measures. The main VI changes the mode of WEAR it three times, so call the sub - VI three times. The last call of the Subvi back all three sets of data together, which is OK. My problem is, when the main VI ends and I run another USE, I get the new set of data as well as the complete list of data from the previous run. I found a similar problem answered here on the forum who suggested I should 'clear indicators when it is called', and so I did. It still has not fixed my problem. Any idea?

    Try this, for example:

  • Add new records to the table while ESX online

    Hello

    I want to add some new drives in a RAID 5 Array existing VMFS-store of data running on my Fibre Channel SAN, on which there is already a logic unit number.

    Can I add these discs with no problems so my 2 ESX hosts are online, and access to the existing database

    Objective final is to inreasing the size of the array by creating another logic unit number with the freespace added and then creating a new data store

    Thanks in advance,

    Alessandro

    It depends on your San. If that supports the extension line of a RAID set, you'll have no problems. But you need to enlarge the VMFS data store later. As far as I know, this is not possible with ESX 3.5. As single VMFS partition is allowed per LUN think about presenting the new disk as a new LUN space.

    You can add this new LUN as an extension to the VMFS data existing store to get this one expanded.

    Another solution would be to remove all the guests of the existing VMFS (if you Storage VMotion which can be done online), destroy that one and create a larger on the expanded LUN.

    AWo

    VCP 3 & 4

    \[:o]===\[o:]

    = You want to have this ad as a ringtone on your mobile phone? =

    = Send 'Assignment' to 911 for only $999999,99! =

  • Add new data to the NAS or USB store

    Hi guys

    My ESXi 3.5 U4 on space is insufficient and we can afford new hard disks at the moment... we have a NAS with XFS file system, it also includes a USB port for external drives that we want to make our shop seconadry for virtual machines.

    I tried to add a NAS share on the Infrastructure Client using NFS, but it keeps failing, see "fails.jpg". Is this because its not formatted with NFS filesystem? If so, how do I format a disk in a format compatible NFS or NFS?

    Please notify

    Thank you very much

    Buffalo does not support NFS. Missing services. A lot of the small devics NAS used to support the NFS. Iomega storecenter peripheral support NFS, are in the HCL and pretty good markets. I have one for the storage of ISO and a virtual machine. Works very well and I think it was $100.

  • How to add data to the table using Manager POST for restful Apex application

    Hi all

    I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.

    Source for the POST Manager:

    Start

    insert into ALL_BOOKS values(:id,:book);

    end;

    Also created 2 parameters id and the book.

    Hi jerry2134,

    jerry2134 wrote:

    I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.

    Source for the POST Manager:

    Start

    insert into ALL_BOOKS values(:id,:book);

    end;

    Also created 2 parameters id and the book.

    Check out the following tutorials OBE, that explains the creation of GET and POST RESTful Web Services and how to use them in the APEX.

    Also what yo mean "looking forward on how to proceed? Do you want to or created for use/consume in your Oracle APEX application hosted RESTful web services?

    If Yes, in your Application, you must create a RESTful Web Service reference -> shared components. Then, create a form/report based on Web Service reference.

    Kind regards

    Kiran

  • How to add data to the table changed in sql developer at Apex and vice versa

    Hello

    I had tables of database with sql developer. But now, I have modified the database (new tables added + changed the data in the tables). However, in the Apex, I the old database. Is it possible to get the new Apex database with the data of the table changed so this database in both places (sql and apex developer) is exactly the same... Also the other way around.

    Thank you

    The database schema that contains the tables, is it associated with the workspace even you are searching through the APEX product t development?  Why I'm asking is, if they are the same schema, the tables that you MODIFIED should be appear in the sql for APEX workshop part.  Now reports and forms will NOT see the changes (unless you have actually added or updated definitions for column).

    Can you explain what exactly you were doing the SQL Developer to the tables in your schema?

    Thank you

    Tony Miller
    Los Alamos, NM

  • Unable to add a new column to the table of the LCD? Option, just usually add it.

    I have a form of LCD with a table in it. Im trying to simply add a new column to the table. The option is there, but the column appear just after clicking Add the column to the left. I selected a column, right click the space > insert > column to the left. But the habit intsert. The object table properties tab shows lines and colum numbers, but they are grey.

    See screenshots:

    http://www.emermed.NET/staging/forums...

    http://www.emermed.NET/staging/forums...

    It is a dynamic array, where a new line can be inserted using a button. Is that the dynamic nature of the question? ID hate to cancel all the flow dynamics and programming just to add a column, and then reapply them all.

    Thank you!

    Hello

    You do not add the columns in the object > palette (screenshot 2) of the Table. I suspect that the problem is that it is not enough on the page (in the content area) to add the column. In the screenshot 1, if you look at the width of the column highlighted from the space to the right of the table, you will see that a column can be added due to restrictions of space.

    Reduce the width of the column highlighted (temporarily), and then add a column. Once added, you can resize the columns to match the width of the page.

    Hope that helps,

    Niall

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • Add a column in the Table lead RN

    Hello

    In a standard page, there is a searchRN, and on this basis, the data from the table ahead are met. I want to add another column of this table in advance. The original Version has the required column, so I just map the attribute and the instance.

    If she wasn't a table in advance, I would have, but for table in advance, it looks different. Any approach step by step would be really useful.

    Appl Version: 12.1.3

    Thank you

    Region of table in advance, create a new item. Type of item would be the column.
    create 2 new items under the newly added column. 1 is the column header and a second would be messagestyledtext.

    Kind regards
    RAM

  • Add / remove rows from the Table

    Hello

    I'm really new to LiveCycle ES 8.2 (= non-existent knowledge of JavaScript) and has difficulties to create a table that can add / remove lines.

    I found a model that has the feature I need, but am unable to reproduce the table. (Ref. "Fax Cover Sheet_SW.pdf' http://forums.adobe.com/message/2561553#2561553)

    Even when I create a new blank form, and then copy / paste the table (subforms: 'detailHeader' + "detal") in the new, blank forms, the table stops working. The buttons are more clickable in the LiveCycle 'Preview PDF'

    In the new, blank forms, the 'Paging' and 'Binding' tabs have some or all of their features grayed out.

    I tried the following:

    1. Save the form as an "Adobe Dynamic form XML (pdf)"
    2. Make sure all of the 'content' subform fields were set to "Position" instead of "Flowed".

    What am I missing, like all JavaScript copied on, but for some reason any does not work.

    4 things you need to correct your form...

    (1) Page1 subform needs tobe Flowed the value.

    (2) then the link to the Subform1 tab will be active. You must check the box "subform to repeat for each item of data.

    (3) in the Add button to Subform1 you missed 'instanceManager' in the code...

    Subform1.instanceManager.addInstance (1);

    (4) in the same way in the button Delete

    Subform1. instanceManager. removeInstance (this.parent.index);

    Thank you

    Srini

  • Add new columns to iExpense Table of Adv. finished Non-Employee Information

    I have a requirement where in I need to add three columns to the table in iExpense DetailsPG at the table of the advanced non-employee information (GuestTableRN). I was able to add three areas through customization (I know that this can be done by extending the CO, but tried through customization)

    If there was DFFs, it would have been easy, but there is no DFFs.

    I created a table with the columns attendee_line_id and report_line_id that are also in the oie_attendees_all table. Then next created the necessary business components, first OS based on the table custom and then expanded the VO on the page, ExpAttendeesVO and also added the custom to the VO EO.

    I put the code in the java VoImpl extended to insert or delete lines and moved these files on the server, insert data into the table manually. The data is displayed in the three new Non-employee table columns. I was able to update the existing data on the details page. But I can't do an insert or delete it from the page.

    I need suggestions on how to address this issue.

    Thank you
    Kishore

    Hi Kishore,

    You cannot update two tables using an EO (even if you extended it). What I propose is to write PLSQL API and call that could insert data into your custom table. Another option is to write a trigger on your table planted (on insert) and check for certain key conditions based on which you can insert data into your custom table.

    Concerning
    Sumit

Maybe you are looking for