updated line and insert them into another table with trigger.

Hi guys I have a table that looks like this.
CREATE TABLE TEST
  (
    "COL1" VARCHAR2(20 BYTE),
    "COL2" VARCHAR2(20 BYTE),
    "COL3" VARCHAR2(20 BYTE)
  )
I'm going to insert the col1 and col2 values, but I need to get the value of column 3 of table 2 and then insert the complete record in table 3. I love doing that with a trigger. I get an error message and I can't for the life of me figuere out what im doing wrong.
So here is my nonfunctional trigger.


Here are the two table

CREATE TABLE TESTTABLE
  (
    "COLUMN1" NUMBER(15,0),
    "COLUMN2" NUMBER(15,0)
  )
 

Insert into TESTTABLE (COLUMN1,COLUMN2) values (1,5);
HERE IS THE CODE OF THE TRIGGER
CREATE OR REPLACE TRIGGER TRIGGER1 
AFTER INSERT ON TEST 
FOR EACH ROW 
BEGIN
  update TEST
  SET COL3 = (SELECT COLUMN2 FROM TEST, TESTTABLE WHERE COLUMN1 = :new.COL1);
END
I get an error of trigger mutation that I tried the other iterations of the above but I'm not getting anywhere. I have dumb down my problem at these 3 table.
Can someone point me in the right direction.

You'll have to do some reading, but it comes down to process the data on education instead of line level.
You may even be not at all a trigger.
See:
http://www.Oracle-base.com/articles/9i/mutating-table-exceptions.php
http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551198119097816936

Tags: Database

Similar Questions

  • Remove all lines and insert them into Oracle can make performance worse?

    I m working in a project that I need to make a batch update regularly (every 4 months) of excel files. These files have doesn´t excellent key in their ranks.

    The development of a code that deletes all lines and inserts the entire base again is easier than one who checks in all the ranks of its primary key and if necessary update. (sometimes may be a key to 5 columns).

    My question is: if I delete all the rows in the tables of the insert it again, it will cause tablespace fragmentation and in a future loss of performance?

    Is there a way to avoid this?

    Thanks in advance

    Alexander

    This response helped me a lot.

    Thank you all

    Remove all lines and insert them into Oracle can make performance worse? -Stack overflow

  • Gears - error when you try to insert values into a table with multiple columns

    Hello

    I started playing with the gears and SQlLite today and I get an error when I try to insert values into a table with multiple columns.

    I have:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text, DeveloperAge int)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?, ?)', [devName, devAge]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I get the error:

    net.rim.device.api.database.DatabaseException; insert into developers values (?,?): SQL logic error or missing database.

    I use this reference: http://code.google.com/apis/gears/api_database.html

    Everything works if I have only one field as:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?)', [devName]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I use the plug-in Visual Studio 2.0 for 2008 that are running Windows XP SP and Simulator 2.13.0.56

    Thank you

    Davy

    Yes, a SQLite database will persist between battery pulls.  The database is registered either to internal MEM or removable media (not the device memory), depending on which is available on your device.

    In general, its not considered a best practice to remove your table as soon as it is empty and re - create it again when you want to add data.  This adds extra overhead fresh for the final, delete and insert first for a given table.  Instead, define and finalize your drawing before you create your table.  Once created, review the static schema.

    That being said, for development purposes, it may be easier to provide an easy way to drop your tables while you develop your schema.

    See you soon,.

    Adam

  • Read the BLOB and insert data into a table

    Hi all

    Let us examine below on Oracle DB 12 c:

    create table xx_test3 (c blob);
    
    insert into xx_test3 (c) values (utl_raw.cast_to_raw(
    'azertyuiop,qsdfghjklm,wxcvbn'));
    
    
    create table xx_target (col1 varchar2(50));
    
    
    
    

    Can someone guide me how to read the data and insert it into the xx_target table?

    Necessary result is:

    
    select * from xx_target;
    
    
    COL1                                              
    
    --------------------------------------------------
    azertyuiop                                        
    qsdfghjklm                                        
    wxcvbn                                            
    
    3 rows selected.
    
    
    
    
    

    Thanks in advance,

    Stoyanov.

    insert into xx_target (col1)

    with the data as)

    Select utl_raw.cast_to_varchar2 (dbms_lob.substr (c, 32000, 1)) CBC

    of xx_test3

    )

    Select regexp_substr (CBC, ' [^,] +', 1, level)

    from the data

    connect by level<= regexp_count(src,="" ',')="" +="">

  • Insert data into another database with a script

    Hello.

    What is the best way to insert data into one database with a script

    INSERT INTO BF_PRUEBASMTP.bf_mtp_agr_inscription (ain_agreementid, ain_customerid, ain_paymethodsid, ain_servicemoduleid, referencia)

    SELECT AAG. AAG_AGREEMENTID, ACU. ACU_CUSTOMERID, 2, 2, ins. NUMERO_REFERENCIA

    OF BF_PRUEBASMTP.bf_mtp_agr_biller ABI

    JOIN IN-HOUSE

    BF_PRUEBASMTP. BF_MTP_AGR_AGREEMENT AAG ON ABI. ABI_BILLERID = AAG. AAG_BILLERID

    INNER JOIN 'CLIENTEUNICO. ALMUERZO" ins

    ON THE AAG. AAG_AGREEMENTID = ins. CONVENIOID

    INNER JOIN BF_PRUEBASMTP.bf_mtp_agr_customer ACU

    ON ACU.acu_typedocumentid = ins. TIPO_DOCUMENTO

    AND ACU.acu_numberid = ins. NUMERO_DOCUMENTO;

    CLIENTEUNICO. INSCRIPCIONES = SELECT * DE INSCRIPCIONES - to a DIFFERENT DATABASE


    Thank you very much.

    2931095 wrote:

    If I don't have permissions to create a database link. Is there another way to do this?

    Thank you.

    link to database IS the method by which an Oracle database accesses to a different database.

    If you are the ADMINISTRATOR, you should have permission.

    If you are not the ADMINISTRATOR, you should not have permission and need to talk to the ADMINISTRATOR that is allowed.

  • get the name of a directory file and insert it into a table

    Hello

    I have a requirement, I need to read the name of a Linux directory file and enter the file name in a variable,

    After that, I need to insert this file name in a table.

    EX: is it a file1.txt in Yearbook of the CBA, and I read that 'file name' in the v_file_name variable and I'm going to insert this file name in a table.

    Hello

    I think you've got your request of replied by Chantal.
    Shoul you have a kind of intelience in the name of the file itself so that ODI retrieves the correct file and insert into the table.

    Thank you
    Fati

  • How can I program a button to retrieve an image from a user base and insert them into a form field?

    I need help (I have not the slightest idea) with a java script to program a button to retrieve an image from a user base and insert into a form field. To go to the menu select icon.

    [edited by moderator - he had no body to the post office and it was while heading a long title.] [Shorten the title and pasted the original title, plenty of length as the message body]

    Okay, that's actually quite easily. As the l' evenement event MouseUp button, select "Execute JavaScript" and enter this code:

    event.target.buttonImportIcon ();

    When you click the button it will open a file selection dialog and the selected file is displayed under the icon of the button.

  • Can I copy the list of names of files and paste them into a table

    I have a list of files in a folder and here paste the titles only in a table

    You can create a list of text files by using the command prompt.

    • Open a command prompt in the folder that you want to get the list of. (You can open a command prompt and navigate to your required file, or use the Solution Explorer and press and right click on your file at the same time. Then you should see "open a command here window' in the menu - click on it.)
    • Enter the command "dir /b > filenames.txt" (without the quotes), then simply type dir /b > filenames.txtand press return/enter to transport.
    • Use Explorer to navigate to your file and you should now see a text file called filenames.txt. Open and it must contain a list of files. Then, copy and paste the list where you want to.

    If all goes well, I understood your question correctly, if so, hope it helps.




  • New items - save the cut and paste them into another image.

    I'm new to photoshop.  I am trying to record an image that I could 'cutting' a photo, so I want to paste this image on a different photo.  I learn about layers (slowly...) and I've seen several tutorials.  What I have seen/heard makes it look simple, but I'm missing something.  Worked on it for several nights with no luck.  Using Photoshop Elements 11.   Appreciate the comments, the links, the ets.  Thanks in advance.

    Once you have the choice of loan on the first image,

    Use the move tool (see the below screen shot for the moov tool), and then drag the selection to the first image on the secondary image tab.

    As soon as you place the cursor on the second image the second image tab will open and now you can place the cutting on the second image.

    It will automatically create the layer for you.

    -Thomas yannick

  • How to read a column of ASCII numbers and merge them into a file with 0-360 degrees for a polar route?

    I have a file saved with 8 columns of numbers ASCII.  I want to format it so that the entrance of the polar plot will accept it.  The polar plot expects an array 1 d of amplitude AND phase.  Is that mean two numbers with a comma separation?  I can't make it work.

    Ronster,

    There is a good example of use of the Polar curve. Open the example finder and search for Polar. The name of the vi is polar Plot Demo. You should be able to adapt to meet your needs. What kind of file saves these recorded temperatures in? You can try using the worksheet file.vi reading? You must obtain a separate column (table) of the double to power the Demo.vi. What version of LabVIEW are you using? You can download the file or is it too big? What did you use to write the file when you had the time?

  • inserting data into the table

    Hi all
    I use forms [32 bit] Version 6.0.8.24.1 (Production)
    Oracle Database 10g Release 10.2.0.1.0 - Production
    I have settings such as the (optional) emp_code and the year (mandatory field - four digits).
    Based on the setting that I have to get the detail of a table and these must be inserted at the other table with columns of additions (to hardcode the additional columns).
    To achieve this, I intend to get a cursor by selecting the required fields in the table by the way the where clause of the cursor parameters.
    by making a loop through the cursor I will insert the records in the other table.
    Here, the thing is that the data is going to be huge (since the year is the parameter).
    so my approach causes the performance issue.
    I heard that there is a different method of insetions
    can anyone suggest me the best way (performance wise) other than what I mentioned (if you are aware of)...

    Thank you...

    user13329002 wrote:
    Thanks for everyone.
    I have to take the data from the table as e_name, e_code, of the table and insert it into another table with some other values such as
    e_name, e_code, as well as I add 'n', 'o'.
    its something like

    insert into e_emp(emp_name,emp_code,emp_add,emp_status,emp_type)
    select e_name,e_code,e_add,'O','N')
    from e_table
    where e_date = Parameter.
    

    in other words, the values for Emp_status, emp_type I have no values in the e_table.so table and enter in e_table I have to hard code it.
    CAL I hard code as I mentioned in my statement example

    can someone clear me of the foregoing.

    Thank you...

    Published by: user13329002 on February 15, 2011 20:11

    Yes... You can hardcode the values for Emp_status, emp_type.

    SQL> CREATE TABLE e_emp(emp_code NUMBER(10),emp_status VARCHAR2(1),emp_type VARCHAR2(1));
    
    Table created.
    
    SQL> create table e_table as (select * from e_emp);
    
    Table created.
    
    SQL> INSERT INTO e_table(emp_code) VALUES('1111');
    
    1 row created.
    
    SQL> insert into e_table(emp_code) values('2222');
    
    1 row created.
    
    SQL> select * from e_table;
    
      EMP_CODE E E
    ---------- - -
          1111
          2222
    
    SQL> insert into e_emp(emp_code,emp_status,emp_type) (select emp_code,'0','N' from e_table);
    
    2 rows created.
    
    SQL> select * from e_emp;
    
      EMP_CODE E E
    ---------- - -
          1111 0 N
          2222 0 N
    
    SQL> 
    

    I hope this helps.

    Kind regards
    Claudy

  • Get the date value. MinValue and insert it into the DB

    Hello

    I'm developing an adf application using jdev11g.

    I need to recover the 3 values of page jsf (inputText 2 + 1 date. MinValue) and insert them into DB

    so I create a method in appModuleImpl:

    {public createAffAgVehNewRow (Date date, around km, veh Integer) Sub

    Get the id of the current user

    String ag = ADFContext.getCurrent () .getSessionScope ().get("idAg").toString ();

    getSequenceNumber

    oracle.jbo.domain.Number seq = new oracle.jbo.domain.Number (0);

    SequenceImpl seqImpl = new SequenceImpl ("AFF_AV_SEQ", getDBTransaction());

    SEQ = seqImpl.getSequenceNumber ();

    Insert values into the DB table

    Line r = getAffAgVehView1 () .createRow ();

    ViewObjectImpl vo = this.getAffAgVehView1 ();

    r.setAttribute ("IdAg", Integer.parseInt (ag.toString ()) ");

    r.setAttribute ("IdAffAv", seq);

    r.setAttribute ("KmDep", km);

    r.setAttribute ("IdVeh", veh);

    r.setAttribute ("DateAff", date);

    r.setAttribute ("KmArriv", null);

    r.setAttribute ("ConsoCarb", null);

    vo.insertRow (r);

    this.getDBTransaction () .commit ();

    }

    also, I changed the default value of the EO (AffAgVeh) to adf.currentDate () and the user interface as simpleDate format: "MM/DD/YYYY.

    the problem as whene I enter 3 inputValues and click on the button I get this message:

    Timestamp format must be yyyy-mm-dd hh: mm: [.fffffffff]

    someone knows how to solve this problem

    Thank you

    Mark

    Hi Dev

    Please pass.

    java.sql.SQLException: column type invalid in the adf

    Thank you

    Subramanian M

  • Reading file from the ftp server and importing data into the table

    Hi experts,

    Well, basically, I text with different layout files have been uploaded to an ftp server. Now, I must write a procedure to recover these files, read and insert data into a table... what to do?

    your help would be greatly helpful.

    Thank you

    user9004152 wrote:
    http://it.Toolbox.com/wiki/index.php/Load_data_from_a_flat_file_into_an_Oracle_table

    See the link, hope it will work.

    It is an old method, using the utl_file_dir parameter that is now obsolete and which is frankly a waste of space when external tables can do exactly the same thing much more easily.

  • How to insert data into the table of plain text stored as a CLOB in another table

    Hi people,

    Maybe it's an easy question for someone who is more frequently used files and CLOB.

    I have a table that stores text files in the CLOB column. Files text includes some basic data that I want to load in the other - a text line = a new insert for me. Is there a "trick" how to do it effectively?

    Here is my model:

    Table OS_IMPORT_DOCS, stores the complete files as CLOB
    SQL> desc OS_IMPORT_DOCS
    Name          Type           Nullable Default Comments 
    ------------- -------------- -------- ------- -------- 
    OBJECT_ID     NUMBER                                   
    DATUM_ZMENY   DATE                    sysdate          
    FILE_PATH     VARCHAR2(4000) Y                         
    FILE_NAME     VARCHAR2(4000) Y                         
    FILE_SIZE     NUMBER         Y                         
    LAST_MODIFIED DATE           Y                         
    DOCUMENT      CLOB           Y                         
    STATUS        VARCHAR2(15)   Y        'NEW'  
    Sample data from OS_IMPORT_DOCS
    SQL> select *
      2    from os_import_docs d
      3  order by d.last_modified desc
      4  ;
     
     OBJECT_ID DATUM_ZMENY FILE_PATH                      FILE_NAME       FILE_SIZE  LAST_MODIFIED DOCUMENT    STATUS
    ---------- ----------- ------------------------------ --------------- ---------- ------------- ----------- ---------------
       1815043 13.8.2012 1 d:\data\C120813.DAT            C120813.DAT          16800 13.8.2012 16: <<CLOB>>    NEW
       1815042 13.8.2012 1 d:\data\C120812.DAT            C120812.DAT           3600 12.8.2012 22: <<CLOB>>    NEW
       1815041 13.8.2012 1 d:\data\C120811.DAT            C120811.DAT           1800 11.8.2012 13: <<CLOB>>    NEW
    Example of file CLOB - stored text data (select d.document from os_import_docs d where d.object_id = 1815042 ;)
    061053120820120000AGT000002Osoby                   0000000042301000000017210632
    062322120820120000AGT000002Osoby                   0000000012301000000017197566
    063526120820120001AGT000002Osoby                   0000000012301000000017197566
    064234120820120001AGT000002Osoby                   0000000103301000000162218777
    Above the example text includes "columns" in plain text:
    timestamp - 1-14, SSMIHH24DDMMYYYY position format
    flag - post 15-18
    company code - position 19-27
    etc...

    How can I query data stored within the OS_IMPORT_DOCS. The DOCUMENT column, divide it into columns and insert into another table?
    I have to read this method of 'online' file?


    Thank you very much
    Tomas

    For the first three columns:

    SQL> create type TRecord is object (
      2    ts           timestamp
      3  , flag         varchar2(4)
      4  , company_code varchar2(9)
      5  );
      6  /
    
    Type created
    
    SQL>
    SQL> create type TRecordTable is table of TRecord;
      2  /
    
    Type created
    
    SQL>
    SQL> create or replace function parse_clob (p_doc in clob)
      2  return TRecordTable pipelined
      3  is
      4    lf      number;
      5    eol     varchar2(2) := chr(10);
      6    eollen  number := length(eol);
      7    line    varchar2(32767);
      8    offs    number := 1;
      9  begin
     10    loop
     11      lf := dbms_lob.instr(p_doc, eol, offs);
     12      if lf != 0 then
     13        line := dbms_lob.substr(p_doc, lf - offs + 1 - eollen, offs);
     14        offs := lf + eollen;
     15      else
     16        line := dbms_lob.substr(p_doc, dbms_lob.getlength(p_doc) - offs + 1, offs);
     17      end if;
     18      pipe row (
     19        TRecord(
     20          to_timestamp(substr(line, 1, 14), 'HH24MISSDDMMYYYY')
     21        , substr(line, 15, 4)
     22        , substr(line, 19, 9)
     23        )
     24      );
     25      exit when lf = 0;
     26    end loop;
     27  end;
     28  /
    
    Function created
    
    SQL>
    SQL> select t.*
      2  from os_import_docs d
      3     , table(parse_clob(d.document)) t
      4  where d.object_id = 1815042;
    
    TS                                     FLAG COMPANY_CODE
    -------------------------------------- ---- ------------
    12/08/12 06:10:53,000000               0000 AGT000002
    12/08/12 06:23:22,000000               0000 AGT000002
    12/08/12 06:35:26,000000               0001 AGT000002
    12/08/12 06:42:34,000000               0001 AGT000002
     
    
  • How can I insert data from another table into a table containing a timestamp column

    How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.


    I use MS SQL

    Sorry, I managed to get around this by inserting null as the value

Maybe you are looking for