Multi table query with key foreign null.

Consider the following tables

create table student (
 id number not null,
 name varchar2(80),
primary key(id)
);

create table course(
  id number not null,
  subject varchar2(120),
  primary key(id)
);

create table class(
 id number not null,
 name varchar2(80),
 day number,
 course_id number not null,
 primary key(id),
 foreign key(course_id) references course(id)
);

create table student_course(
  id number not null,
  student_id number not null,
  course_id number not null,
  class_id number,
  primary key(id),
  foreign key(student_id) references student(id),
  foreign key(course_id) references course(id),
  foreign key(class_id) references class(id)
);

The student may enroll in a course and then a Professor assign to a class, that's why foreign class_id key isn't a constraint not null.

What I want is to write a query so that the student can see all courses, it is registered for the class, that he has been assigned and the day of the class, but the report should include courses where the student is not assigned to a class again.

I wrote the following query.

select
 course.subject,
 class.name,
 class.day
from
  course,
  class,
  student_course,
  student
where course.id = student.course_id
and class.id = student_course.class_id
and student_course.foititis_id = get_foititis_id

However, I only get the lines where the student_course.class_id is not null.

I tried various combinations of coalesce, nvl, decode in both the select statement and where statement, but the results where garbage.

No idea if such a request is possible?

Thanks in advance for any help.

Hello

Thanks for posting the instructions CREATE TABLE.  Don't forget to display instructions INSERT for a litle sample data and the results desired from these sample data.

odysam wrote:

... I wrote the following query.

  1. Select
  2. race. Subject,
  3. Class.Name,
  4. Class.Day
  5. Of
  6. Of course
  7. class,
  8. student_course,
  9. Student
  10. where course.id = student.course_id
  11. and class.id = student_course.class_id
  12. and student_course.foititis_id = get_foititis_id

However, I only get the lines where the student_course.class_id is not null.

I tried various combinations of coalesce, nvl, decode in both the select statement and where statement, but the results where garbage.

No idea if such a request is possible? ...

It's logical.  The condition on line 11

Class.ID = student_course.class_id

will not be TRUE is student.course.class_id is null.

As Someoneelse said, looks like you need an Outer Join.

Inner joins, as you use above, produce results only when a row in a table has one matching row in another table.

In this case (as far as I can tell without data sample or results), you want to display the rows in a table with their matching rows When THERE is a MATCHING ROWS, but you want to show each row of the first table in any case, if corresponding lines.  This is an outer join.

Tags: Database

Similar Questions

  • Plans test stops with the error 'Array with key "BB0050569F23260000-null" not found ".

    Dear gurus, I hope someone can help me with my problem.

    My SRM 4.0 Lab:

    • two servers vCenter v.4 + SRM 4.0 + EMC_Celerra_Replicator_SRA

    • two VSA Celerra with replication of work

    • two ESXi 4 servers connected to vCenter Server

    When I am trying to perform a recovery of the Test plan, I got the error 'Array with key as NULL "BB0050569F23260000" not found. "

    I guess it's something with recovery VSA, but cannot move forward, as I am a beginner in storaging.

    I've attached screenshots of the box of diag "Configure storage arrays", maybe this will help.

    Thanks in advance!

    without the hotfix SRA, you must rename your celerra VSA on the two sites do not contain not "-" in their names

    Itzik Reich

    Solutions architect

    VCP, VTSP, MCTS, MCITP, MCSE, CCA, CCNA

    EMC²

    where the news concerts

    If you find this information useful, please give points to "correct" or "useful".

  • 11g - new: NOT IN has a different behavior with key FOREIGN ACTIVE!

    Oracle has changed NOT IN way that works?
    The NOT IN operator is supposed to return no rows when there are NULL values, see example below:
    Two table c1 (table 1), p2 (table 1 in the parent).

    create table c1 (c_col, p_col number);
    create table p1 (number p_col);
    insert into p1 values ('1');
    insert into values p1 (2);
    Insert in the values of c1 (100, 1);
    Insert in the values of c1 (200, 2);
    Insert in the values of c1 (300, null);
    Select * C1
    If p_col not in (select p_col from p1)
    NO RETURNS NO LINE! <-this is the expected behavior

    When adding a foreign key, the variations in results:
    ALTER TABLE p1
    Add CONSTRAINT p_PK PRIMARY KEY (p_col)
    ALTER TABLE c1
    ADD CONSTRAINT FOREIGN KEY FK1
    (p_col) P1 REFERENCES;

    THE RESULT OF THE CHANGE:
    Select * C1
    If p_col not in (select p_col from p1)
    RETURNS:
    C_COL P_COL
    ---------------------- ----------------------
    300

    1 selected lines

    WHY?
    When the foreign key is disabled, the result does not change back to the old.
    -
    ALTER table disable forced fk1 c1
    Select * C1
    If p_col not in (select p_col from p1)
    NO RETURNS NO LINE!

    Activation of the constraint:
    ALTER table ENable constraint fk1 c1
    Select * C1
    If p_col not in (select p_col from p1)
    RETURNS:
    C_COL P_COL
    ---------------------- ----------------------
    300

    1 selected lines

    That's happened?

    This is a bug caused by a combination of two elements: [join elimination | http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html] introduced in 10 gr 2 and [Null-aware anti-jointures | http://structureddata.org/2008/05/22/null-aware-anti-join/] introduced in 11 GR 1 material. 11 g CBO to the first query transformations via unnesting of the subquery:

    *****************************
    Cost-Based Subquery Unnesting
    *****************************
    SU: Unnesting query blocks in query block SEL$1 (#1) that are valid to unnest.
    Subquery Unnesting on query block SEL$1 (#1)SU: Performing unnesting that does not require costing.
    SU: Considering subquery unnest on query block SEL$1 (#1).
    SU:   Checking validity of unnesting subquery SEL$2 (#2)
    SU:   Passed validity checks.
    SU: Transform ALL subquery to a single null-aware antijoin.
    

    and then eliminates the join:

    *************************
    Join Elimination (JE)
    *************************
    JE:   cfro: C1 objn:61493 col#:2 dfro:P1 dcol#:2
    JE:   cfro: C1 objn:61493 col#:2 dfro:P1 dcol#:2
    Query block (32724184) before join elimination:
    SQL:******* UNPARSED QUERY IS *******
    SELECT "C1"."C_COL" "C_COL","C1"."P_COL" "P_COL" FROM "TIM"."P1" "P1","TIM"."C1" "C1" WHERE "C1"."P_COL"="P1"."P_COL"
    JE:   eliminate table: P1
    Registered qb: SEL$F9980BE6 0x32724184 (JOIN REMOVED FROM QUERY BLOCK SEL$5DA710D3; SEL$5DA710D3; "P1"@"SEL$2")
    ---------------------
    QUERY BLOCK SIGNATURE
    ---------------------
      signature (): qb_name=SEL$F9980BE6 nbfros=1 flg=0
        fro(0): flg=0 objn=61492 hint_alias="C1"@"SEL$1"
    
    SQL:******* UNPARSED QUERY IS *******
    SELECT "C1"."C_COL" "C_COL","C1"."P_COL" "P_COL" FROM "TIM"."C1" "C1" WHERE "C1"."P_COL" IS NULL
    Query block SEL$F9980BE6 (#1) simplified
    

    which is obviously false.
    With optimizer_features_enable = '10.2.0.4' CBO transforms a NOT EXISTS query, since he cannot transform into normal join:

    SELECT "SYS_ALIAS_1"."C_COL" "C_COL","SYS_ALIAS_1"."P_COL" "P_COL" FROM "TIM"."C1" "SYS_ALIAS_1"
    WHERE  NOT EXISTS (SELECT 0 FROM "TIM"."P1" "P1" WHERE LNNVL("P1"."P_COL"<>"SYS_ALIAS_1"."P_COL"));
    

    and elimination of join is not even considered.
    So as a workaround, you can disable elimination join on either the session or application level via the index OPT_PARAM (although course after approval of Oracle support):

    SQL> explain plan for
      2  select /*+ opt_param('_optimizer_join_elimination_enabled' 'false') */ * from c1
      3  where p_col not in (select p_col from p1)
      4  /
    
    Explained
    
    SQL>
    SQL> select * from table(dbms_xplan.display)
      2  /
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 1552686931
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     1 |    39 |     5  (20)| 00:00:01 |
    |*  1 |  HASH JOIN ANTI SNA|      |     1 |    39 |     5  (20)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| C1   |     3 |    78 |     3   (0)| 00:00:01 |
    |   3 |   INDEX FULL SCAN  | P_PK |     2 |    26 |     1   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       1 - access("P_COL"="P_COL")
    

    BTW, elimination of join has two major bugs: [bad results: https://metalink2.oracle.com/metalink/plsql/f?p=130:14:9360445691478960109:p14_database_id, p14_docid, p14_show_header, p14_show_help, p14_black_frame, p14_font:NOT, 6894671.8, 1, 1, 1, helvetica] with outer joins and [suboptimal plan | https://metalink2.oracle.com/metalink/plsql/f?p=130:15:9360445691478960109:p15_database_id, p15_docid, p15_show_header] [, p15_show_help, p15_black_frame, p15_font:BUG, 7668888, 1, 1, 1, helvetica], making this dangerous service in 10 gr 2 also.

  • A table with two foreign keys

    Hi all

    I need to create a table (mytable) filled from 2 different tables, for example, table1 and table2

    When the rows of the table (mytable) comes from the first table (table1) columns in mytable (foreign key to the second table) are nulled, when they come (foreign key) column in the second table (table2)
    the first table) are cancelled as well.

    In terms of performance, architecture is valid, in other words, create a foreign key 2 on mytable and consequently, (the composite foreign key in this table are null according to whether they belong to the first or the second table)?

    Thanks in advance for any help

    I hope to clear

    As promised,

    mhouri.world > create table p as select * from all_users;
    
    Table created.
    
    mhouri.world > alter table p add constraint p_pk primary key (user_id);
    
    Table altered.
    
    mhouri.world > create table c (user_id references p, name varchar2(30));
    
    Table created.
    
    mhouri.world > select min(user_id),max(user_id) from p;
    
    MIN(USER_ID) MAX(USER_ID)
    ------------ ------------
               0           72                                                       
    
    mhouri.world > insert into c (user_id, name) values (0, 'test without index');
    
    1 row created.
    

    Thanks to the autonomous operation I simulates the effect of two users working on the same parent/child table

    (a) first of all, without any index covering the FK on the child table

    (b) second with a function based index on the FK column (note the desc clause in the definition of the index)

    (c) and finally with an index b-tree on the FK columns

    case (a)

    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    declare
    *
    ERROR at line 1:
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 4 
    
    mhouri.world > rollback;
    
    Rollback complete.
    

    case (b)

    mhouri.world > create index fbi_c_fk on c (user_id desc);
    
    Index created.
    
    mhouri.world > insert into c (user_id, name) values (0, 'test with fbi index');
    
    1 row created.
    
    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    declare
    *
    ERROR at line 1:
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 4 
    
    mhouri.world > rollback;
    
    Rollback complete.
    

    case (c)

    mhouri.world > create index btree_c_fk on c (user_id);
    
    Index created.
    
    mhouri.world > insert into c (user_id, name) values (0, 'test with b-tree index');
    
    1 row created.
    
    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    
    PL/SQL procedure successfully completed.
    

    Only the index b-tree covered with success the threat of the deadlock in key foreign unidexed

    Best regards

    Mohamed Houri

  • foreign key ALTER TABLE QUERY PROBLEM

    HAI ALL,

    ANY SUGGESTION PLEASE?

    UNDER: foreign key ALTER TABLE QUERY PROBLEM

    I want TO CREATE AND ALTER TABLE foreign key:

    1.TABLE:HAEMATOLOGY1
    COLUMN: HMTLY_PATIENT_NUM
    WITH
    TABLE: PATIENTS_MASTER1
    COLUMN: PATIENT_NUM (THIS IS THE KEY PRIMARY AND UNIQUE)

    1.TABLE:HAEMATOLOGY1
    COLUMN: HMTLY_TEST_NAME
    WITH
    TABLE: TESTS_MASTER1
    COLUMN: TEST_NAME ((C'EST LA CLÉ UNIQUE))
    ---------------


    SQL + QUERY DATA:
    -----------
    ALTER TABLE HAEMATOLOGY1
    Key constraint SYS_C002742_1 foreign (HMTLY_PATIENT_NUM)
    references PATIENTS_MASTER1 (PATIENT_NUM);

    ERROR on line 2:
    ORA-01735: invalid option of ALTER TABLE

    NOTE: THE NAME OF THE CONSTRAINTS: SYS_C002742_1 TAKEN FROM ORACLE ENTP TABLE DETAILS. MGR.
    ---------
    ALTER TABLE HAEMATOLOGY1
    Key constraint SYS_C002735_1 foreign (HMTLY_TEST_NAME)
    references TESTS_MASTER1 (TEST_NAME);

    ERROR on line 2:
    ORA-01735: invalid option of ALTER TABLE

    NOTE: THE NAME OF THE CONSTRAINTS: SYS_C002735_1 TAKEN FROM ORACLE ENTP TABLE DETAILS. MGR.

    ==============

    4 TABLES OF LABORATORY CLINIC FOR DATA ENTRY AND GET REPORT ONLY FOR THE TESTS CARRIED OUT FOR PARTICULAR

    PATIENT.

    TABLE1:PATIENTS_MASTER1
    COLUMNS: PATIENT_NUM, PATIENT_NAME,

    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BENAMER
    GIROT
    KKKK
    PPPP
    ---------------
    TABLE2:TESTS_MASTER1
    COLUMNS: TEST_NUM, TEST_NAME

    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HEMATOLOGY
    DIFFERENTIAL LEUKOCYTE COUNT
    -------------

    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM, HMTLY_PATIENT_NUM, HMTLY_TEST_NAME, HMTLY_RBC_VALUE, HMTLY_RBC_NORMAL_VALUE

    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HEMATOLOGY
    HEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6 - 6.0
    4.6 - 6.0
    ------------

    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS: DLC_NUM, DLC_PATIENT_NUM, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE, DLC_POLYMORPHS_

    NORMAL_VALUE,

    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUKOCYTE COUNT
    DIFFERENTIAL LEUKOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    -----------------


    Thank you
    RCS
    E-mail:[email protected]
    --------

    ALTER TABLE HAEMATOLOGY1
    ADD Key constraint SYS_C002742_1 foreign (HMTLY_PATIENT_NUM)
    references PATIENTS_MASTER1 (PATIENT_NUM);

  • 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.

  • rowSetIterator.getRow (key) is null first time click ADF table row

    Hello experts, I have very strange problem in ADF table with multiple selection mode. First time when I select a folder and a command button press to treat the selected query, rowSetIterator.getRow (key) throws null pointer exception.   Second time click on any record command button and hit it again, rowSetIterator.getRow (key) does not throw an error it gives me rather recording.  Here is my code:

    < af:table value = "#{bindings.paymentList.collectionModel}" var = 'row' "

    Rows = "#{Bindings.paymentList.rangeSize} '"

    emptyText = "#{bindings.paymentList.viewable?" "{"No request found.":"Access Denied."}"

    columnStretching = "column: c8" width = "860px";

    fetchSize = "#{bindings.paymentList.rangeSize} '"

    disableColumnReordering = "true" rowBandingInterval = "1".

    inlineStyle = ' height: 400px; "

    filterModel = "#{bindings.paymentListQuery.queryDescriptor} '"

    queryListener = "#{bindings.paymentListQuery.processQuery} '"

    filterVisible = "true" varStatus = "vs."

    selectionListener = "#{viewScope.myBean.currentSelectionListener} '"

    rowSelection = "multiple".

    ID = "t1".

    Binding = "#{viewScope.myBean.MyTable}" >

    < af:column... >

    .....

    < / af:table >

    < af:commandButton text = "ProcessRequest".

    ID = "cbProcReq".

    Binding = "#{viewScope.myBean.processReqCB} '"

    action = "#{viewScope.myBean.processRequests}" > "

    < / af:commandButton >

    currentSelectionListener():


    rksSelectedRows = searchResultTable.getSelectedRowKeys ();

    If (rksSelectedRows! = null & &! rksSelectedRows.isEmpty ()) {}

    System.out.println ("rksSelectedRows is not null or empty");   / / always runs

    }

    }

    processRequests():

    RowKeySet rksSelectedRows = myTable.getSelectedRowKeys ();

    If (null! = rksSelectedRows & &! rksSelectedRows.isEmpty ()) {}

    Iterator itrSelectedRows = rksSelectedRows.iterator ();

    RowSetIterator rowSetIterator = dcItteratorBindings.getRowSetIterator ();

    While (itrSelectedRows.hasNext ()) {}

    Key = (Key) ((List) itrSelectedRows.next () .get (0);

    If (null! = rowSetIterator.getRow (key)) {//works only 2nd time click.}  First, click on throw null for getRow()

    PaymentReq paymentReq = (PaymentReq) ((DCDataRow) rowSetIterator.getRow (key)) .getDataProvider ();

    reqList.add (paymentReq);

    } else {}

    System.out.println ("getRow() is null");

    }

    }

    I noticed that the key is never null.  Something is still getting filled.    No idea why this glitch.  Why always 2nd time click work?

    I also checked thatRow myRow = rsiSelectedRows.getRow(key); is showing  myRow as null  for the first time. But  2nd time when I click and hit button,  myRow is not null !!  Do not know what is this glitch.


    Appreciate your help.

    Thank you

    Finally I was able to solve the problem.   Noticed that code clear filter in backing bean caused this problem.   I am clear the filter of bean support when the user forgets to clear the filter in the user interface and that caused the issue with table selection.  I commented on this code and table selection works perfectly well.

  • Unique problem with selction on the table (Query Page)

    Unique problem with selction on the table (Query Page)

    I have a VO data Bulletin Board, with a transitional attribute for selction unique column.
    My requirement is that I need to identify the line that was selected in the table.

    I associated with fireAction singleSelection column, such that whenever the user selects the line
    I'm looking for that VO using some rowIterator.
    But when running the loop of the transient VO that is mapped to the singleSelection variable is the show as "n" / NUll
    for all the lines...

    So how do you identify the selected line in singleSelection to a table.

    -Sasi

    In the property inspector of the element for which you've put firePartialAction, you can find a property named "parameters". That mention primary key as your setting.

    You can get the arameter using pageContext.getparameter ();

    -Anand

  • SQL statement error INSERT The conflicted with the FOREIGN KEY constraint

    I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.

    SQL questions are better posed on Technet.  They are better equipped to manage the

    http://social.technet.Microsoft.com/forums/en-us/categories/

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • will be the foreign key allows Null values?

    Hello gurus!


    will be the foreign key allows Null values?


    Thanks in advance!

    Yes

    You can try example below

    create table table_1(id number primary key)
    insert into table_1 values (1);
    create table table_2 (id number references table_1(id),name varchar2(10))
    insert into table_2 values (null,'test')
    commit;
    
  • run wth params does not when used with table query Panel

    Hi Experts ADF,

    JDev 12 c

    I have a VO query that binds variables in which its clause. It also has a ViewCriteria who is dragged as a query with table Panel.

    When the loading of the page table does not display data.

    Click on the query search button, it works.

    Please let me know your opinion on this.

    Thank you

    Roy

    This is normal.

    You can replace it by initialQueryOverriden = true binary: display executed before the result of the query in a search engine

    Dario

  • AF:query with table

    I use the af: query with table to create a query, but the funny page, is in charge of the query page, the data contained in af:table are not fulfilled automatically. any idea, what the problem is?

    Rgds!

    Hello
    Do you use ViewCriteria to build your af:query with table, if yes, go to your ViewObject, then select your viewCriteria and click edit, and then open the data of the user interface tab, then check the query automatically .

  • SQL +-PROBLEM OF QUERY IN MULTI TABLE

    HAI ALL,

    ANY SUGGESTION PLEASE?

    SUP: SQL +-PROBLEM OF QUERY IN MULTI TABLE


    SQL + QUERY DATA:
    -----------
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,

    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,

    PATIENTS_MASTER1 DLC_POLYMORPHS_NORMAL_VALUE, HAEMATOLOGY1,

    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM

    = & PATIENT_NUM;
    -----------
    RESULT:

    & PATIENT_NUM = 1
    no selected line
    ---------
    & PATIENT_NUM = 2
    no selected line
    ------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65

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

    REAL WILL BE:

    & PATIENT_NUM = 1

    PATIENT_NUM 1

    PATIENT_NAME BBBB

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 5
    4.6 - 6.0 HMTLY_RBC_NORMAL

    -----------

    & PATIENT_NUM = 2

    PATIENT_NUM 2

    PATIENT_NAME GEORGE

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 42

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ---------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ----------------------------

    4 TABLES OF LABORATORY CLINIC FOR DATA ENTRY AND GET REPORT ONLY FOR THE TESTS CARRIED OUT FOR PARTICULAR

    PATIENT.

    TABLE1:PATIENTS_MASTER1
    COLUMNS: PATIENT_NUM, PATIENT_NAME,

    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BENAMER
    GIROT
    KKKK
    PPPP
    ---------------
    TABLE2:TESTS_MASTER1
    COLUMNS: TEST_NUM, TEST_NAME

    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HEMATOLOGY
    DIFFERENTIAL LEUKOCYTE COUNT
    -------------

    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM, HMTLY_PATIENT_NUM, HMTLY_TEST_NAME, HMTLY_RBC_VALUE, HMTLY_RBC_NORMAL_VALUE

    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HEMATOLOGY
    HEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6 - 6.0
    4.6 - 6.0
    ------------

    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS: DLC_NUM, DLC_PATIENT_NUM, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE, DLC_POLYMORPHS_

    NORMAL_VALUE,

    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUKOCYTE COUNT
    DIFFERENTIAL LEUKOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    -----------------


    Thank you
    RCS
    E-mail:[email protected]
    --------

    I think you want an OUTER JOIN

    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
     HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
     DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;
    

    Published by: shoblock on November 5, 2008 12:17
    the outer join brands became stupid emoticons or something. try hard

  • Identification and drops the unused index - index of key foreign - 11g R2

    Hi team,

    In our application, table main source have nearly 55 M records and this table have almost 15 foreign key columns. He y 5 foreign key columns that reference 5 very small tables (max 10 lines for each table) where the child tables ever updated or removed, it's very static data.

    so we thought to remove the foreign key index, in order to expedite the DML operations on the source table.

    It's the right option... ?

    Please guide me on the right track, please...

    Thank you

    RAM

    Almosty certainly right, but there are a number of things to be wary of:

    (a) you can't update the keys to reference table (parent) deliberately, but some application codes (typically a form generated) can use a generic statement to update the line and include 'id of the game {its original value} =' as part of the update. It is always updated the parent key even if it does not change, and he closed the child table.

    (b) you have an example where 99.9999% of one of the columns has a single value and the other 0.0001% of the data is shared between the remaining values of 9 parent - this could be useful as a path index even if you do not need to protect against the problem of blocking foreign. In this case you need to constrauct a histogram on the column for that the optimizer can see the extreme data distribution.

    Options

    (a) If you are confident that the parent tables never see no DML so you can move them to a separate tablespace that you do read-only (older versions of Oracle) or make read-only tables (12 c)

    (b) you can disable locking on the child table - it always helps to have implicit mode 2 and mode 3 locks (which will not appear in the lock of v$), but stop a parent update to acquire mode 4 it would be necessary for the child if something tries to update or delete the parent key.  There are however some behavior buggy serious around this area, and I don't know if it was fixed yet: https://jonathanlewis.wordpress.com/2010/02/15/lock-horror/

    ADDENDUM: If almost all the data of a column contains the same, then you can consider using a null to represent this value. Otherwise, you could play with index based on a function (changing the code of the application accordingly) to create an index that contains only the values 'rare' rather than having an index that held an entry for each row in a table. This approach would also avoid the need for a histogram.  Something like the folllowing (although the example is not a perfect match for your requirement): https://jonathanlewis.wordpress.com/2014/04/02/tweaking/

    Concerning

    Jonathan Lewis

Maybe you are looking for

  • End of 2012 very slow Mac. Etrecheck joint

    I have a Mac to end 2012, El Capitan, which has been gradually running slower and slower.  It seems preferable, once he is fully initialized, but it takes that which feels like an age to actually start, and if I try to open applications such as Mail,

  • "WindowsUpdate_28FB02D9" "WindowsUpdate_dt000" SQL Service Packs update failure

    Hello.  I tried to install this update on my computer Windows 7 Professional.  64 bit. Update failed to install: Microsoft SQL Server 2008 Service Pack 2 (or 1). (KB2285068) Please help me on how to install these service packs.  I get the message fai

  • Windows Vista and even Windows 07?

    I am trying to download a game, but the system is Windows XP or Windows Vista. Well, I have Windows 07 is Windows Vista and Windows 07 looked at the same thing?

  • HP 250 G3: drivers for HP 250 G3

    Dear HP, Your driver support page is a joke. At the time the pilot only available for Win 7 64 bit for my lap - top is the touchpad driver that is not yet installed successfully... I tried to use HP support assistant, but it fails to install almost a

  • Cannot uninstall the program and Windows Update.

    Original title: RUNNING WINDOWS VISTA 32. WINDOWS INSTALL STOP WORKING. CAN NOT INSTALL OR UNINSTALL. HOW to REINSTALL WINDOWS INSTALL OR GET to WORK IF I can NOT INSTALL anything, INCLUDING WINDOWS UPDATES.