Check the data before inserting

Hi all

Appreciate your help. I have 3 tables, see below

Examples of data

CREATE TABLE PARENT_1

(PARENT1_PK_COL NUMBER 4

) ;

ALTER TABLE PARENT_1 ADD PRIMARY KEY

(

PARENT1_PK_COL

)

;

/

CREATE TABLE PARENT_2

(PARENT2_PK_COL NUMBER 4, NUMBER 4 PARENT2_FK_COL

) ;

/

ALTER TABLE PARENT_2 ADD PRIMARY KEY

(

PARENT2_PK_COL

)

;

/

ALTER TABLE PARENT_2 ADD CONSTRAINT FOREIGN KEY ABC

(

PARENT2_FK_COL

)

REFERENCES PARENT_1

(

PARENT1_PK_COL

)

;

/

CREATE TABLE CHILD_1

(CHILD_1_PK NUMBER 4

) ;

ALTER TABLE CHILD_1 ADD PRIMARY KEY

(

CHILD_1_PK

)

;

/

My question is that before the insertion of data in the child_1 table, oracle look in parent_1.PARENT1_PK_COL and parent_2.PARENT2_PK_COL and columns if the data exists in both table then it allows to insert the record in the child_1 table, how do I apply this logic? do I need to add another foreign key in the child_1 table that references the two table? Please guide. Thank you

Concerning

MIT


I got the answer, please ignore this thread

Tags: Database

Similar Questions

  • ITextModelCmds::InsertCmd modifies the data before inserting it to the history

    When I insert characters from a story by using ITextModelCmds::InsertCmd, some characters are converted into a totally different value.  Anyone know how to get the exact characters inserted in the story without InDesign switching what he thinks you want?

    When I export my page as ASCII elements, they get inserted into history as plain text.  If the characters ASCII characters single quote, InDesign converts the values 0 x 2018 or 2019 0 x.  It is originally importing my data items page to fail because the values have changed.

    If there is not a way to avoid this, anyone know where I can find a list of the characters that are converted so I don't know what to expect when importing?

    Temporarily disable the InDesign > preferences > Type... > preference 'using the quote from typographers '.

    Do not forget the value of kDocWorkspaceBoss / IID_ITEXTOPTIONS / GetUseTypographersQuotes().

    kUseTypographersQuotesCmdBoss

    IID_IUIDDATA-your kDocWorkspaceBoss online

    IID_IBOOLDATA-online fake

    There might be some façade / util as wrapper for this command, I'm too lazy to look for.

    When you are finished, restore the old value (remember above).

    Dirk

  • Check the date in the schema

    Hello

    I'm new on odi and I have to handle this scenario below

    I insert a date in the table at the end of a single package, in another package, I need to check whether this date is equal to the date system and then move to the second stage.

    I reached the date of insertion in the first package with ODI PROCEDURE below using

    Insert dates

    (Select to_char (sysdate, 'YYYY'), to_char (sysdate, 'mm'), to_char (sysdate, 'dd'), the double null);

    Can you please indicate how can I check the second step.

    You could use variable refresh and then check it out under estimate

    for example (in your case):

    Update the variable

    Select

    -case when to_char (sysdate, 'YYYY') + '-' + to_char (sysdate, 'mm') + '-' + to_char (sysdate, 'dd') = dates.year + '-'+ dates.month +' -' + dates.day, 1

    otherwise 0 end of dates where...

    On the second State handed this condition variable 1

    PS: why you store date in columns three tank?

    Maybe stored in formats or date format YYYYMMDD

  • Anyone know how to check the date of warranty until when?

    Anyone know how to check the date of warranty until when?

    https://checkcoverage.Apple.com/Jo/en/;JSESSIONID=9pJ0X9pFPJtNg3c44yDGCvk9pVpt5l QSgn4B60y4Skv1WfmnqMkF!-1840326800

  • I bought a latitude d530 use. It came with Windows 7. Site Web of Dell initially said vista wit came. It is no longer start. Error says check the data cable

    I bought a latitude d530 use. It came with Windows 7. Site Web of Dell initially said vista wit came. It is no longer start. Error says check the data cable. Sometimes, reinstall drive. I do not have the windows CD. Can I download the original Windows on android phone and the transfer

    You can download and create a bootable copy:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-windows_install?tab=question&status=unanswered

    then

    http://techingiteasy.WordPress.com/2012/04/13/how-to-activate-Windows-7-OEM-license-using-a-retail-disc/

  • How to check the data file is set to unlimilted autoextend

    S/N,

    Oracle version: 10.2.0.4
    OS: linux

    could someone tell me how can I check the data file are set to unlimited autoextend?

    Thank you
    Bahadur.

    Salvation;

    Pelase see:
    How to check the CanGrow data files the value of Maxsize unlimited [ID 468096.1]

    Respect of
    HELIOS

  • How to check the date valid?

    Hello

    I have a stored procedure that has a parameter of type varchar data entry. This parameter is actually a date, now I want to check whether this parameter is a valid date. My version of oracle's 10g. I tried ISDATE() built-in but my version of oracle does not support.

    Can ppl help please how?

    Concerning

    Frébault

    Hello Marie Lise.
    Here is the code example that you can do to check the Date. Create a function for this, hope this helps

    CREATE OR REPLACE FUNCTION F_DATE(v_date IN VARCHAR2) RETURN NUMBER IS
        v_date1 DATE;
    BEGIN
        select to_date(v_date) into v_date1 from dual;
            RETURN 1;
        Exception WHEN Others THEN
            RETURN 0;
    END;
    ----------------------------------------------
    SELECT F_DATE('01-JAN-09') FROM DUAL;
    -- Returns 1
    SELECT F_DATE('111111') FROM DUAL;
    -- Returns 0
    

    Please indicate if it helps you or correct
    Kind regards
    Danish

  • It does not work when you use the trigger to check the data of the other table.

    Please help me with this, I put a trigger on a table, but it can not work as I expect.

    case study: a class has many students, one of them is going to match.
    The purpose of this trigger is to check when to choose a student going to match, this student has in his class where it belongs to.
    Oracle version is 10.2.0.1.0.
    --table:
    DROP TABLE STU;
    DROP TABLE CLASS;
    
    create table CLASS(
    CID     VARCHAR2(5)   PRIMARY KEY,
    CNAME   VARCHAR2(20)  NOT NULL,
    SCHOSEN VARCHAR2(5));
     
    create table STU(
    SID     VARCHAR2(5)   PRIMARY KEY,
    SNAME   VARCHAR2(20)  NOT NULL,
    CID     VARCHAR2(5)   NOT NULL REFERENCES CLASS(CID) ON DELETE CASCADE);
    
    --data:
    --CLASS
    INSERT INTO CLASS(CID,CNAME) VALUES(1,'SUN');
    INSERT INTO CLASS(CID,CNAME) VALUES(2,'MOON');
    INSERT INTO CLASS(CID,CNAME) VALUES(3,'EARTH');
    --STU
    INSERT INTO STU VALUES(1,'JACK',1);
    INSERT INTO STU VALUES(2,'TOM',1);
    INSERT INTO STU VALUES(3,'LILY',2);
    INSERT INTO STU VALUES(4,'DUSTIN',3);
    
    --TRIGGER
    CREATE OR REPLACE TRIGGER CHECK_SCHOSEN
    BEFORE INSERT OR UPDATE OF SCHOSEN ON CLASS
    FOR EACH ROW WHEN (NEW.SCHOSEN IS NOT NULL)
    
    DECLARE
    DUMMY INTEGER;
    INVALID_STU EXCEPTION;
    VALID_STU EXCEPTION;
    MUTATING_TABLE EXCEPTION;
    PRAGMA EXCEPTION_INIT(MUTATING_TABLE, -4091);
    
    CURSOR DUMMY_CURSOR (ST VARCHAR2, CL VARCHAR2) IS
      SELECT SID FROM STU, CLASS
      WHERE STU.SID=ST AND STU.CID=CLASS.CID AND CLASS.CID=CL
        FOR UPDATE OF CLASS.SCHOSEN;
    
    BEGIN
      OPEN DUMMY_CURSOR(:NEW.SCHOSEN, :NEW.CID);
      FETCH DUMMY_CURSOR INTO DUMMY;
      IF DUMMY_CURSOR%NOTFOUND THEN
        RAISE INVALID_STU;
      ELSE
        RAISE VALID_STU;
      END IF;
      CLOSE DUMMY_CURSOR;
    EXCEPTION
      WHEN INVALID_STU THEN
        CLOSE DUMMY_CURSOR;
        DBMS_OUTPUT.PUT_LINE('PLEASE RE-ENTER CLASS ID AND STUDENT ID AS CLASS OR STUDENT IS NOT VALID.');
      WHEN VALID_STU THEN
        CLOSE DUMMY_CURSOR;
        DBMS_OUTPUT.PUT_LINE('STUDENT CHOOSE SUCCEFULLY!');
      WHEN MUTATING_TABLE THEN
        NULL;
    END;
    /
    Just copy and paste on it and try to run next:
    UPDATE CLASS
    SET SCHOSEN = 3
    WHERE CID = 1;
    Clearly, you can't student who is 3 as to Member of class 1. Please help me. Thank you.

    Published by: 991096 on March 1st, 2013 02:36

    Published by: 991096 on March 1st, 2013 03:03

    Published by: 991096 on March 1st, 2013 03:11

    Hello

    991096 wrote:
    1. the purpose of this trigger is to check when to choose a student going to match, this student has in his class where it belongs to. Then, when I try to choose 3 student-member of correspondence of class 1, should give me "PLEASE RE-ENTER ID AND STUDENT ID AS CLASS or STUDENT not IS NOT VALID."

    Then do something like this:

    CREATE OR REPLACE TRIGGER CHECK_SCHOSEN
    BEFORE INSERT OR UPDATE OF SCHOSEN ON CLASS
    FOR EACH ROW WHEN (NEW.SCHOSEN IS NOT NULL)
    DECLARE
        sid_found     stu.sid%TYPE;
    BEGIN
        dbms_output.put_line (:NEW.schosen || ' = schosen entering check_schosen');             SELECT  sid
             INTO    sid_found
         FROM      stu
         WHERE     sid     = :NEW.schosen
         AND     cid     = :NEW.cid
         AND     ROWNUM     = 1     -- to avoid TOO_MANY_ROWS
         ;
    EXCEPTION
        WHEN  NO_DATA_FOUND
        THEN
         RAISE_APPLICATION_ERROR ( -20000
                        , 'Please re-enter class id and student id as class ('
                          || :NEW.cid
                          || ') or student ('
                          || :NEW.schosen
                          || ') is not valid.'
                        );
    end;
    /
    

    DBMS_OUTPUT creates only a message. The message may not be displayed, and if this is the case, then the user cannot see it. The DML will still take place.
    I used instead, RAISE_APPLICATION_ERROR to keep the DML does not happen. It displays a message like

    ORA-20000: Please re-enter class id and student id as class (1) or student (3) is not valid.
    

    ' 2 ' game ' means ' an official competition in which two several people or teams competing.

    What individuals or teams are competing in this case?
    In any case, the question wasn't 'that 'game' means', but

    Frank Kulash wrote:
    What do you mean when you say "going to match?

    I think that now you're saying that the new values of (class.cid, class.schosen) must be equal to (or "fit") some existing (stu.cid, stu.sid).

    3. thanks for your tip, I learned how to use '{code} '.

    4. it's really goes with the exception of MUTATING_TABLE. So, how do to fix the trigger to show me INVALID_STU EXCEPTION when I try to choose a student does not belong
    a class?

    Don't refer to the table of class in the trigger, and the error table mutation occur. All the information you need are in the stu table, so there is no need to query the table of class, anyway.

  • What is the best way to check the data

    What is the best way to check the actual changes in the data, i.e., to be able to see each insert, update, delete on a given line, when it happened, who did it, and what looked like to the front row and after the change?

    Currently, we have implemented our own audit infrastructure where we generate standard triggers and an audit table to store the OLD (values at the beginning of the Timekeeping point row before) and NEW (values at the beginning of the point of timing after line) values for each change.

    I put this strategy due to the performance impact there (important say least) and because it's something that a developer (confession, I'm the developer) came with, rather than something is a database administrator came with. I looked in the audit of the Oracle, but it doesn't seem like we would be able to go back and see what a line looked like at some point in time. I also watched flashbacks, but this seems like it would take a monumental amount of storage just to be able to go back a week, much less the years currently keep us these data.

    Thank you
    Matt Knowles

    Published by: mattknowles on January 10, 2011 08:40

    mattknowles wrote:
    What is the best way to check the actual changes in the data, i.e., to be able to see each insert, update, delete on a given line, when it happened, who did it, and what looked like to the front row and after the change?

    Currently, we have implemented our own audit infrastructure where we generate standard triggers and an audit table to store the OLD (values at the beginning of the Timekeeping point row before) and NEW (values at the beginning of the point of timing after line) values for each change.

    You can either:
    1. set up your own audit custom (as you do now)
    2 flashback Data Archive (11 g). Application for licence.
    3 version check your tables with Workspace Manager.

    >

    I put this strategy due to the performance impact there (important say least) and because it's something that a developer (confession, I'm the developer) came with, rather than something is a database administrator came with. I looked in the audit of the Oracle, but it doesn't seem like we would be able to go back and see what a line looked like at some point in time. I also watched flashbacks, but this seems like it would take a monumental amount of storage just to be able to go back a week, much less the years currently keep us these data.

    Unfortunately, the audit of data always takes a lot of space. You should also consider the performance, as custom triggers and Workspace Manager will perform much slower than the FDA if there is heavy DML on the table.

  • Check the Date

    Hi,

    My_table
    COL_A | COL_b
    1     | 07/01/2012
    2     | 01/02/2012
    3     | 10/02/2012  <-- WRONG
    4     | 08/02/2012
    5     | 18/03/2012
    6     | 20/03/2012
    7     | 16/02/2012  <-- WRONG
    8     | 07/05/2012
    9     | 10/05/2012

    The dates are obligatory and they are arranged in the cronological order.
    Is it possible to verify which ones are not in order with the help of only one sql?

    Regards

    Jomar
                       

    Hi, Jomar,

    Jomar says:

    Hi,
    
    My_tableCOL_A | COL_b1     | 07/01/20122     | 01/02/20123     | 10/02/2012  <-- WRONG4     | 08/02/2012
    

    Why do you say this and not

    COL_A   COL_B
    3       10/02/2012
    4       08/02/2012     <-- WRONG
    

    ?

    5     | 18/03/20126     | 20/03/20127     | 16/02/2012  <-- WRONG8     | 07/05/20129     | 10/05/2012
    
    The dates are obligatory and they are arranged in the cronological order.Is it possible to verify which ones are not in order with the help of only one sql?
    

    Can you tell which ones is not in order? Describe exactly why you want the results do you and not some others (such as those that I asked above), and someone will help you to get them.

    Regards
    
    Jomar
    

    Assuming col_b is a DATE, you can do something like this:

    SELECT       col_a
    ,       col_b
    ,       CASE
               WHEN  col_b < LAG  (col_b) OVER (ORDER BY  col_a)
                 OR  col_b > LEAD (col_b) OVER (ORDER BY  col_a)
               THEN  '<-- Could be wrong'
           END             AS flag
    FROM       my_table
    ORDER BY  col_a
    ;
    

    I hope that answers your question.
    If not, what exactly is your question? What exactly are you trying to do? You want to change a single column (or the other), such as two columns of follow the same order? It's actually easier to identify which lines are out of use.
    Post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
    In the case of a DML (UPDATE), for example, the sample data should show what looks like the tables before the DML, and the results will be the content of the or the tables changed after the DML.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • increase the value of minute in 14 minutes, while the data is inserted into the table

    Hello

    I'm having the asp page that connects with the DB to insert values into the table. One column is date data type. Value from this asp page must be incremented to 14 minutes before be inserted into the table.

    How can I do this?
    sqlG="INSERT INTO AEMU " &_
                                                      " (MSISDN,X,Y,TIME_STAMP,REQ_ID, " &_
                                                      "  COUNTRY_G)" &_
                                                      " VALUES " &_
                                                      "('"& msid &"'," &_
                                                      "'" & X & "'," &_
                                                      "' " & Y & " '," &_
                                                      "to_date('" & Day(TrueTimeStamp) & "-" & MonthName(Month(TrueTimeStamp), True) & "-" & Year(TrueTimeStamp) & " " & Hour(TrueTimeStamp) & ":" & Minute(TrueTimeStamp) & ":" & Second(TrueTimeStamp) & "', 'DD-MON-YYYY HH24:MI:SS')," &_
                                                      "' " & req_id & " '," &_
                                                      "'" & CountryName_G & "')"

    Try this way:

    sqlG="INSERT INTO AEMU " &_
         " (MSISDN,X,Y,TIME_STAMP,REQ_ID, " &_
         "  COUNTRY_G)" &_
         " VALUES " &_
         "('"& msid &"'," &_
         "'" & X & "'," &_
         "' " & Y & " '," &_
         "to_date('" & Day(TrueTimeStamp) & "-" & MonthName(Month(TrueTimeStamp), True) & "-" & Year(TrueTimeStamp) & " " & Hour(TrueTimeStamp) & ":" & Minute(TrueTimeStamp) & ":" & Second(TrueTimeStamp) & "', 'DD-MON-YYYY HH24:MI:SS')+14/(24*60)," &_
         "' " & req_id & " '," &_
         "'" & CountryName_G & "')"
    

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com]

  • Satellite M300 - how do I back up the data before using the recovery disk

    Hello everyone,

    Today, I closed my laptop Toshiba Satellite M300.
    Just after a few seconds, it automatically in service and reported some "boot error".

    She also suggested I put on the recovery CD. When I put the CD, nothing happened.
    After awhile, I read the instructions in the CD cover that says that I have to hold the C button and it will start the recovery process.

    How the process goes, the system told me that all the files that I had in the computer would be removed.
    Is it possible how I could back up my documents before as I recover my Vista?

    I would be very grateful if someone could help me!

    Sincerely,

    Milan

    Hello

    If I understand correctly, you are not able to boot into the Windows operating system; According to the normal starting procedure or by using safe mode. Is this good?

    If Yes, then I don't see many options to get access to the files on the HARD drive.
    What you could try is to remove the HARD drive and use an external USB 2.5 enclosure to connect the HARD drive on another computer.
    Then you could test whether it is possible to access the HARD disk and save the data.

    The Toshiba Recovery disk does not any option that allows you to save the data, the drive formats the HARD drive and erases all partitions.

  • Save the data before and after the occurrence of a Trigger Condition.

    Hello

    I am worrking on an application that acquires data from 64 channels and performs many analyses.

    Necessary to implement something is recording the data in the event of alarm condition.

    I've implemented datalogging in many previous applications, but this one is difficult.

    I need to save data for a few seconds before and a few seconds after the alarm has occurred in a single file.

    I thought constantly write data to a file PDM and at the same time deleting the old data, until the alarm trigger occurs.

    but I was not able to do, since I have no blocks to remove data from a PDM file.

    I'm looking for the ideal approach to this recording.

    Any help will be appreciated.

    What I have to do this in the past, use of a queue with loss as a circular buffer.  When you get the relaxation, dump you the data in the queue to your file and then save however many data you want after the outbreak.

    For the purposes of the memory allocation, do not use the queue to rinse.  Use rather a Dequeue element inside a conditional FOR loop with a 0 timeout (reading the queue stops when you have a timeout or you read X samples).

  • How to check the date of last used database?

    We have a few databases are not used for a long time. How we can check the last date of use?

    I tried scn_to_timestamp (max (ora_rowscn)), does not, because scn_to_timestamp SNA must be not more than 5 days.
    I tried DBA_TAB_modifications, but we have not defined monitoring.

    Thank you very much

    SkyRiver

    How we can check the last date of use?

    If apps/user to connect through earpiece, you can look in the newspaper of the listener.

  • check the data

    Hi experts,

    using the jdeveloper 11.1.1.4.0 version and am using adf BC

    Here's my use case

    I had an af:table in the user interface. He had two fields (id1, id2).

    1 - the ID is a primary key.

    2 - the ID is not a primary key.

    some time, click on save button.

    I want to check the two fields with the same data. If the same data exist in two means of field. error should be thrown during the recording of the data.

    willingness to example in the photo what it is?

    ID1-(PK) | ID2

    Data1 | Data1 > error should be thrown during recording.

    Data2. datas > just accept to save it.

    in your dodMl of your entityImpl compares the two values... as

    public void doDML(operation){
    ...
    if(operation== DML_UPDATE){
    String value1= getAttribute("value1");
    String value2= getAttribute("value1");
    if(value1.equalIgnoreCase(value2)){
    throw new JBOException("Both the values are same");
    }
    }
    ...
    }
    

Maybe you are looking for

  • Why is it so difficult to find the required configuration or the date of issue for versions of Firefox?

    Why aren't Firefox system requirements and disclosure of information made accessible via links on the main pages of Firefox?I can find them easily enough via Google, but I wonder why they can't be found in in mozilla.com.Even a search in aid of "Fire

  • "WindowsUpdate_8024200D" "WindowsUpdate_dt000"

    Set to automatic update tried 5 or 6 times (after restart) to install KB967723. It gives the error next "WindowsUpdate_8024200D" "WindowsUpdate_dt000"What I can do. Operating system is Vista Ulitmate 64

  • Print with my printer HP 7510 35mm slides

    The HP 7510 has the ability to scan and print 35mm slides? If not, is it all the accessories for the printer who will do it?

  • How to make an element ListField unselectable?

    I did a search but could not find an answer and I tried to play with the recall but nothing worked so just... How could I go for a row of a listField unselectable? What I'm trying to do, is to have a "separator" in the list, and when the user makes a

  • Get Windows is not genuine message

    Hello I get a message on my phone that says "copy of windows is not genuine." I ran the diagnostic tool and the results are below. I'm not the greatest technology, so if the answer may be as clear as possible I would appreciate it. Thank you. Diagnos