foreign keys different files randomly

Hello dear members,

Here is my table

MY_TABLE
--------------------
PRIMARY_KEY FOREIGN_KEY
1A
1 b
3A
4 B
5 B
6 B
8 m
8 C
9 C
10 D

I want to fetch random files N where these records N foreign keys must be different.

Example outouts:
N = 2
1
4

N = 3
1
7
9


I'm sure there is a quick and logical way to achieve this goal, but I couldn't find that either by myself or through google.
Thanks for your replies.

brkmhr wrote:
Hello

Are you sure that's the answer? Because I'm not!

Stew of solution is really COOL, but your sentence unfortunately does not show satisfaction.

If you want to try its solution with a slight change, you exactly what you need:

with mydata AS
(
   SELECT 1  pk, 'A' fk FROM DUAL UNION ALL
   SELECT 2  pk, 'A' fk FROM DUAL UNION ALL
   SELECT 3  pk, 'A' fk FROM DUAL UNION ALL
   SELECT 4  pk, 'B' fk FROM DUAL UNION ALL
   SELECT 5  pk, 'B' fk FROM DUAL UNION ALL
   SELECT 6  pk, 'B' fk FROM DUAL UNION ALL
   SELECT 7  pk, 'B' fk FROM DUAL UNION ALL
   SELECT 8  pk, 'C' fk FROM DUAL UNION ALL
   SELECT 9  pk, 'C' fk FROM DUAL UNION ALL
   SELECT 10 pk, 'D' fk FROM DUAL
)
SELECT pk
  FROM (  SELECT a.*
               , ROW_NUMBER () OVER (PARTITION BY fk ORDER BY DBMS_RANDOM.random) rn
            FROM mydata a
        ORDER BY fk)
 WHERE rn = 1
   AND ROWNUM <= 3  -- this is your N
;

Simply replace the number in the last line of the n you want.

Next time try the solution before giving these answers.

Kind regards.
Al

Tags: Database

Similar Questions

  • Schema import Gets the foreign key number

    Hi all;


    Scott has a table named rank-> he has primary key-> different tablespace

    Sharma has a table named emp-> he has foreign key-> different tablespace

    $ imp/System Manager queue = refresh_sharma.dmp log = refresh_sharma_imp.log fromuser = touser = sharma sharma

    Import: Free 11.2.0.1.0 - Production Thursday, may 7, 18:35:03-2015

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    Export file created by EXPORT: V11.02.00 direct

    import in US7ASCII and AL16UTF16 NCHAR character set

    import server uses WE8MSWIN1252 (possible character set conversion) character set

    Customer export uses the (possible character set conversion) WE8MSWIN1252 character set

    . import of objects in SHARMA SHARMA

    . . import of partition "CONT_EMP": "P1" 4000 imported lines

    . . import of partition "CONT_EMP": "P2" 5000 imported lines

    . . import of partition 'CONT_EMP': 'P3' 5000 imported lines

    . . "DEPT" table import 12 lines imported

    . . import of table 'EMP' 68278 imported lines

    . . importing table "EMP_AUDIT" 4 imported lines

    . . table 'Method' import 68000 lines imported

    . . importing table "EMP_PERS_INFO" 68278 imported lines

    . . importing table "EMP_PROJ_INFO" 68278 imported lines

    . . table 'LOGTAB' import 603 lines imported

    . . table import "PAYROLL" 186282 imported lines

    . . import of table 'of the PROJECT"22 rows imported

    . . importation of "TAB1" 4000000 imported table rows

    . . table import 'TRANSPORT' 0 rows imported

    IMP-00017: statement failed with error ORACLE 1031:

    'ALTER TABLE 'EMP' ADD 'EMP_EMPLEV_C12_FK' OF CONSTRAINT FOREIGN KEY ("EMP_LEVE" '.

    ""L") REFERS TO"SCOTT" CATEGORY"("GRADE_NAME") ENABLE NOVALIDATE.

    IMP-00003: ORACLE error 1031

    ORA-01031: insufficient privileges

    About to activate the constraints...

    IMP-00017: statement failed with error ORACLE 2430:

    ' ALTER TABLE 'EMP' ENABLE CONSTRAINT "EMP_EMPLEV_C12_FK"

    Import completed successfully with warnings.

    30, 31 line number is display error.

    'ALTER TABLE 'EMP' ADD 'EMP_EMPLEV_C12_FK' OF CONSTRAINT FOREIGN KEY ("EMP_LEVE" '.

    ""L") REFERS TO"SCOTT" CATEGORY"("GRADE_NAME") ENABLE NOVALIDATE.

    After the import operation, to recreate the foreign key is the right option. but

    By performing the import operation, how can all I avoid this error dump file or log file?

    I don't want to use constraints = N.


    Thanks in advance


    You gave * of * SCOTT * at * SHARMA.  The grant received by SHARMA not getting exported when you export SHARMA.  So, it is not imported when you import SHARMA.  If you did an export and import of SCOTT before SHARMA, the award of the cross-schema would have also been imported.  (Subsidies granted by a user are exported with the user, the subsidies received by a user are not exported with the user).

    Hemant K Collette

  • foreign key referencing the table in different schema

    I create a foreign key for the table in the schema A a table to diagram B.

    I do that by grant references (column name) on the name of the table to username;


    is there any drawback/disadvantage in the creation of foreign keys referencing tables in another schema?

    Not as such, no.

    Generally, you want to check a second time when you are in this kind of situation that the two tables really belong in different schemas. It should be relatively rare to find a child table that belongs to a different schema than the parent. Sometimes, but it should be an exception, not the rule.

    Justin

  • Primary key and foreign key between the different schemas

    Hi all;

    SCOTT user have a 'rank' of table-> it contains the primary key-> users tablespace

    The U1 user have a 'emp' table-> it contains the foreign key-> test tablespace

    U1 > select constraint_name, constraint_type, r_owner, owner, r_constraint_name of all_constraints where table_name = 'EMP ';

    OWNER CONSTRAINT_NAME C R_OWNER R_CONSTRAINT_NAME

    ------------ ------------------------------ - -------------------------- ----------------------- -----------------------------------------------------

    U1              EMP_EMPLEV_C12_FK R SCOTT GRADE_GRL_C1_PK

    If I have connection U1, no possibility to find the name of the primary key without connection scott table?

    Thank you

    Hello

    So, you want to know what picture of the SCOTT schema has the constraint that is named "GRADE_GRL_C1_PK." Isn't it?

    If so,.

    SELECT table_name

    Of all_constraints

    Owner WHERE = 'SCOTT '.

    AND the argument constraint_name = 'GRADE_GRL_C1_PK. '

    ;

  • Add the foreign key refers to a different schema

    Hello

    We have a database with schemaA and schemaB and we use a data model for schemaA with SQL Data Modeler.

    Our data model is based on SchemaA and we do not want add schemaB or create subview in our current model for schemaB since our dev team do not want schemaB in the model

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    for example. Add ALTER table tableA foreign constraint key(column-name) references tableB(colum-name)

    So far so good.

    But if we try to produce the DDL for tableA it has not provided the ALTAR of the foreign key that is based on shcmeaB

    We know that we cannot add foreign key on dblinks.

    How can I get the Modeler DDL from SQL data for tableA, including the foreign key

    We appreciate the answers

    Kind regards

    Zafar

    Hi zak,.

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    You can do it in the database because TableB exists in the database and DB knows its definition, including the existing constraint of PK/UK.

    This is the same model of data Modeler - you must have the definition of the table referenced in order to create the FK that refer to the constraint of PK/UK.

    As it works now (we can change it) you can have modeled for SchemaA and ModelB for SchemaB. Then, you can drag & drop tableB form the Navigator to the diagram of the ModelA and TableB there will exist as an object remote read-only, you can use to create the FK.

    With the help of subviews, DDL generation and configurations of reports, you can display the dev team than objects that they want to see - on the charts in generated DDL and reports.

    Philippe

  • Question: Is foreign key references to a different column in the same table

    Hello

    I'm not grasp this concept. Would you be able to provide the logic how and why you need to create a foreign key that references a column of the same table?

    For example, referencing the schema, SupervisorNo @ here is a FOREIGN KEY to the "EmpNo" column in the same table.

    EMPLOYEE (EmpNo, title, Fname, Lname, phone, Email, date of birth, sex, salary, HireDate, OutNo, SupervisorNo @)


    Why would you want to do this and how can it be used? If you are filling out the data in the table, and this constraint is enabled, you will not be able to load whatever it is because the "EmpNo" column will be empty.


    Any input you can provide me with this would be greatly appreciated. Thank you!



    His name

    Self-referential integrity constraints

    Lets say that we have the table emp with emp_no and mgr_no columns.

    Now all managers should also be an employee too. How can I check this when inserting data into this table? I applied auto integrity constraint. It would help me to make sure no handler (doesn't mean no mgr_no) must be registered if this Manager is not an employee of this organization. Which means, I won't be able to enter any mgr_no in the column until and unless that the same employee also is an employee (emp_no from the same table).

    Check the link as well below.

    Data integrity

    Thank you

    Ishan

  • Create a foreign key constraint against a different schema

    Hi all

    I use the oracle 10g r2 on windows 2003 server database.

    I have a table in the HRMS as STAFF.
    I have another INVENTORY schema, where I want to access a column as a foreign key in HRMS. STAFF (STAFF_ID).
    connect hrms/hrms@orcl
    grant select on STAFF to INVENTORY;
    connect inventory/inventory@orcl
    alter table inv_details add constraint fk_inv_hr_staff foreign key (staff_id) references HRMS.STAFF(STAFF_ID);
    Error report:
    SQL Error: ORA-00942: table or view does not exist
    00942. 00000 -  "table or view does not exist"
    What exactly I have to grant so this diagram of the INVENTORY will be able to create a referential constraint?

    Kind regards.

    You must also grant the privilege of REFERENCES.

    See privileges in table 18-2 at http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9013.htm#BGBCIIEG

    Hemant K Collette

  • Open different files to workspace with VeriStand API

    Hello, I have a question about the API VeriStand using LabVIEW. LabView is able to open a specific project of VS; now, I mean VS to open the same project file with a file from another workspace (.nivsscreen) similar like the box below, but with the API:

    I want to do this is because I want to open different files, workspace according to the connected equipment.

    Is there an API function to do this?

    Thank you, Michael

    There is not an API to directly modify the screen workspace or ask running workspace to load a particular screen.

    I think going that you can accomplish what you want, leaving to know the definition of deployed system but by program by selecting different workspaces to display via the API. It is a small roundabout and there are a few quirks of cosmetics that I mention below, but it's probably worth a look. I am attaching an example below, you can play.

    The main idea is to create a system definition file, and then create several separate project VeriStand files which all related to the same system definition. You can do this in the dialog box create a new project by selecting the tab system definition to use a definition from existing system rather than create a new one. For each project you create, modify the file to corresponding workspace screens for some display you like.

    Once you have done this, use execution > Workspace screws to deploy by programming the system definition file. It is important that do you rather than deploy the system through the project definition file, as I'll explain below. Then, you can take advantage of the project API screw for programmically load and close projects, as well as launch and close the workspace for this project. To view a particular workspace, just close the current project (if it is open) and load the project associated with this workspace. Then ask this project to open his window to the workspace.

    The key thing to note here is that if a project load and it detects that VeriStand bridge is already linked to its definition of linked system, it will just adopt that opens the connection. In addition, if the project is closed, it will NOT cancel the deployment of this system gateway definition connection, because it doesn't have to deploy it in the first place.

    See the example below. Just unzip all the files in the same folder and open the Automator.vi workspace. Make sure VeriStand is open before you run this VI.

    Known issues: when you switch workspaces in this example, you are in fact a project of closing and opening another. Therefore, the window began to do can do appear briefly.

  • PARTITION BY REFERENCE: ORA-02266 when several relatives of foreign key

    Bubble my problem down to a simple example, imagine providers of satellite TV, their programming packages, their clients and customers linking to packages.  Shouldn't be able to drop all data from a provider in one shot?

    CREATE TABLE suppliers

    (provider_name VARCHAR2 (20) NOT NULL)

    CONSTRAINT providers_pk PRIMARY KEY (nom_de_fournisseur)

    )

    PARTITION BY LIST (provider_name) (PARTITION provider__dflt VALUES (DEFAULT))

    /

    CREATE TABLE programming

    (programming_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT programming_pk PRIMARY KEY (programming_name)

    CONSTRAINT programming_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (programming_fk1)

    /

    Subscribers of CREATE TABLE

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT subscribers_pk PRIMARY KEY (subscriber_name)

    CONSTRAINT subscribers_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (subscribers_fk1)

    /

    CREATE TABLE subscriber_programming

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , programming_name VARCHAR2 (20) NOT NULL

    CONSTRAINT Subscriber_programming_pk

    PRIMARY KEY (subscriber_name, programming_name)

    CONSTRAINT subscriber_programming_fk1 FOREIGN KEY (subscriber_name)

    Subscribers of REFERENCES (subscriber_name)

    CONSTRAINT subscriber_programming_fk2 FOREIGN KEY (programming_name)

    Programming REFERENCES (programming_name)

    )

    PARTITION BY REFERENCE (subscriber_programming_fk1)

    /

    ALTER TABLE SPLIT PARTITION provider__dflt values ("dishnetwork") suppliers

    IN (provider_dishnetwork PARTITION, PARTITION provider__dflt)

    UPDATE INDEX

    /

    INSERT INTO suppliers (provider_name)

    VALUES ("dishnetwork")

    /

    INSERT INTO subscribers (subscriber_name, provider_name)

    VALUES ('john doe', "dishnetwork")

    /

    INSERT INTO programming (programming_name, provider_name)

    VALUES ('top200","dishnetwork")

    /

    ALTER TABLE DROP PARTITION provider_dishnetwork UPDATE INDEX providers

    /

    I have same INSERT in subscriber_programming; the above is sufficient to cause the latter to draw "ORA-02266: unique/primary keys in table referenced by foreign keys enabled". ""  Version information:

    -Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    -With options for partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing

    -Linux 2.6.32 - 279.11.1.el6.x86_64 #1 SMP Sat Sep 22 07:10:26 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

    This simple demo is simply representative of course.  Our number of real paintings ~ 60, with hundreds of millions of records in a large number of tables, a tree FK covering several levels of depth, without the partition littered throughout key.  Given that the volume of data, we try hard to avoid executing DELETE, which is why I explore PARTITION migration BY reference.  The problem is not unlike the already-fixed Bug 9329773, but it is slightly different - especially that this variant is not resolved.  If there is no way that such a facility would never fly, you have any suggestions that would not involve changes to application code?  (For example, adding a partition to the tables key column kids won't fly, but I might be able to sell disabling constraints to developers.)

    After much head striking, I found the trick, by https://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/ .  The difference of Appendix A is bold: the NOVALIDATE on subscriber_programming_fk2 and the EXCHANGE/CREATE/DROP of programming_e.

    CREATE TABLE suppliers

    (provider_name VARCHAR2 (20) NOT NULL)

    CONSTRAINT providers_pk PRIMARY KEY (nom_de_fournisseur)

    )

    PARTITION BY LIST (provider_name) (PARTITION provider__dflt VALUES (DEFAULT))

    /

    CREATE TABLE programming

    (programming_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT programming_pk PRIMARY KEY (programming_name)

    CONSTRAINT programming_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (programming_fk1)

    /

    Subscribers of CREATE TABLE

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT subscribers_pk PRIMARY KEY (subscriber_name)

    CONSTRAINT subscribers_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (subscribers_fk1)

    /

    CREATE TABLE subscriber_programming

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , programming_name VARCHAR2 (20) NOT NULL

    CONSTRAINT Subscriber_programming_pk

    PRIMARY KEY (subscriber_name, programming_name)

    CONSTRAINT subscriber_programming_fk1 FOREIGN KEY (subscriber_name)

    Subscribers of REFERENCES (subscriber_name)

    CONSTRAINT subscriber_programming_fk2 FOREIGN KEY (programming_name)

    Programming (programming_name) NOVALIDATE REFERENCES

    )

    PARTITION BY REFERENCE (subscriber_programming_fk1)

    /

    ALTER TABLE SPLIT PARTITION provider__dflt values ("dishnetwork") suppliers

    IN (provider_dishnetwork PARTITION, PARTITION provider__dflt)

    UPDATE INDEX

    /

    INSERT INTO suppliers (provider_name)

    VALUES ("dishnetwork")

    /

    INSERT INTO subscribers (subscriber_name, provider_name)

    VALUES ('john doe', "dishnetwork")

    /

    INSERT INTO programming (programming_name, provider_name)

    VALUES ('top200","dishnetwork")

    /

    INSERT INTO subscriber_programming (subscriber_name, programming_name)

    VALUES ('john doe', "top200")

    /

    CREATE TABLE programming_e AS

    SELECT * PROGRAMMING WHERE 0 = 1

    /

    ALTER TABLE programming

    Provider_dishnetwork WITH TABLE programming_e SWAP PARTITION

    /

    DROP TABLE programming_e

    /

    ALTER TABLE DROP PARTITION provider_dishnetwork UPDATE INDEX providers

    /

  • Oracle cannot validate the composite foreign key when NULLs comes into play

    Hi all

    When a composite foreign key is used in a schema. Oracle does not check the necessary rules correctly, as indicated below.

    create the table parent_tab
    (
    x int,
    int y,
    z int,
    primary key for constraint p_key (x, y)
    );

    create the table child_tab
    (
    x int,
    int y,
    z int,
    Constraint f_key foreign key (x, y) refers to parent_tab (x, y)
    );

    insert into child_tab (x, y, z) values (1, NULL, 4);
    commit;

    Select count(x|| y) from parent_tab;

    0


    Select count(x|| y) from child_tab;

    1

    Tom Kyte says the following for an explanation.

    The database is unable to validate a foreign key when it is partially null. To assert the rule MATCH FULL for composite foreign keys, you add a constraint to your table:

    The constraint will ensure that either

    • All columns have NULL value in the foreign key, or
    • None of the columns are set to NULL in the foreign key

    As long as this constraint is in place, your foreign key will work as you probably think that it should.

    However, it does not explain WHY? I mean why Oracle is unable to validate the foreign key when it is partially NULL?

    Concerning

    John Spencer wrote:

    He thinks logically.  You have a composite PK of two columns, so 1, 1 is a valid key, as these are the 1, 2 and 1, 3 and 1.42.  In the child table, you have a line 1, the null value.

    What parent should have the child?

    I wish that it would be logical about this. Unfortunately, Oracle applies different rules in different cases. For example, parent of the value 1, NULL value and 1 child, NULL is not the same as NULL is equal or not equal to null. At the same time, one constraint unique index / unique Treaty, 1, NULL, equal to another 1, NULL NULL treatment as being equal to NULL and don't let several lines with 1, the NULL value.

    SY.

  • ODI is not able to detect the primary/foreign keys to XML - the user has no privilege or object not found

    Hi guys,.

    Im trying to load an XML with the address of two entities and employee as below. The topology of reverse engineering, everything works well. Even able to display the xml data in ODI, but when I try to load the data of these two entities join by the schema of the primary keys and foreign keys which created odi engineering process reverses for xml, im im getting the error below.  IM able to load an entity data, error occurs only when I use the join odi creates internally to identify employees for xml and address components

    XML file:

    <? XML version = "1.0" encoding = "UTF-8"? >

    < EMP >

    < Empsch >

    < employee >

    < EmployeeID 12345 > < / EmployeeID >

    < original > t < / initials >

    John < name > < / LastName >

    DOE < FirstName > < / name >

    < / employee >

    < address >

    < > 12345 as WorkPhone < / as WorkPhone >

    < WorkAddress > test 234 < / WorkAddress >

    < / address >

    < / Empsch >

    < / EMP >

    Topology: jdbc:snps:xml?f=C:/Temp/RR/Empsch.xml & s = Empsch & re = EMP & dod = true & nobu = false

    Error message:

    -5501: 42501: java.sql.SQLException: user has no privilege or object not found: EMPSCH. EMPSCHPK

    java.sql.SQLException: user has no privilege or object not found: EMPSCH. EMPSCHPK

    at org.hsqldb.jdbc.Util.sqlException (unknown Source)

    for org.hsqldb.jdbc.JDBCPreparedStatement. < init >(Unknown Source)

    at org.hsqldb.jdbc.JDBCConnection.prepareStatement (unknown Source)

    at com.sunopsis.jdbc.driver.xml.SnpsXmlConnection.prepareStatement(SnpsXmlConnection.java:1232)

    at sun.reflect.GeneratedMethodAccessor65.invoke (unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    to oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$ OnDisconnectCommandExecutionHandler.invoke (OnConnectOnDisconnectDataSourceAdapter.java:200)

    to $Proxy2.prepareStatement (Unknown Source)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.doInitializeStatement(SQLCommand.java:83)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:117)

    at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:111)

    at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:81)

    at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)

    at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:70)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)

    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)

    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)

    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)

    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)

    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)

    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)

    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)

    at java.lang.Thread.run(Thread.java:662)

    Caused by: org.hsqldb.HsqlException: the user has no privilege or object not found: EMPSCH. EMPSCHPK

    at org.hsqldb.error.Error.error (unknown Source)

    at org.hsqldb.ExpressionColumn.checkColumnsResolved (unknown Source)

    at org.hsqldb.QueryExpression.resolve (unknown Source)

    at org.hsqldb.ParserDQL.compileCursorSpecification (unknown Source)

    at org.hsqldb.ParserCommand.compilePart (unknown Source)

    at org.hsqldb.ParserCommand.compileStatement (unknown Source)

    at org.hsqldb.Session.compileStatement (unknown Source)

    at org.hsqldb.StatementManager.compile (unknown Source)

    at org.hsqldb.Session.execute (unknown Source)

    ... more than 27

    Please advice

    Thank you

    Fabien

    It is clear from the content of the xml file, you have given here. In this xml file, you have four type of complex. Two of them are employed and address. However the employee doesnot has nothing to do with the address that you have not added the relationship. That is why its failure. This isn't the fault of the ODI.

    Also I suggest not to use self-generated by ODI dtd that you might face problem in the future. For example, the address of XML type has 8 attributes, and 4 of them are not mandatory. This means that each of your xml file may have attributes between 4 and 8.  That's where ODI auto generated DTD fails.

    ComplexType element XML schema

    Thank you

    Chantal

  • Foreign key, check force

    Hello

    This is the structure of two two table.

    Untitled.png

    DDL:

    CREATE TABLE TEST_PARENT
      (
        PARENT_KEY NUMBER (22),
        PARENT_ID NUMBER (22),
        PARENT_NAME VARCHAR2 (255 CHAR),
        EFFECTIVE_START_DATE DATE DEFAULT sysdate NOT NULL ,
        EFFECTIVE_END_DATE   DATE
      ) ;
    ALTER TABLE TEST_PARENT ADD CONSTRAINT PK_TEST_PARENT PRIMARY KEY ( PARENT_KEY ) ;
    
    
    CREATE TABLE TEST_CHANNEL
      (
    
    
        CHANNEL_KEY NUMBER (22),
        CHANNEL_ID NUMBER (22),
        CHANNEL_NAME VARCHAR2 (255 CHAR),
        EFFECTIVE_START_DATE DATE DEFAULT sysdate NOT NULL ,
        EFFECTIVE_END_DATE   DATE 
      ) ;
    ALTER TABLE TEST_CHANNEL ADD CONSTRAINT PK_TEST_CHANNEL PRIMARY KEY ( CHANNEL_KEY ) ;
    

    Logic:

    Parent_id is always fixed to a Parent. But a Parent can have different attributes (parent_name here). Where the attributes are changing it will end the bu previous records put a value to effective_end_date and it will create a new line. New line will have the PARENT_KEY new PARENT_NAME with new effective_start_date and null in effective_end_date.

    Same logic applies to the CHILD table as well.

    What is the best way to put a reference to the type of the foreign key in the CHILD table that in case, will ensure that a child cannot exist without a parent now. I can't take PARENT_KEY as a foreign key to the same parent can change the PARENT_KEY and a child must always point to the parent ASSET (EFFECTIVE_END_DATE as null) folder.

    Thanks in advance.

    I would enrich your datamodel by tables of the object/version as:

    CREATE TABLE TEST_PARENT_OT
    (
    NUMBER OF PARENT_KEY (22) NOT NULL
    ) ;

    ALTER TABLE TEST_PARENT_OT ADD CONSTRAINT PK_TEST_PARENT_OT PRIMARY KEY (PARENT_KEY);

    CREATE TABLE TEST_PARENT_VT
    (
    NUMBER OF PARENT_KEY (22) NOT NULL,
    NUMBER of VERSION_ID (22) not null,
    PARENT_NAME VARCHAR2 (255 CHAR),
    EFFECTIVE_START_DATE DATE default sysdate NOT NULL,
    DATE OF EFFECTIVE_END_DATE
    ) ;

    ALTER TABLE TEST_PARENT_VT ADD CONSTRAINT PK_TEST_PARENT_VT PRIMARY KEY (PARENT_KEY, VERSION_ID);
    ALTER TABLE TEST_PARENT_VT add CONSTRAINT FK_PARENT_VT_PARENT_OT foreign key (parent_key) refers to test_parent_ot (parent_key);

    CREATE TABLE TEST_CHANNEL_OT
    (
    NUMBER OF CHANNEL_KEY (22) NOT NULL
    ) ;

    ALTER TABLE TEST_CHANNEL_OT ADD CONSTRAINT PK_TEST_CHANNEL_OT PRIMARY KEY (CHANNEL_KEY);

    CREATE TABLE TEST_CHANNEL_VT
    (
    NUMBER OF CHANNEL_KEY (22) NOT NULL,
    NUMBER OF VERSION_ID (22) NOT NULL,
    PARENT_KEY NUMBER (22) NOT NULL,
    CHANNEL_NAME VARCHAR2 (255 CHAR),
    EFFECTIVE_START_DATE DATE default sysdate NOT NULL,
    DATE OF EFFECTIVE_END_DATE
    ) ;

    ALTER TABLE TEST_CHANNEL_VT ADD CONSTRAINT PK_TEST_CHANNEL_VT PRIMARY KEY (CHANNEL_KEY, VERSION_ID);
    ALTER TABLE TEST_CHANNEL_VT add CONSTRAINT FK_CHANNEL_VT_CHANNEL_OT FOREIGN KEY (channel_key) REFERENCES TEST_CHANNEL_OT (channel_key);
    ALTER TABLE TEST_CHANNEL_VT add CONSTRAINT FK_CHANNEL_VT_PARENT_OT FOREIGN KEY (PARENT_key) REFERENCES test_parent_ot (parrent_key);

    Using this you will not have to reallocate your child of the lines when a new version of parent is created and you will be able to have the independent channel versions of the parent versions (so no need to change all the children when the parents ends).

    the construction of views of parents and the channels which only show active lines.

    The problem you may have is to be sure to have for each point in time an active version and so I would not implement of an effective_end date, but inherit the effective end of the effective next to (which is a little more work but you will help gapelessness if necessary)

    HTH

  • foreign key 'generate' strange behavior check box, any idea?

    Summary: in the properties of the table, the foreign keys, the box generate behaves badly, and I don't understand why or how I got there.

    Oracle Data Modeler 4.0.2.840 8.1 X 64 Windows, jdk1.7.0_55

    the behavior is:

    (1) add the foreign key (two different more to see strange behavior)

    (2) uncheck 'generate' on a foreign key

    (3) apply, Ok

    (4) ask 'Preview DDL', a foreign key constraint is generated, SO FAR SO GOOD, I'm happy

    5-now click on the button 'generate the DDL' for any design = > * * TWO foreign keys are generated?

    (6) even more strange: sometimes the 'generate' check itself after step 5, most of the time is not

    (7) at the beginning this has occurred for a couple of foreign key 'uncheckees', now it almost always happens.

    The relational model was built by importing the SQL scripts already exist (try to migrate the Data Modeler). No too complex ~ 115 tables, 12 times.

    I think it's a bug, but I can't find any reference on the web, maybe I do something wrong?

    Hi Michel,.

    The generation is different depending on whether or not the relevant storage design is open.

    If the design of the storage is not open, the option "Generate DDL" on the foreign key is taken into account (for an overview of the DDL or full generation of DDL).  For an entire generation of DDL, the foreign key will initially not selected phase in the generation of the DDL if Options the option "Generate DDL" on the foreign key has been disabled.  (This change in the phase of the generation of DDL Options will also cause the option "Generate DDL" on the foreign key update.)

    If the design of the storage is open, the option 'generate DDL"on the foreign key has no effect (in a Preview of DDL or full DDL generation).

    Also in a generation full of DDL, an object will be initially marked as not selected if it has been disabled in the previous generation of DDL.

    I hope that this helps to explain the behavior that you find.

    David

  • First database with Oracle 12 c and Entity Framework 5: no foreign key in the EMD Associations

    We have an updated database implemented in Oracle 12 c R1. When attempting to reverse engineer the EMD of the DB using Visual Studio 2013 with ODAC 12 c Release 2 and Oracle developer Tools support all we get are entities with no association, despite multiple foreign keys defined in the database. There, of course, no navigation property in both entities. No error or warning messages are displayed and activate us the option "include foreign keys in the model columns.

    Does anyone have any idea why this might happen?

    If you use files PDB (pluggable database), there is a known bug (17474322) to generate an EDM with foreign keys in a PDB file. This is probably the question you are running in.

  • Optimize the foreign key for the removal of the cascade constraint.

    Hello

    JDeveloper version: 11.1.2.3.0

    I saw this blog and found something new to me: http://snag.gy/qI6dY.jpg

    Jdeveloper user interface, there is an option to select all tables to select the foreign key and set it for the removal of the waterfall.

    My project is deployed on multiple databases. I wonder where this change is registered. None of the project files is modified.

    Can I make this change (from limitations to the waterfall) for each database that I use?

    Here is the blog where I saw that: http://tompeez.wordpress.com/2013/04/22/master-detail-insertdelete-sample/

    I have my object associations optimized for the removal of the waterfall, but without the option above together, I always get constraint violations...

    Concerning

    Not sure however if you set the option the DOF looks like

    "EMP_JOB_FK' FOREIGN KEY ('JOB_ID') CONSTRAINT
    REFERENCES 'HR '. "" SELECT JOBS "("JOB_ID') WE DELETE CASCADE

    If you set the option to cascade for fk Job_id from the employees table.

    Timo

Maybe you are looking for