a constraint many

Thank you in advance.

I have a table below:

CREATE THE TABLE ACCTMGMT. TES_ANTIUNIQUE

(

SUPERVISOR, VARCHAR2 (10 BYTE),

COLLECTOR VARCHAR2 (10 BYTE),

VARCHAR2 (10 BYTE) COMMENTS

)

and I want to insert these records:

INSERT INTO ACCTMGMT. THE VALUES OF TES_ANTIUNIQUE ('SPV HAS ',' COLL 1', 'OK');

INSERT INTO ACCTMGMT. THE VALUES OF TES_ANTIUNIQUE ('SPV HAS ',' COLL 2', 'OK');

INSERT INTO ACCTMGMT. THE VALUES OF TES_ANTIUNIQUE ('SPV X ',' COLL 1', 'NOT GOOD');

A collector can have exactly a supervisor. A supervisor may have more than one collector.

Instead of relaxing, can we use another constraint for this one of many relationships?

Best regards

IB

Hello Indra,

Why don't you have collector and supervisor on different tables and primary key relationships?

S.Balraj

Tags: Database

Similar Questions

  • Dashboard quickly too many values of constraint

    I have a requirement where the user wants to select among the thousands of available records. When you create a dashboard prompt that it takes only 250 values and remaining wrote too many values.

    My question is why you would build a prompt with the values a lot? I know you said the 'user wants', but sometimes you have to educate the (and when I say 'them' several times, it's a few loud people who just shout the loudest and so achieve their ends) that what they want isn't always the best. I think that it is virtually impossible to have to sift through thousands of values to find the one you want.

    However, if the values are to be given, I would recommend penetrate blocked guests indicating on the label invited a range of values, so that each of them has a 'reasonable' values list and the user can directly access which "invites the high-end" will contain the value he wants.

  • How many pictures can manage the Photos app?

    I ~ 130 000 photos.  What is the maximum number of pictures that can handle the Photos app?

    I've seen it has not documented Max - iPhoto and Aperture could run 1 000 000 so I don't know that photos can manage many - basically, the answer is more that you have and you are limited by disk space not the constraints of program

    LN

  • REF. order. give the constraint when built in table

    I have a front face with (IMO) too many controls. To help cope with all of them, I build an arrary of references I can index or move to submarines. However, I noticed that each Ref control produces a point constraint when building them in a table. Two questions:

    (1) is there a way to avoid this? and

    (2) otherwise, it will cause problems later if I will try to find a specific comparing to the other refs of control?

    (1) none

    (2) Yes (maybe)

    All the elements in an array can differ only by their value. The point of constraint tells you that these references are cast from a generic type. If you rely on the ref is a specific type, then you can run in question.

    Rather than building a table, I suggest the creation of a cluster (def of type a) with the appropriate Ref types. This makes my development because I can't count to find a ref, I can just take in a list (ungroup by name).

    Just trying to help,

    Ben

  • Many many order of VALIDATION

    Hello

    JDev 11.1.2.4

    I'm trying to create a number insert many relationships. My model has a * to * the association between A and B EOs. I also have the link display based on this association.

    In the AM, I exposed A and B your using the VL and also the VO ABIntersection.

    My AM:

    A

    --> B

    ABIntersection

    In the AM, I create 3 objects A, B and ABIntersection. The AM method is called from a managed bean. The code is essentially

    AViewImpl a = this.getAViewImpl ();

    a.createRow ();

    Set the attribute for A

    BViewImpl b = this.getBViewImpl ();

    b.createRow ();

    Set the attribute required for B

    ABIntersectionViewImpl ab = this.getABIntersectionViewImpl ();

    ab.setAId (a.getId ());

    ab.setBId (b.getId ());

    Validation is called. In the paper, I see an INSERT IN A then an INSERT IN AB. It fails because of the constraint of integrity which is normal because the line B is unknown.

    < OracleSQLBuilderImpl > < doEntityDML > OracleSQLBuilderImpl.doEntityDML [6725] failed...

    < OracleSQLBuilderImpl > < doEntityDML > [6726] X / Open SQL State is: 23000

    java.sql.SQLIntegrityConstraintViolationException < OracleSQLBuilderImpl > < doEntityDML > [6727]: ORA-02291: integrity (AB_FK) violated constraint - found parent key

    This works if the validation done INSERTs in this order A then B then the AB. Is there a way to put the order?

    Thank you

    Hello

    I hope this helps.

    Liu Wuhua technology and learning of Notes: insert master / detail in ADF BC

    Best regards

    Jagadeesh Badri

  • Strange error when adding constraints

    Hi friends

    We are oracle runing 11.2.0.3.0, windows server.

    Only we don't have any problems on the 'source' scheme, which has been exported and imported to a new schema using DataPump and remap_schema. The same error occurs when using exp.exe

    Gives this error when adding some constraints, but not all, the Oracle returns a failure statemente:

    ORA-31685:object REF_CONSTRAINT type: NEW_SCHEMA. NOTE_ITEM_FK failed due to insufficient privileges. In the absence of sql is:

    ALTER TABLE NEW_SCHEMA. NOTE_ITEM_FINAL ADD CONSTRAINT NOTE_ITEM_FK FOREIGN KEY (CODID) REFERENCES NOTE ENABLE (ID)

    But I'm the owner of the table user, I DBA and all other privileges. We often but suddenly got this erros.

    Any idea?

    I have REFERENCES of the concession and many other roles and privileges at the trial, but nothing has worked.

    If I run the command via SQLPlus it returns me

    ORA-00604: an error occurred at recursive SQL level 1

    ORA-01031: insufficient privileges

    But I'm not referring to any other table schema, just mine.

    TKS a lot

    Well

    I found a solution

    RENAME TABLE to aaa_bkp aaa

    CREATE TABLE AS SELECT aaa * of aaa_bkp

    Re-create all triggers and constraints.

    It is, I think it was a good work around

    TKS all

  • CONSTRAINT to CHANGE DISABLE VALIDATE pk

    Sorry for the questions.

    However, I'm on my way to the OCP and face many new aspects.

    If I have pk CONSTRAINT to EDIT, DISABLE VALIDATE no LMD is possible I read into Oracle concepts.

    It makes sense, because the data in the table are validated and no insert with unchecked data should happen.

    However, sql loader runs that I discovered. How does this work?

    Loader "inserts" the data in the table? And can sql loader put (non-unique) "invalid" data in the table?

    Concerning

    Christian

    SQL Loader also supports Direct path loading that is different from the classic SQL INSERT statement

    Officers Direct and conventional

  • Discover many-to-many

    How can I make the following view?

    Thank you very much.

    Participation of students in the meetings.

    Students = John, Mary (more students may be added)

    Meetings = 1, 2, 3 (more meetings may be added)

    Participation = 0/1 (absent/present).

    __________________________________________

    View

    Meeting 1 meeting 2 3

    John 1 1 0

    Mary 1 0 [null]

    __________________________________________

    Here's the diagram:

    -Student-Meeting-to-many

    drop student table constraints waterfall;

    drop table meeting cascade constraints;

    drop table student_meeting cascade constraints;

    create table students

    (

    primary key not null ID number,

    name varchar2 (80)

    );

    create table meeting

    (

    primary key not null ID number,

    date of meeting_date

    );

    create the table student_meeting

    (

    primary key not null ID number,

    student_id number of non-null reference student (id),

    meeting_id number of non-null reference meeting (id),

    unique (student_id, meeting_id).

    attendance char(1),

    check (presence in ('0 ', ' 1'))

    );

    insert into values student (11, 'John');

    insert into values student (12, 'Mary');

    Insert in the encounter of the values (1, '' 2014-01-05);

    insert into values of meeting (date 2, '' 2014-01-15).

    Insert in meeting values (3, '' 2014-01-25).

    -The presence of John

    insert into student_meeting values (101, 11, 1, '1');

    insert into student_meeting values (102, 11, 2, '1');

    insert into student_meeting values (103, 11, 3, '0');

    -Participation to Marie (no session value 3 attendance still inserted)

    insert into student_meeting values (104, 12, 1, '1');

    insert into student_meeting values (105, 12, 2, '0');

    commit;


    Hello

    When you have 1 column on several lines, and you want to display it in the form of multiple columns on 1 row, this is called pivoting.

    The forum FAQ has a page on swivel:

    https://forums.Oracle.com/message/9362005#9362005

  • Cascading list of values with a many-to-many relationship

    Hi all

    I have three paintings; semester, subject and half of subject. Each semester has a lot of topics and a subject can be taught in several semesters.

    create table semester(
         id number not null,
         name varchar2(50) not null,
         primary key(id)
    );
    create table subject(
         id number not null,
         name varchar2(50) not not null,
         primary key(id)
    );
    create table semester_subject(
         id number not null,
         semester_id number not null,
         subject_id number not null,
         primary key(id),
         foreign key(semester_id) references semester(id),
         foreign key(subject_id) references subject(id),
         constraint semester_subject_uq unique(semester_id, subject_id)
    );
    
    

    EDIT: I have a page with a report that shows all students who are currently enrolled in the selected for the selected session object.

    There are two selection lists at the top of the report, one for the half and the other for the subject.

    What I try to do is when you select a semester in the half selection list, the topic selection list should contain only the subjects for the half of some (not all) in the subject of the painting.

    h

    If the relationship was of 1 to many that I could write to see half of value

    select name, id
    from semester
    order by 1
    
    

    and for the purpose of value list

    select name, id
    from subject
    where semester_id = :PX_SEMESTER
    
    

    But now that the relationship depends on the table of semester_subject, I can't find a way to achieve this and Googling has not helped.

    Thanks in advance for any help.

    I believe that this issue has also been implemented on stack overflow plsql - list of values cascading with many-to-many relationship - stack overflow and received a very wide response. If the OP has not yet verified, he may want to.

    (FYI: I'm not the person who answered there.)

  • Error in many many examples of relationship

    I'm a newbie very to ATG. I started reading the guide ATGRepository and practice with simple examples. I came across the subject many-to-many relationship Page no. 42. When I try to run the example, I get the following error

    java.lang.IllegalArgumentException: attempted to set property named degrees (employee: employee: 200001) whose value = [50001, 50002] (class = class java.util.HashSet).  This property failed due to a specific event of the type of property.  Turn on loggingDebug for more details.

    atg.repository.RepositoryItemImpl.setPropertyValue(RepositoryItemImpl.java:237)

    atg.adapter.gsa.GSAItem.setPropertyValue(GSAItem.java:1536)

    com.learn.EmployeeFormHandler.updateItem(EmployeeFormHandler.java:100)

    com.learn.EmployeeFormHandler.handleUpdateUser(EmployeeFormHandler.java:50)

    sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    java.lang.reflect.Method.invoke(Method.java:601)

    atg.droplet.EventSender.sendEvent(EventSender.java:639)

    atg.droplet.FormTag.doSendEvents(FormTag.java:823)

    atg.droplet.FormTag.sendEvents(FormTag.java:671)

    atg.droplet.DropletEventServlet.sendEvents(DropletEventServlet.java:614)

    atg.droplet.DropletEventServlet.service(DropletEventServlet.java:642)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:150)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:213)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:696)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2447)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.userprofiling.PageEventTriggerPipelineServlet.service(PageEventTriggerPipelineServlet.java:191)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.multisite.SiteSessionEventTriggerPipelineServlet.service(SiteSessionEventTriggerPipelineServlet.java:161)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.userprofiling.SessionEventTrigger.service(SessionEventTrigger.java:512)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.userprofiling.ProfilePropertyServlet.service(ProfilePropertyServlet.java:230)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.userprofiling.ProfileRequestServlet.service(ProfileRequestServlet.java:460)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.pipeline.DynamoPipelineServlet.service(DynamoPipelineServlet.java:491)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.pipeline.URLArgumentPipelineServlet.service(URLArgumentPipelineServlet.java:302)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.pipeline.PathAuthenticationPipelineServlet.service(PathAuthenticationPipelineServlet.java:392)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.security.ThreadUserBinderServlet.service(ThreadUserBinderServlet.java:113)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.dtm.TransactionPipelineServlet.service(TransactionPipelineServlet.java:234)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.pipeline.SecurityServlet.service(SecurityServlet.java:191)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.multisite.SiteContextPipelineServlet.service(SiteContextPipelineServlet.java:370)

    atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)

    atg.servlet.pipeline.HeadPipelineServlet.passRequest(HeadPipelineServlet.java:1224)

    atg.servlet.pipeline.HeadPipelineServlet.service(HeadPipelineServlet.java:910)

    atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:272)

    atg.filter.dspjsp.PageFilter.innerDoFilter(PageFilter.java:349)

    atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:208)

    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    My point descriptor

    < name point-descriptor = "employee" cache-mode = "simple" default = "true" >

    < table name = "employee" id-column-name = "id" type = "primary" >

    < property name = data type 'id' = 'chain' queryable = "true" / >

    < property column-name = "FirstName" name = "FirstName" data type = 'string' queryable = "true" / >

    < property column-name = "last_name" name = 'name' data type = 'string' queryable = "true" / >

    < /table >

    < table name = "employee_education" id-column-names = "employe_id" type = "multi" >

    < property column-name = "degree_id" name = "degrees" of data type = "dΘfinir" component-type of item = 'education' queryable = "true" / >

    < /table >

    < / descriptor point >

    < name point-descriptor = "education" cache-mode 'simple' = >

    < table name = 'education' id-column-name = "id" type = "primary" >

    < property name = data type 'id' = 'chain' queryable = "true" / >

    < data type property column-name = "degree_name" name = "degreeName" = 'chain' queryable = "true" / >

    < /table >

    < table name = "employee_education" id-column-names = "degree_id" type = "multi" >

    < property column-name = "employe_id" name = "employees" data type = "dΘfinir" component-type of item = "employee" queryable = "true" / >

    < /table >

    < / descriptor point >

    The database script is

    CREATE TABLE IF NOT EXISTS 'mydb '. "employee")

    'id' VARCHAR (40) NOT NULL,

    "first_name" NULL VARCHAR (45).

    "last_name", NULL VARCHAR (45).

    PRIMARY KEY ('id'))

    ENGINE type = InnoDB;

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

    -Table 'mydb '. 'education '.

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

    CREATE TABLE IF NOT EXISTS 'mydb '. 'education')

    'employe_id' VARCHAR (40) NOT NULL,

    'degree_id' VARCHAR (45) NOT NULL,

    PRIMARY KEY ('employe_id', 'degree_id'))

    ENGINE type = InnoDB;

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

    -Table 'mydb '. 'employee_education '.

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

    CREATE TABLE IF NOT EXISTS 'mydb '. "employee_education")

    'employe_id' VARCHAR (40) NOT NULL,

    'degree_id' VARCHAR (40) NOT NULL,

    PRIMARY KEY ('employe_id', 'degree_id'),

    CONSTRAINT 'fk_degree_id '.

    (FOREIGN KEY)

    REFERENCES 'mydb '. 'education')

    ON DELETE NO ACTION

    ON UPDATE NO ACTION.

    CONSTRAINT 'fk_employee_id '.

    (FOREIGN KEY)

    REFERENCES 'mydb '. "employee")

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

    ENGINE type = InnoDB;

    Java code insert record is

    try {}

    Repository employeeRepo = getEmployeeRepo();

    MutableRepository mutableEmployeeRepo = (MutableRepository) employeeRepo;

    MutableRepositoryItem mutableEmployeeRepoItem = mutableEmployeeRepo.createItem (getItemDescriptor ());

    mutableEmployeeRepoItem.setPropertyValue ("firstName", getFirstName());

    mutableEmployeeRepoItem.setPropertyValue ("lastName", getLastName());

    int degreeLength = getDegrees () .length;

    If (degreeLength! = 0) {}

    < String > degreeList value = new HashSet (<>);

    String [] degreeArr = getDegrees();

    for (int i = 0; i < degreeLength; i ++) {}

    degreeList.add (degreeArr [i]);

    }

    mutableEmployeeRepoItem.setPropertyValue ('degrees', degreeList);

    }

    RepositoryItem addedItem = (mutableEmployeeRepoItem) mutableEmployeeRepo.addItem;

    }

    {} catch (e RepositoryException)

    System.out.println ("Exception occurred." + e.getMessage ());

    }

    Thank you.

    The degrees has the value of the education.

    If you code should be replaced with:

    If (degreeLength! = 0) {}

    DegreeList value = new HashSet();

    String [] degreeArr = getDegrees();

    for (int i = 0; i)< degreelength;="" i++)="">

    MutableRepositoryItem mutableEducationRepoItem = mutableEmployeeRepo.createItem ("education");

    mutableEducationRepoItem.setPropertyValue ("degreeName", degreeArr [i]);

    degreeList.add (mutableEducationRepoItem);

    }

    mutableEmployeeRepoItem.setPropertyValue ('degrees', degreeList);

    }

    RepositoryItem addedItem = (mutableEmployeeRepoItem) mutableEmployeeRepo.addItem;

    }

    Peace

    Shaik

  • How to apply the constraint ONLY to new lines

    Hi, gurus:

    I have a question as follows:

    We need to migrate a legacy to a new production server system. I have to add two columns from each table to record that updates the row most recently through triggers, and I must ask constraint not null for columns. However, since the old system has already given for each table and old data have no value for 2 new columns. If we apply the constraint, all existing lines throws an exception. I wonder if there is possibility to apply the ONLY constraint to the new lines coming in the future.

    Thank you.

    Sam

    We need to migrate a legacy to a new production server system. I have to add two columns from each table to record that updates the row most recently through triggers, and I must ask constraint not null for columns.

    The best suggestion I can give you is that you ensure that the management of the documents on behalf of the person who came up with this requirement of brain hair so they can sufficiently punished for the huge waste of human and database resources they have caused for which they almost NOTHING got in return in the future.

    I've seen many systems over the past 25 years + who have added columns such as: CREATED_DATE, CREATED_BY, MODIFIED_DATE MODIFIED_BY.

    I have yet to see a system where this information is really useful for any real purpose. Many systems have the users/application schema, and users can change the data. In addition, a DBA can modify the data, and many of them can connect as long as the schema owner to do.

    Many tables also updated by other applications or processes of loading of bulk and these processes use generic connections that cannot be attached to any particular system.

    The net result is that these columns will be filled by user names that are completely useless for verification purposes.

    If a user is allowed to edit a table, they are allowed to modify a table. If you want to track that you need to implement a security strategy appropriate using the functionality of Oracle's AUDIT.

    Encumber ALL or even many of your tables with columns is a very BAD idea. Worse is the addition of doesn't trigger this server no other goal but captures the useless information, but because they are the impacts on performance just PL/SQL cause worse the total impact.

    Must certainly be to worry about security and auditability of your important data. But by adding columns and triggers, such as those proposed is NOT the right solution to achieve this security.

    Before your organization any decision so stupid you should propose that the same steps before adding this feature you should take before the addition of ANY structural MAJOR or the application:

    1. document the real need

    2 document and justify the business reasons for this need

    3. perform tests that shows the impact of this requirement on the production system

    4. determine the cost of the resources (people, storage, etc.) to implement this requirement

    5 demonstrate how this information will actually be used EFFECTIVELY for professional purposes

    With regard to points #1 and #2 above that the requirement should be noted with regard to the PROBLEM to be solved, not a some preconceived notion of the solution that should be used.

    Your org should also speak to other associations or other departments in your org even who have used your proposed solution and discover how useful it was for them. If you do this research, you may find it has not responded to their needs at all.

    And in your own org, there are probably some applications with tables that already have such columns. Has anyone here EVER used these columns and found them invaluable to identify and solve any real problems?

    If you can't use them and why first add their data to some important process?

    IMHO, this is a total waste of time and resources to add columns in your tables. Any such audit or security, at least, approach will be limited to those tables with key data that needs to be protected, and then only when you cannot implement the appropriate audit "best practices".

    A migration is hard enough without adding unnecessary additional expenses such as those. You have MUCH more important you can do with the resources that you have:

    1. capture all THE DDL for the existing system in a version control system

    2. train your developers on the use of the version control system

    3. determine the correct configuration of the new server and the system. It's almost a CERTAINTY that parameters will change and performance will suffer even if you don't think you have changed anything at all.

    4. validate that the data was migrated correctly. Which may involve a broad polling and comparison to make sure that the data has not been altered during migration. The validation process to a SINGLE TABLE is more difficult if the table structures are not the same. And they will not if you add two columns in each table; every single request, you do have to specify the columns by name in order to EXCLUDE from your two new columns.

    5. validate the performance of the app on the new system. He there will HAVE problems where things do not work as they did. You need to find these problems and fix them

    6 capture appropriate statistics after that data has been migrated and all indexes have been rebuilt.

    7 enter the new implementation plans to use a base for when things go wrong in the future.

    If it's worth doing is worth doing right.

  • Stars marks the beginning or the end date without affecting a primary constraint

    I'm working on 4 project consists of some 225 thousands of activities on p6v7 Primavera. All four EPC and supply projects are interconnected. I get the mark of the Star (*) at the start or end date without affecting any primary obligation. These activities are logically follow constraints also gives no relevant dates and negative float. I cannot import excel sheet too make any changes to my projects, it shows memory. Can someone confirm how many activities takes in charge the Primavera? There is no filter at the level of the WBS code, I need to put the filter at the level of the WBS code so that I could see that the activities that fall within these WBS. The UDF, I defined at the level of WBS code also not shown to global, how WBS UDF activity? I want to glue the print screen on this forum but impossible...

    Hello

    In P6 client, there is no filter available for view of WBS, so you play with the filters of activity only according to your needs...

    And change overall WBS UDF feature isn't available in client P6... If you can not any calculation or changes...

    What are all the limitations of primavera P6 customer.

    See you soon...

  • Creating a unique index frame on a one-to-many table and search

    Hello

    I was properly put in place of the full text index on multiple columns on the same table (using the MULTI_COLUMN_DATASTORE preferences), but now I have a situation with a table of one-to-many data collection (with a CF of a lookup table), and I need to get columns through two of these tables. Code example below, several of my chatter after the code block:
    CREATE TABLE SUBMISSION
    ( SUBMISSION_ID             NUMBER(10)          NOT NULL,
      SUBMISSION_NAME           VARCHAR2(100)       NOT NULL
    );
     
    CREATE TABLE ADVISOR_TYPE
    ( ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
      ADVISOR_TYPE_NAME         VARCHAR2(50)        NOT NULL
    );
      
    CREATE TABLE SUBMISSION_ADVISORS
    ( SUBMISSION_ADVISORS_ID    NUMBER(10)          NOT NULL,
      SUBMISSION_ID             NUMBER(10)          NOT NULL,
      ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
      FIRST_NAME                VARCHAR(50)         NULL,
      LAST_NAME                 VARCHAR(50)         NULL,
      SUFFIX                    VARCHAR(20)         NULL
    );
    
    INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (1, 'Some Research Paper');
    INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (2, 'Thesis on 17th Century Weather Patterns');
    INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (3, 'Statistical Analysis on Sunny Days in March');
    
    INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (1, 'Department Chair');
    INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (2, 'Department Co-Chair');
    INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (3, 'Professor');
    INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (4, 'Associate Professor');
    INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (5, 'Scientist');
    
    INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (1,1,2,'John', 'Doe', 'PhD');
    INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (2,1,2,'Jane', 'Doe', 'PhD');
    INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (3,2,3,'Johan', 'Smith', NULL);
    INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (4,2,4,'Magnus', 'Jackson', 'MS');
    INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (5,3,5,'Williard', 'Forsberg', 'AMS');
     
    COMMIT;
    I want to be able to create a text index to group these fields:

    SUBMISSION_ADVISORS. FIRST NAME
    SUBMISSION_ADVISORS. LAST_NAME
    SUBMISSION_ADVISORS. SUFFIX
    ADVISOR_TYPE. ADVISOR_TYPE_NAME

    I looked at DETAIL_DATASTORE and USER_DATASTORE, but examples of Oracle Docs for DETAIL_DATASTORE leave me a little confused. It seems that this should be fairly simple.

    Ideally, I try to avoid creating new columns and keeping a minimum shutter adjustments. But I'm open to any suggestion. Thanks for your time and your thoughts.

    -Jamie

    I would create a procedure that creates a virtual with labels document, what is the multi_column_datatstore behind the scenes. Then I would like to use this procedure in a user_datastore, so the result is the same for several tables as a multi_column_datastore for a table. I would use auto_section_group or another type of Group of sections, so that you can search from WITHIN as with the multi_column_datastore. Please see the demo below.

    SCOTT@orcl_11gR2> -- tables and data that you provided:
    SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION
      2  ( SUBMISSION_ID           NUMBER(10)          NOT NULL,
      3    SUBMISSION_NAME           VARCHAR2(100)          NOT NULL
      4  )
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> CREATE TABLE ADVISOR_TYPE
      2  ( ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
      3    ADVISOR_TYPE_NAME      VARCHAR2(50)          NOT NULL
      4  )
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION_ADVISORS
      2  ( SUBMISSION_ADVISORS_ID      NUMBER(10)          NOT NULL,
      3    SUBMISSION_ID           NUMBER(10)          NOT NULL,
      4    ADVISOR_TYPE_ID           NUMBER(10)          NOT NULL,
      5    FIRST_NAME           VARCHAR(50)          NULL,
      6    LAST_NAME           VARCHAR(50)          NULL,
      7    SUFFIX                VARCHAR(20)          NULL
      8  )
      9  /
    
    Table created.
    
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
      3    VALUES (1, 'Some Research Paper')
      4  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
      5    VALUES (2, 'Thesis on 17th Century Weather Patterns')
      6  INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
      7    VALUES (3, 'Statistical Analysis on Sunny Days in March')
      8  SELECT * FROM DUAL
      9  /
    
    3 rows created.
    
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
      3    VALUES (1, 'Department Chair')
      4  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
      5    VALUES (2, 'Department Co-Chair')
      6  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
      7    VALUES (3, 'Professor')
      8  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
      9    VALUES (4, 'Associate Professor')
     10  INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
     11    VALUES (5, 'Scientist')
     12  SELECT * FROM DUAL
     13  /
    
    5 rows created.
    
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
      3    VALUES (1,1,2,'John', 'Doe', 'PhD')
      4  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
      5    VALUES (2,1,2,'Jane', 'Doe', 'PhD')
      6  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
      7    VALUES (3,2,3,'Johan', 'Smith', NULL)
      8  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
      9    VALUES (4,2,4,'Magnus', 'Jackson', 'MS')
     10  INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
     11    VALUES (5,3,5,'Williard', 'Forsberg', 'AMS')
     12  SELECT * FROM DUAL
     13  /
    
    5 rows created.
    
    SCOTT@orcl_11gR2> -- constraints presumed based on your description:
    SCOTT@orcl_11gR2> ALTER TABLE submission ADD CONSTRAINT submission_id_pk
      2    PRIMARY KEY (submission_id)
      3  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> ALTER TABLE advisor_type ADD CONSTRAINT advisor_type_id_pk
      2    PRIMARY KEY (advisor_type_id)
      3  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_advisors_id_pk
      2    PRIMARY KEY (submission_advisors_id)
      3  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_id_fk
      2    FOREIGN KEY (submission_id) REFERENCES submission (submission_id)
      3  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT advisor_type_id_fk
      2    FOREIGN KEY (advisor_type_id) REFERENCES advisor_type (advisor_type_id)
      3  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> -- resulting data:
    SCOTT@orcl_11gR2> COLUMN submission_name FORMAT A45
    SCOTT@orcl_11gR2> COLUMN advisor      FORMAT A40
    SCOTT@orcl_11gR2> SELECT s.submission_name,
      2           a.advisor_type_name || ' ' ||
      3           sa.first_name || ' ' ||
      4           sa.last_name || ' ' ||
      5           sa.suffix AS advisor
      6  FROM   submission_advisors sa,
      7           submission s,
      8           advisor_type a
      9  WHERE  sa.advisor_type_id = a.advisor_type_id
     10  AND    sa.submission_id = s.submission_id
     11  /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Some Research Paper                           Department Co-Chair John Doe PhD
    Some Research Paper                           Department Co-Chair Jane Doe PhD
    Thesis on 17th Century Weather Patterns       Professor Johan Smith
    Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
    Statistical Analysis on Sunny Days in March   Scientist Williard Forsberg AMS
    
    5 rows selected.
    
    SCOTT@orcl_11gR2> -- procedure to create virtual documents:
    SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE submission_advisors_proc
      2    (p_rowid IN           ROWID,
      3       p_clob     IN OUT NOCOPY CLOB)
      4  AS
      5  BEGIN
      6    FOR r1 IN
      7        (SELECT *
      8         FROM      submission_advisors
      9         WHERE  ROWID = p_rowid)
     10    LOOP
     11        IF r1.first_name IS NOT NULL THEN
     12          DBMS_LOB.WRITEAPPEND (p_clob, 12, '');
     13          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.first_name), r1.first_name);
     14          DBMS_LOB.WRITEAPPEND (p_clob, 13, '');
     15        END IF;
     16        IF r1.last_name IS NOT NULL THEN
     17          DBMS_LOB.WRITEAPPEND (p_clob, 11, '');
     18          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.last_name), r1.last_name);
     19          DBMS_LOB.WRITEAPPEND (p_clob, 12, '');
     20        END IF;
     21        IF r1.suffix IS NOT NULL THEN
     22          DBMS_LOB.WRITEAPPEND (p_clob, 8, '');
     23          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.suffix), r1.suffix);
     24          DBMS_LOB.WRITEAPPEND (p_clob, 9, '');
     25        END IF;
     26        FOR r2 IN
     27          (SELECT *
     28           FROM   submission
     29           WHERE  submission_id = r1.submission_id)
     30        LOOP
     31          DBMS_LOB.WRITEAPPEND (p_clob, 17, '');
     32          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r2.submission_name), r2.submission_name);
     33          DBMS_LOB.WRITEAPPEND (p_clob, 18, '');
     34        END LOOP;
     35        FOR r3 IN
     36          (SELECT *
     37           FROM   advisor_type
     38           WHERE  advisor_type_id = r1.advisor_type_id)
     39        LOOP
     40          DBMS_LOB.WRITEAPPEND (p_clob, 19, '');
     41          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r3.advisor_type_name), r3.advisor_type_name);
     42          DBMS_LOB.WRITEAPPEND (p_clob, 20, '');
     43        END LOOP;
     44    END LOOP;
     45  END submission_advisors_proc;
     46  /
    
    Procedure created.
    
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> -- examples of virtual documents that procedure creates:
    SCOTT@orcl_11gR2> DECLARE
      2    v_clob  CLOB := EMPTY_CLOB();
      3  BEGIN
      4    FOR r IN
      5        (SELECT ROWID rid FROM submission_advisors)
      6    LOOP
      7        DBMS_LOB.CREATETEMPORARY (v_clob, TRUE);
      8        submission_advisors_proc (r.rid, v_clob);
      9        DBMS_OUTPUT.PUT_LINE (v_clob);
     10        DBMS_LOB.FREETEMPORARY (v_clob);
     11    END LOOP;
     12  END;
     13  /
    JohnDoePhDSome
    Research PaperDepartment Co-Chair
    JaneDoePhDSome
    Research PaperDepartment Co-Chair
    JohanSmithThesis on 17th Century
    Weather PatternsProfessor
    MagnusJacksonMSThe
    sis on 17th Century Weather PatternsAssociate
    Professor
    WilliardForsbergAMS
    

    Statistical Analysis on Sunny Days in

    MarchScientist
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> -- user_datastore that uses procedure:
    SCOTT@orcl_11gR2> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('sa_datastore', 'USER_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('sa_datastore', 'PROCEDURE', 'submission_advisors_proc');
      4  END;
      5  /
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> -- index (on optional extra column) that uses user_datastore and section group:
    SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD (any_column VARCHAR2(1))
      2  /
    
    Table altered.
    
    SCOTT@orcl_11gR2> CREATE INDEX submission_advisors_idx
      2  ON submission_advisors (any_column)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  PARAMETERS
      5    ('DATASTORE     sa_datastore
      6        SECTION GROUP     CTXSYS.AUTO_SECTION_GROUP')
      7  /
    
    Index created.
    
    SCOTT@orcl_11gR2> -- what is tokenized, indexed, and searchable:
    SCOTT@orcl_11gR2> SELECT token_text FROM dr$submission_advisors_idx$i
      2  /
    
    TOKEN_TEXT
    ----------------------------------------------------------------
    17TH
    ADVISOR_TYPE_NAME
    AMS
    ANALYSIS
    ASSOCIATE
    CENTURY
    CHAIR
    CO
    DAYS
    DEPARTMENT
    DOE
    FIRST_NAME
    FORSBERG
    JACKSON
    JANE
    JOHAN
    JOHN
    LAST_NAME
    MAGNUS
    MARCH
    PAPER
    PATTERNS
    PHD
    PROFESSOR
    RESEARCH
    SCIENTIST
    SMITH
    STATISTICAL
    SUBMISSION_NAME
    SUFFIX
    SUNNY
    THESIS
    WEATHER
    WILLIARD
    
    34 rows selected.
    
    SCOTT@orcl_11gR2> -- sample searches across all data:
    SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100)
    SCOTT@orcl_11gR2> EXEC :search_string := 'professor'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> SELECT s.submission_name,
      2           a.advisor_type_name || ' ' ||
      3           sa.first_name || ' ' ||
      4           sa.last_name || ' ' ||
      5           sa.suffix AS advisor
      6  FROM   submission_advisors sa,
      7           submission s,
      8           advisor_type a
      9  WHERE  CONTAINS (sa.any_column, :search_string) > 0
     10  AND    sa.advisor_type_id = a.advisor_type_id
     11  AND    sa.submission_id = s.submission_id
     12  /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Thesis on 17th Century Weather Patterns       Professor Johan Smith
    Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> EXEC :search_string := 'doe'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Some Research Paper                           Department Co-Chair John Doe PhD
    Some Research Paper                           Department Co-Chair Jane Doe PhD
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> EXEC :search_string := 'paper'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Some Research Paper                           Department Co-Chair John Doe PhD
    Some Research Paper                           Department Co-Chair Jane Doe PhD
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> -- sample searches within specific columns:
    SCOTT@orcl_11gR2> EXEC :search_string := 'chair'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> SELECT s.submission_name,
      2           a.advisor_type_name || ' ' ||
      3           sa.first_name || ' ' ||
      4           sa.last_name || ' ' ||
      5           sa.suffix AS advisor
      6  FROM   submission_advisors sa,
      7           submission s,
      8           advisor_type a
      9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN advisor_type_name') > 0
     10  AND    sa.advisor_type_id = a.advisor_type_id
     11  AND    sa.submission_id = s.submission_id
     12  /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Some Research Paper                           Department Co-Chair John Doe PhD
    Some Research Paper                           Department Co-Chair Jane Doe PhD
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> EXEC :search_string := 'phd'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> SELECT s.submission_name,
      2           a.advisor_type_name || ' ' ||
      3           sa.first_name || ' ' ||
      4           sa.last_name || ' ' ||
      5           sa.suffix AS advisor
      6  FROM   submission_advisors sa,
      7           submission s,
      8           advisor_type a
      9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN suffix') > 0
     10  AND    sa.advisor_type_id = a.advisor_type_id
     11  AND    sa.submission_id = s.submission_id
     12  /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Some Research Paper                           Department Co-Chair John Doe PhD
    Some Research Paper                           Department Co-Chair Jane Doe PhD
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> EXEC :search_string := 'weather'
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> SELECT s.submission_name,
      2           a.advisor_type_name || ' ' ||
      3           sa.first_name || ' ' ||
      4           sa.last_name || ' ' ||
      5           sa.suffix AS advisor
      6  FROM   submission_advisors sa,
      7           submission s,
      8           advisor_type a
      9  WHERE  CONTAINS (sa.any_column, :search_string || ' WITHIN submission_name') > 0
     10  AND    sa.advisor_type_id = a.advisor_type_id
     11  AND    sa.submission_id = s.submission_id
     12  /
    
    SUBMISSION_NAME                               ADVISOR
    --------------------------------------------- ----------------------------------------
    Thesis on 17th Century Weather Patterns       Professor Johan Smith
    Thesis on 17th Century Weather Patterns       Associate Professor Magnus Jackson MS
    
    2 rows selected.
    
  • Disable all constraints

    My table has many constraints, but I want to load data into this table, so I have to disable constraints, so do we have a SINGLE command to disable all constraints, instead of one by one?

    Thank you

    No there is no universal constraint inability. What you can do, it's a loop around the data dictionary view and use dynamic SQL statements:

    begin
         for all_cons in ( select table_name, constraint_name from user_constraints
                              where constraint_type in ('U', 'P', 'R') )
         loop
              execute immediate 'alter table '||all_cons||' disable constraint '||all_cons.constraint_name;
        end loop;
    end;
    

    Note that this fact that relational constraints. Remove the filter on CONSTRAINT_TYPE if you want to include check constraints as well.

    Update

    I agree with Sybrand warnings. You will need to make sure you are the only user of the database when you perform this loading.

    Cheers, APC

    Published by: APC on 28 March 2013 13:59

  • Add primary key constraint

    What will happen if I do this?

    ALTER table emp
    Add primart key (employee_id, last_name);

    It's going to be two primary keys in the table?
    or what?

    987018 wrote:
    What will happen if I do this?

    ALTER table emp
    Add primart key (employee_id, last_name);

    It's going to be two primary keys in the table?
    or what?

    It will come with an error, unless you change "primart' primary '.

    If you do, you'll get a primary key that requires a combination of the two columns to be unique.

    So, you can insert two rows with the same id of employee but different names! Not a good idea.

    Simply use a code that is used as the primary key.

    Note: you can have only one primary key for a table, but you can have many unique constraints.

Maybe you are looking for