Trigger for two related tables

Hello

I have two tables, one i keep the general areas and the other table keep several rates per year related to the first table of field general_id (one to many relationship)

create table (general)

number of general_id

general_type varchar2 (10),

Description varchar2 (250).

Notes varchar2 (250).

State number,

date of date_de_modification,

'PK_GENERAL' CONSTRAINT PRIMARY KEY (general_id)

);

Insert in general (general_id, general_type, description, notes, status, date_modified)

values (1, "gen rate", 'Test Desc', 'New folder', 0, sysdate);

create table rates)

number of general_id

number of rate_id,

Number of exercise,

number of amount,

date of date_de_modification,

"PK_RATES" PRIMARY KEY CONSTRAINT (rate_id)

);

Insert rates (general_id, rate_id, fy, amount, date_modified)

values (1, 1, 2012, 10, sysdate);

Insert rates (general_id, rate_id, fy, amount, date_modified)

values (1, 1, 2013, 20, sysdate);

Insert rates (general_id, rate_id, fy, amount, date_modified)

values (1, 1, 2014, 30, sysdate);

How can I create a trigger when any amount is updated in the rate table? Don't need to save anything when insert or remove.

I wish I had a history table that I can save some old values from the general and charts of rates such as:

create table hst_rates)

number of general_id

Note varchar2 (250),-THE GENERAL TABLE

State number,-THE GENERAL TABLE

number of rate_id,

Number of exercise,

number of amount,

date of date_de_modification,

hst_action

);

can I do this?

OR I can create tables of history for each table. But I have to do a join query to show history.

How can I have a unique identifier between then?

Make sense? Any ideas?

Thanks in advance.

Why do you not use sum? What happens if the amount is changed several times, do not end up with a bigger number? I think that max (...) Dungeon (dense_rank last date_modified) would be a better choice.

The unchanged records, you can the union with the rate table before spinning.

Tags: Database

Similar Questions

  • Insert records from a single to two related tables table

    DB - 10G
    OS - XP

    We have thousands of records delimited by commas that we want to insert in a normalized table structure.

    I created a group of test data that can be found at the end of this post.


    I have csv files that look like this;

    Donald, huey
    Dewey, Donald
    Donald, louie

    And I want that data to be inserted into a table separate two like that;

    table named PARENTS
    parent_name PK
    1 donald

    Table named for CHILDREN
    child_name fk PK
    1 1 huey
    1 2 dewey
    1 3 louie


    I built an insert query that looks like this;

    INSERT ALL
    IN parents (parent_id, parent_name) VALUES (parents_seq.nextval, parent_name)
    IN children (children_id, parent_id, child_name) VALUES (children_seq.nextval, parents_seq.nextval, child_name)
    SELECT parent_name, child_name
    SOURCES;

    And this has resulted in the following:

    Table named PARENTS
    PK child_name
    1 DONALD
    2 DONALD
    3 DONALD

    Table named PARENTS
    child_name fk PK
    1 1 HUEY
    2 2 DEWEY
    3 3 LOUIE

    Anyone have any ideas on how I could accomplish this task?

    This is some sample data;

    [code]
    Parents_seq SEQUENCE DROP;
    Sources_seq SEQUENCE DROP;
    Children_seq SEQUENCE DROP;
    Sources of DROP TABLE.
    DROP TABLE children;
    Parents of DROP TABLE;

    CREATE SEQUENCE PARENTS_SEQ MINVALUE MAXVALUE 1 1000000000000000000000000000 INCREMENT OF 1 START WITH 1 CACHE 20 ALL NOCYCLE.

    CREATE THE PARENTS TABLE
    (THE NUMBER (8) OF PARENT_ID NOT NULL)
    PARENT_NAME VARCHAR2 (50 CHAR) NOT NULL,
    CONSTRAINT PARENTS_PK PRIMARY KEY (PARENT_ID)
    );

    create or replace
    PARENTS_BI RELAXATION
    FRONT
    INSERT OR UPDATE PARENTS
    FOR EACH START OF LINE

    IF THE INSERTION

    IF: NEW. PARENT_ID IS NULL THEN
    SELECT PARENTS_SEQ.nextval IN: NEW. PARENT_ID FROM dual;
    END IF;

    END IF;

    END;
    /


    CREATE SEQUENCE SOURCES_SEQ MINVALUE MAXVALUE 1 1000000000000000000000000000 INCREMENT OF 1 START WITH 1 CACHE 20 ALL NOCYCLE.

    CREATE TABLE SOURCES
    (THE NUMBER (8) OF SOURCE_ID NOT NULL)
    PARENT_NAME VARCHAR2 (50 CHAR) NOT NULL,
    CHILD_NAME VARCHAR2 (50 CHAR) NOT NULL,
    CONSTRAINT SOURCES_PK PRIMARY KEY (SOURCE_ID)
    );

    create or replace
    SOURCES_BI RELAXATION
    FRONT
    INSERT OR UPDATE ON SOURCES
    FOR EACH START OF LINE

    IF THE INSERTION

    IF: NEW. SOURCE_ID IS NULL THEN
    SELECT SOURCES_SEQ.nextval IN: NEW. SOURCE_ID FROM dual;
    END IF;

    END IF;

    END;
    /

    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'HUEY');
    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'DEWEY');
    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'LOUIE');
    Commit;


    CREATE SEQUENCE CHILDREN_SEQ MINVALUE MAXVALUE 1 1000000000000000000000000000 INCREMENT OF 1 START WITH 1 CACHE 20 ALL NOCYCLE.

    FAST * CREATE TABLE *.
    CREATE TABLE CHILDREN
    (CHILDREN_ID NUMBER OF NON-NULL
    , PARENT_ID NUMBER NOT NULL
    CHILD_NAME VARCHAR2 (50 CHAR) NOT NULL,
    CONSTRAINT CHILDREN_PK PRIMARY KEY (CHILDREN_ID)
    );

    create or replace
    CHILDREN_BI RELAXATION
    FRONT
    INSERT OR UPDATE ON CHILDREN
    FOR EACH START OF LINE

    IF THE INSERTION

    IF: NEW. CHILDREN_ID IS NULL THEN
    SELECT CHILDREN_SEQ.nextval IN: NEW. CHILDREN_ID FROM dual;
    END IF;

    END IF;

    END;
    /

    [code]

    Looks like it's a way to do this:

    insert into parents (parent_name) select distinct parent_name from sources;
    
    select *
      from parents;
    PARENT_ID              PARENT_NAME
    ---------------------- --------------------------------------------------
    1                      DONALD
    
    insert into children (parent_id, child_name)
    select p.parent_id, s.child_name
      from sources s
      join parents p
        on (s.parent_name = p.parent_name);
    
    select *
      from children;
    
    CHILDREN_ID            PARENT_ID              CHILD_NAME
    ---------------------- ---------------------- --------------------------------------------------
    1                      1                      HUEY
    2                      1                      DEWEY
    3                      1                      LOUIE
    
  • Synchronization between RDF store and relational table

    I start this question in a new thread, as it goes in a field of another problem

    Is one of the option to model the attributes of the object to store the attributes in a separate relational table and a SQL allows to attach graphic query results. Now, here's a situation, if we want to join, we need to keep a few key reference in the RDF data store, so that they can join together. But it leaves a question, how do synchronize us data? Suppose that we keep a user node in RDF with the user ID property and keep all other modules in the relational table. When join us, we can reach by user ID. But if we remove this record from the user in the relational table, probably RDF will not delete this user node in the graph data store. Am I correct on this point or Oracle has a sort of way to maintain data synchronization?

    Thank you.

    Hi HansC,

    Sorry for the late reply.

    When a row is deleted from a relational table, its correspondent/associated triple (s) will NOT will be removed one or more RDF models unless there is a custom logic to handle this.

    For example, we can define a trigger on the relational table to manage the synchronization of the data. Another way is to use the existing track changes

    mechanism (motion Flashback, Golden Gate etc.) to preserve the synchronization data.

    Thank you

    Zhe Wu

  • Insertion of XMLTABLE to RELATIONAL table

    Hello

    I have a Realational table


    CREATE TABLE VALU_RSLT)
    VALU_RSLT_ID NUMBER OF NON-NULL,
    NUMBER OF FRD_RQST_INFO_ID
    NUMBER OF CERT_NBR (12: 0),
    VALUATIONMETHODTYPE VARCHAR2 (4000).
    VALUATIONMODEL VARCHAR2 (4000).
    EARNED NUMBER (20: 5).
    NUMBER OF VALUATIONLOW (20: 5),
    NUMBER OF VALUATIONHIGH (20: 5),
    NUMBER OF CONFIDENCESCORE
    CONFIDENCEDESC VARCHAR2 (255),
    CRT_BY_USR_ID VARCHAR2 (255),
    CRT_TMST TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    LAST_UPD_BY_USR_ID VARCHAR2 (255),
    LAST_UPD_TMST TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );



    VALU_RSLT_ID - is a sequence object.


    Select tx. FRD_RQST_INFO_ID, CERT_NBR, temp.*
    OF FRD_XML_TEST1 tx.
    XMLTABLE ('/ DRIVEResponse/loan/assessments/ValuationResult ')
    TX OF PASSAGE. RSP_XML
    PATH of COLUMNS 'ValuationMethodType' VARCHAR2 (4000) "@ValuationMethodType."
    Path of 'ValuationModel' VARCHAR2 (4000) "@ValuationModel."
    "Assessment" PATH of NUMBER (20.5) "@Valuation."
    Path of "ValuationLow" NUMBER (20.5) "@ValuationLow."
    Path of "ValuationHigh" NUMBER (20.5) "@ValuationHigh."
    PATH of NUMBER "ConfidenceScore" "@ConfidenceScore"
    PATH of VARCHAR2 (255) 'ConfidenceDesc' '@ConfidenceDesc '.
    ) in the temp


    Is a very good job.


    What I try to achieve is to insert the data from the XML for this relational Table (VALU_RSLT) and also to increment the Sequence (VALU_RSLT_ID) and others
    check the fields in the table. (CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST).

    How can I do this?


    I tried something like this

    INSERT into VALU_RSLT (VALU_RSLT_ID, FRD_RQST_INFO_ID, CERT_NBR, VALUATIONMETHODTYPE, VALUATIONMODEL, EARNED,
    VALUATIONLOW, VALUATIONHIGH, CONFIDENCESCORE, CONFIDENCEDESC, CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST)
    VALUES (VALU_RSLT_ID_SEQ1.nextval (), select tx. FRD_RQST_INFO_ID, CERT_NBR, temp.*
    OF FRD_XML_TEST1 tx.
    XMLTABLE ('/ DRIVEResponse/loan/assessments/ValuationResult ')
    TX OF PASSAGE. RSP_XML
    PATH of COLUMNS 'ValuationMethodType' VARCHAR2 (4000) "@ValuationMethodType."
    Path of 'ValuationModel' VARCHAR2 (4000) "@ValuationModel."
    "Assessment" PATH of NUMBER (20.5) "@Valuation."
    Path of "ValuationLow" NUMBER (20.5) "@ValuationLow."
    Path of "ValuationHigh" NUMBER (20.5) "@ValuationHigh."
    PATH of NUMBER "ConfidenceScore" "@ConfidenceScore"
    PATH of VARCHAR2 (255) 'ConfidenceDesc' '@ConfidenceDesc '.
    (), Temp, NULL, NULL, NULL, NULL);



    gave me the following error message

    Error in the command line: 3 column: 35
    Error report:
    SQL error: ORA-00936: lack of expression
    00936 00000 - "missing expression.
    * Cause:
    * Action:


    How can I do this insert work?

    You mix styles of syntax INSERT. VALUES is for a single line. You want something like

    INSERT into VALU_RSLT(VALU_RSLT_ID, FRD_RQST_INFO_ID, CERT_NBR, VALUATIONMETHODTYPE, VALUATIONMODEL, VALU,
    VALUATIONLOW, VALUATIONHIGH, CONFIDENCESCORE, CONFIDENCEDESC, CRT_BY_USR_ID, CRT_TMST, LAST_UPD_BY_USR_ID, LAST_UPD_TMST)
    select VALU_RSLT_ID_SEQ1.nextval(),
           tx.FRD_RQST_INFO_ID,CERT_NBR,temp.*,
           NULL,NULL,NULL,NULL
    FROM FRD_XML_TEST1 tx,
         XMLTABLE('/DRIVEResponse/Loan/Valuations/ValuationResult'
                  PASSING TX.RSP_XML
                  COLUMNS
                  "ValuationMethodType" VARCHAR2(4000) PATH '@ValuationMethodType',
                  "ValuationModel" VARCHAR2(4000) PATH '@ValuationModel',
                  "Valuation" NUMBER(20,5) PATH '@Valuation',
                  "ValuationLow" NUMBER(20,5) PATH '@ValuationLow',
                  "ValuationHigh" NUMBER(20,5) PATH '@ValuationHigh',
                  "ConfidenceScore" NUMBER PATH '@ConfidenceScore',
                  "ConfidenceDesc" VARCHAR2(255) PATH '@ConfidenceDesc');
    
  • trigger for update field in a table with the sum of the fields to another table

    My experience in creation of triggers and pl/sql in general can be described in terms of oracle with the null value. I practiced by creating arrays and applications on my personal server at home to help me with some of my work related tasks. Right now I am creating a trigger which will, after insert, update, delete on the update of the table assignment_time_track the area of the time_spent on the table of assignments with the sum of the time_spent on the assignment_time_track table fields. I hope that run on the sentence it is clear to the people other than me. I tried this script on my own using the tool of creation of trigger for Oracle Database Express Edition, but I get the following error:

    Create a trigger failed, for the following reason:
    ORA-06552: PL/SQL: ORA-06553 finished Compilation unit analysis: PLS-320: the declaration of the type of the expression is incomplete or incorrect

    Here is my attempt to create the trigger on my own.

    create or replace trigger "ASSIGNMENT_TIME_TRACK_T1".
    AFTER
    INSERT or update or delete on 'ASSIGNMENT_TIME_TRACK '.
    for each line
    Start
    update assignments
    Set time_spent = (select sum (time_spent)
    of assignment_time_track
    where assignment_time_track.name = assignments.name);

    end;
    /


    If what I posted is not clear or more detail is needed, let me know and I will respond with a full description of tables and my goals for each table. Thanks in advance for any help. I also gladly accepts links to tutorials or lessons that explain how to do this kind of thing.

    Published by: bobonthenet on March 9, 2009 14:01

    I think I understand what you mean :)

    Rather than use a trigger to keep the master table (assignments) in sync with the time spent on the details, it would be much easier to use a query to do this, maybe creating a view.

    Something along the lines of

    SQL> create table assignments
      2  (id number primary key
      3  ,name varchar2(10)
      4  );
    
    Table created.
    
    SQL>
    SQL> create table assignment_time_tbl
      2  (id number primary key
      3  ,assid number references assignments
      4  ,time_spent number
      5  );
    
    Table created.
    
    SQL>
    SQL> insert into assignments
      2  select rownum
      3       , 'a'
      4    from all_objects
      5   where rownum < 5
      6  /
    
    4 rows created.
    
    SQL>
    SQL> insert into assignment_time_tbl
      2  select rownum
      3       , rownum
      4       , rownum * 3
      5    from all_objects
      6   where rownum < 5
      7  /
    
    4 rows created.
    
    SQL>
    SQL> commit;
    
    Commit complete.
    
    SQL>
    SQL>
    SQL> select a.id
      2       , a.name
      3       , (select sum (time_spent)
      4            from assignment_time_tbl
      5           where assid = a.id
      6         )
      7    from assignments a
      8  /
    
            ID NAME       (SELECTSUM(TIME_SPENT)FROMASSIGNMENT_TIME_TBLWHEREASSID=A.ID)
    ---------- ---------- -------------------------------------------------------------
             1 a                                                                      3
             2 a                                                                      6
             3 a                                                                      9
             4 a                                                                     12
    
  • How to write the trigger for update or delete multiple columns in a table?

    Hello

    I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.

    Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9
    EMP_IDEMP_NAMEDESIGNATIONTEAM_IDTEAM_LEADER_IDEMPLOYEEMANAGER_IDHIRE_DATERELIEVED_DATE

    --

    Thank you.

    Hi Joel,.

    Venky_prs wrote:

    Hello

    I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.

    Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9
    EMP_ID EMP_NAME DESIGNATION TEAM_ID TEAM_LEADER_ID EMPLOYEE MANAGER_ID HIRE_DATE RELIEVED_DATE

    --

    Thank you.

    You can try something like this given below to complete the historical table on update and delete.

    create or replace TRIGGER  "CLONE_EMP_UPDATE_DELETE"
    BEFORE DELETE OR UPDATE ON EMP
    FOR EACH ROW
    DECLARE
        PRAGMA autonomous_transaction;
    BEGIN
    INSERT INTO JOB_HISTORY("EMP_ID","EMP_NAME","DESIGNATION","TEAM_ID","TEAM_LEADER_ID","SUPERVISOR_ID","MANAGER_ID"
    ,"HIRE_DATE","RELIEVED_DATE")
      VALUES(:OLD.EMP_ID,:OLD.EMP_NAME,:OLD.DESIGNATION,:OLD.TEAM_ID,:OLD.TEAM_LEADER_ID,:OLD.SUPERVISOR_ID,
    :OLD.MANAGER_ID,:OLD.HIRE_DATE,
    :OLD.RELIEVED_DATE);
    COMMIT;
    END;
    

    Hope this helps you,

    Kind regards

    Jitendra

  • How to open two PDFs at the same time (for example on two related screens)? It was always possible in the previous version of the Adobe Reader software.

    How to open two PDFs at the same time (for example on two related screens)? It was always possible in the previous version of the Adobe Reader software. Now while one of them is open, I can't open the other, because it is hidden, and I have only shown in the taskbar as a thumbnail.

    Hi ewap51098943,

    You can disable this in the Edit menu-> preferences-> General

    Kind regards
    Nicos

  • export the schema, but for two tables, export only 20 rows

    11.2.0.2/RHEL 5.4

    Using expdp, I want to export an entire schema. But for the 2 large tables (say the EMP and DEPT tables) in this diagram, I want to export only 20 records (at random) for them. Is it possible for expdp and impdp?

    If this is not possible then, is there any option to have no any line for these 2 tables?

    Christian Christmas Pal Singh says:
    possible, but you must create two files dmp means export of run 2 times.
    1. for complete schema to exclude these 2 tables by the exclusion clause.
    2. use the query clause to filter the data in the second export for these 2 tables.

    Really? is not something that similar work? instead of rownum, if you want truly random, then use example of clause, but it should be based on the amount of sample would make 20 lines for you, then a bit of work there.

    schemas=my_schema
    QUERY=my_schema.table1:"where rownum < 21"
    QUERY=my_schema.table3:"where rownum < 21"
    

    Published by: rjamya on Sep 19, 2012 08:32

  • How can I write the trigger for the global temporary Table

    Hi Grus,
    How can I write the trigger for the global temporary Table.

    I created the TWG with trigger using the script below.


    CREATE A GLOBAL_TEMP GLOBAL TEMPORARY TABLE
    (
    EMP_C_NAME VARCHAR2 (20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;


    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE, UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERRING AGAIN AS NINE OLD AND OLD
    FOR EACH LINE
    BEGIN
    INSERT INTO VALUES EMPNAME (: OLD.) EMP_C_NAME);
    END;
    /


    trigger was created successfully, but her would not insert EMPNAME Table...

    Please guide if mistaken or not? If not wanting to give a correct syntax with example


    Thanks in advance,
    Arun M M
    BEGIN
    INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
    END;
    
    you are referencing old value in insert stmt.
    
    BEGIN
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    END;
    

    then run your app, it works very well...

    CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
    (
    EMP_C_NAME VARCHAR2(20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;
    
    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE OR UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
    dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo');
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    dbms_output.put_line(:OLD.EMP_C_NAME);
    END;
    /
    
    create table EMPNAME as select * from GLOBAL_TEMP where 1=2
    
    insert into GLOBAL_TEMP values('fgfdgd');
    commit;
    select * from GLOBAL_TEMP;
    select * from EMPNAME;
    
    output:
    1 rows inserted
    commit succeeded.
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    

    He got Arun

    Published by: OraclePLSQL on December 28, 2010 18:07

  • How can simple trigger for verification of status update on the table... - I get upd sql then?

    Hi guys,.

    I need to do a temporary simple audit on all updates on a table.

    That's why I create a trigger for her...

    However, I need to capture the SQL statement to make the update as well... However I have no way to do it, because it is always replaced by a SQL code I run to get the SESSION ID...

    Here is the trigger...
    ----------------------

    create or replace
    alert_setting_trg relaxation
    before the update on user_alert_settings
    for each line
    declare
    number of v_sid;
    v_username varchar2 (100);
    v_osuser varchar2 (100);
    v_machine varchar2 (100);
    v_program varchar2 (100);
    v_module varchar2 (100);
    v_prevsqlid varchar2 (100);
    v_sqltext varchar2 (100);

    Start
    SELECT SYS_CONTEXT ('USERENV', 'SID')
    IN v_sid
    FROM DUAL;

    SELECT the username, osuser, machine, program, module, PREV_SQL_ID
    IN v_username, v_osuser, v_machine, v_program, v_module, v_prevsqlid
    SESSION $ v where SID = v_sid;

    SELECT sql_text
    IN v_sqltext
    V $ sqltext
    WHERE SQL_ID = v_prevsqlid;

    INSERT INTO alert_settings_log
    VALUES (sysdate, v_sid, v_username, v_osuser, v_machine, v_program, v_module, v_sqltext,: new.user_id,: new.service_grp,: new.alert_setting_id,: old.alert_active,: new.alert_active);

    end;


    Now the problem is that...
    the capture of SQL statement will always be

    SELECT SYS_CONTEXT ('USERENV', 'SID')
    IN v_sid
    FROM DUAL;


    and not the UPDATE table statement.

    1st quarter) I have to get the SID of the session before I could know what SQL it is running.

    However, once I get the SID, the SQL to UPDATE the SID is run changes the SQL that gets the SID.

    What can I do?

    Rgds,
    Noob

    Instead of to the request in three steps, do it in 1. Replace all three of your queries with something like:

    SELECT s.username, s.osuser, s.machine, s.program, s.module, q.sql_text
    INTO v_username, v_osuser, v_machine, v_program, v_module, v_sqltext
    FROM v$session s, v$sql_area q
    WHERE s.sid = SYS_CONTEXT('USERENV','SID') and
          s.prev_sql_id = q.sql_id
    

    John

  • Relational table between the user and UD_ADUSER profile

    Hello

    I have a requirement where in I need to write a query to find out the difference between user profile for a particular user data and the form data from the same user AD process in Oracle Identity Manager 11g R2 (11.1.2.0)

    While the details of the user are stored in usr table, the table of process for AD shape is UD_ADUSER table. By comparing the two tables, I find the common attribute to be orc_key in UD_ADUSER and ORC table contains the usr_key and table orc_key / usr the usr_key.

    Is ORC table the proper relational table between usr and UD_ADUSER tables to link users between these two tables usr and UD_ADUSER?

    Please correct me if I'm wrong.

    -Thank you,

    def.

    You can use these two tables. I always spend Ouedraogo table between them because the OST has the status of a resource. You can query between them.

    -Kevin

  • Loading XML into the relational Table data

    Hello

    I get a generated XML file to other tools (Windows), I am trying to create a Linux shell script that will gather the necessary XML file to my Linux server, then ask Oracle to use this file to load the XML data into a relational table. This activity and the data will be needed on an ongoing basis.

    I tried two ways. First, I loaded the XML document into the database and tried to extract the data directly from the document, but it does not work. Now I want to try to read the data directly from the file on the server through select, however I don't get all the returned data. In the Select statement below, I am trying to query the data to see what is returned for my tests.

    Create Table ci_results_table (transactionID Varchar2 (100), //transactionID should be PrimaryKey but became errors in test of insert, PK so deleted NULL value)

    message Varchar2 (200),

    This Varchar2 (50).

    XMLType of the ProcessedDate,

    status Varchar2 (50).

    sourceFile VarChar2 (100));

    Select x.*

    from XMLTable)

    ' TSPLoadResults/results '.

    PASSAGE xmltype (bfilename('CMDB_DEVADHOCRESULTS_DIR','LoadResults-HP_146.results.xml'), nls_charset_id ('AL32UTF8'))

    COLUMNS

    transactionID PATH Varchar2 (100) 'TransactionID '.

    Result XMLType PATH 'result ',.

    Message Varchar2 (200) PATH "Message."

    PrimaryKey Varchar2 (50) PATH "PrimaryKey"

    Date of ProcessedDate path "ProcessedDate."

    Status Varchar2 (50) PATH "Status."

    SourceFile VarChar2 (100) PATH "SourceFileName.

    ) x

    ;

    Eventually, I'll have to build on that to limit the returned data to records where SourceFileName is like '% PA' and insert what is returned in to the ci_results_table. Attached is an example of the XML results file I am trying to load, it is named "ResultsTransformedtoUnix" because I used dos2Unix to convert Unix which can be good or bad. (I send the output file must be converted to the format BACK until the other application can read). Original (before converting Unix) file named in the script is also attached.

    Help, please. Thank you!

    Hello

    I see some bad things in your query.

    (1) obvious one, explaining why you get all the data: there is a typing error in the XQuery expression, there 'result' not'slead.

    (2) ProcessedDate can be extracted as a date (at least not directly) because it actually represents a timestamp, use the TIMESTAMP WITH time ZONE HOURS and cast back to DATE data type in the SELECT clause

    (3) transactionID is an attribute, it must be accessible with ' @' (or ' attribute:' axis)

    (4) if the encoding of file really is ISO-8859-1 as suggested in the prologue, then do not use AL32UTF8 but the name of the corresponding character set: WE8ISO8859P1

    Here is the query to work:

    select x.transactionID
         , x.Message
         , x.Primarykey
         , cast(x.ProcessedDate as date) ProcessDate
         , x.Status
         , x.SourceFile
    from XMLTable(
           '/TSPLoadResults/Result'
           PASSING xmltype(bfilename('XML_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('WE8ISO8859P1'))
           COLUMNS
             transactionID Varchar2(100)            PATH '@transactionID',
             Message       Varchar2(200)            PATH 'Message',
             PrimaryKey    Varchar2(50)             PATH 'PrimaryKey',
             ProcessedDate timestamp with time zone PATH 'ProcessedDate',
             Status        Varchar2(50)             PATH 'Status',
             SourceFile    VarChar2(100)            PATH 'SourceFileName'
         ) x
    ;
    

    Directly on the file using this query will only be decently (for large files) on 11.2.0.4 and beyond.

    On older versions, first load the file into a (temporary) XMLType column with binary XML storage and CHOOSE from there.

    because I used dos2Unix to convert Unix which can be good or bad.

    This conversion should not be necessary.

  • Automatically update a field in a related table.

    Hi all

    So far, I worked in a dev environment closed, where I can define, an "update" on a table, a related table to change a value.
    Ex: In the table 'orders', I can set an "update" of the Stock of the Products table field, racking up the value of the quantity of the command line (I hope I explained properly, is very difficult to explain it to me in English: P)

    This process is automatically. If I add an order with 14 tomato, field tomato product inventory, increase in 14 tomatoes, and if I change the command line, or delete it, all this changes affect the value of the stock.

    I would do the same thing, and I don't know if Oracle has something for this. I suppose it's possible to write 3 INSERT, update, and delete triggers, but I would like to know if there is something more easy/fast/easy to manage.

    Kind regards.

    It's easy. Like this:

    CREATE OR REPLACE TRIGGER row_level
    AFTER INSERT OR UPDATE OR DELETE
    ON orders
    FOR EACH ROW
    DECLARE
     vMsg VARCHAR2(30) := 'Row Level Trigger Fired';
    BEGIN
      IF INSERTING THEN
        dbms_output.put_line(vMsg || ' When Inserting');
      ELSIF UPDATING THEN
        dbms_output.put_line(vMsg || ' When Updating');
      ELSIF DELETING THEN
        dbms_output.put_line(vMsg || ' When Deleting');
      END IF;
    END row_level;
    /
    

    http://psoug.org/reference/table_trigger.html

  • Trigger on a several tables

    IHAVE a requirement like this.but explained in the form of two table emp and Dept.

    I have a table emp table(empno,ename,deptno) and dept (deptno, dname)
    I have a third emp_details (empno, ename, deptno, dname) of table

    I have a procedure that returns the empdetails
    I have a query in th eabove procedure, select * from emp_details; that returns all the details.

    I want to write a trigger of such that,.
    If I insert or update a row in the emp and dept table and then he should get inserted/updated in the table of emp_details also.
    I am able to write triggers ona single table. I can't get the rows inserted or updated when it comes to multiple tables.

    Data:

    create table emp
    (key primary empno number,)
    Ename varchar2 (20).
    DEPTNO number
    )

    create table dept
    (key primary number depno,)
    DNAME varchar2 (20)
    )

    Insert into dept values(10,'hyderabad');
    Insert into dept values(20,'bangalore');

    Insert into emp values(1,'A',10);
    Insert into emp values(2,'B',20);


    CREATE TABLE EMP_DETAILS
    AS
    SELECT E.ENAME, E.EMPNO, E.DEPTNO, D.DNAME
    Of
    EMP E, DEPT. D
    WHERE E.DEPTNO = D.DEPTNO;


    CREATE OR REPLACE PROCEDURE PROC_EMP_DETAILS (P_EMPNO EMP. EMPNO % TYPE OUT, P_ENAME EMP. ENAME OUT TYPE, P_DEPTNO EMP %. DEPTNO % TYPE OUT, P_DNAME MIN. DNAME % OUT TYPE)
    AS
    / * EXAMPLE OF CODE * /.
    BEGIN
    SELECT * FROM EMP_DETAILS;
    END;
    /

    I tried like this

    CREATE OR REPLACE TRIGGER TRIG_EMP_DETAILS
    AFTER INSERT OR UPDATE ON EMP
    FOR EACH LINE
    REFERENCING OLD AS OLD AGAIN AS NEW
    BEGIN
    INSERT INTO EMP_DETAILS VALUES(:NEW.) EMPNO,: NEW. ENAME,: NEW. DEPTNO,?)

    ???? -As a column, we get dept table how to represent that?

    Could you please guide me in this regard?



    Thanks in advance
    KVB

    Trigger on a several tables

    I think that you don't need triggers on several tables: one is enough:

    CREATE OR REPLACE TRIGGER trig_emp_details
      AFTER INSERT OR UPDATE
      ON emp
      FOR EACH ROW
    BEGIN
      INSERT INTO emp_details
        SELECT :new.empno, :new.ename, :new.deptno, dname
          FROM dept
         WHERE deptno = :new.deptno;
    END;
    
  • Inserting data in several related tables using the database

    Hello world
    I'm working on a BPM application using Oracle BPM 11.1.1.5.0 and JDeveloper 11.1.1.5.0.

    In my database, I have two tables, loan and guarantee that are related by a field named employeeID (PK on loan) and FK in warranty.
    Each line can have several lines of guarantee.

    At this point, I'm doing an entry form for the user to insert data in the two tables.

    I did successfully before with a single table that has no relations.

    The way I'm doing here is, after the creation of the database successfully adapter, a type of LoanCollection is created in the types module, which can be used to create business objects and data objects of.

    The problem is when I create an object of type loanCollection process data and then create a UI generated automatically on that basis, only the fields in the primary table (the Table of loan) appear in the form.
    On the other hand, if I create a business object based on the LoanSchema, the form for all of the two tables is created automatically (the loan as a form, the guarantee in a table), but then, when I try to access it in the section processing service mission which calls the database adapter, I have no access to such.
    In fact, the only type which can be used in the service task is the process based on the loanCollection data object.

    To summorize, I have to use the type of business for my UI object to include all the fields in both tables, so I have to use the data object from the collection process in the transformation of service task dialog box.
    And I can't find a way to map to another.

    Can someone help me with this please?
    Thank you very much

    Try to follow these steps.

    1. create a new module in your catalogue our BPM project management section
    2. in this new module create 3 Business Objects - (LoanBusinessObject, GuaranteeBusinessObject and GuaranteeArrayBusinessObject)
    3. Add the attributes appropriate to the LoanBusinessObject and the GuaranteeBusinessObject so that they mimic your database tables, then to the GuaranteeArrayBusinessObject add an array of type attribute GuraranteeBusinessObject
    4. now you need to create two process data objects, type loanProcessObject LoanBusinessObject and type guaranteesProcessObject GuaranteeArrayBusinessObject
    5. as inputs to your human task adds the loanProcessObject and guaranteesProcessObject, these should now be available in your data controls and can be used to auto generate the form
    6. in your dbadapter you'll then use XSL Transformation and use for each so that it will write the data to the ready table and all the line items of warranty for the warranty table.

Maybe you are looking for

  • 'Settings' icon missing

    Settings icon is missing. Please spare me self-righteous excuses, denial and nonsense. The settings option is simply gone, kaput, no more. Rather than assuming that the user is always bad, consider resolved the bug instead.

  • Can I upgrade my processor Compaq Presario CQ57?

    I have a Compaq Presario CQ57 Notebook with an Intel Celeron CPU B815 with 1.60 GHz. Is my product number: A9S00PA #ABG. I was wondering if I could upgrade my processor or not.

  • HP Pavilion 15-bc000nx: Webcam not working not

    my web camra is not working I just bought this laptop it's new I've updated the operating system and updated the driver (from the internet (aut research)) HP Pavilion 15-bc000nx (ENERGY STAR) Model #: W7B64EA

  • How to turn the "words" in a link

    I would like to know how to turn the words into link instead of posting the link. Example: I copy and paste this one answers... Microsoft PowerPoint 2007 Viewer . For the benefits of others looking for answers, please mark as answer suggestion if it

  • OS 6.0.0.526 update problem

    The update to OS version 6.0.0.526 caused problems with the GPS connection. Most of the users said that after having updated the operating system (for example on the Torch 9800), they were not able to acquire a GPS lock. I have not found to date a ch