One-to-many table linking

Hi all,
I'm trying to write a report with multiple one-to-many table links.  The issue is I only want a single record from the linked tables.  The main table is an item table and the linked tables are issue and receipt.  I want to display information from the last issue record and the last receipt record along with the item information.  Not sure how to restrict the joins to just a single record (also need to sort desc on dates in the linked tables).  Does this require the use of a view? or a custom sp?
Thanks for taking your time to help.
Kevin

To bring back a single record then you will probably need to use a View , command or SP.
However, in Crystal you can bring back multiple records and only display the record you want. The easiest way will be to group
Data on Date and then Item code.
Place the data you want to see in in Item group footer and suppress details and all other Group headers and footers.
To get receipt date just use a maximum summary of receipt date in item group footer
Ian

Similar Messages

  • One to Many table join -- concat field per record grouped by id

    Post Author: wm5
    CA Forum: Formula
    Hello,
    I am using Crystal Reports XI and have two tables that have a one to many relationship and are joined by an JobID (number).
    Below is a sample with relative fields for each table.
    job_table: JobID (number), Manager (text), Status (text)
    jobaudit_table : JobAuditID (number), JobID (Number), FormID (Number)
    There is a one to many relationship with jobaudit_table having multiple records for each JobID in job_table.
    I have created a Group Header using the job_table.JobID and suppressed the detail section.
    In the group header for each JobID I display the JobID, Manager, Status. I also use the below formula to determine if any records in the jobaudit_table has a record where FormID = 90. If so, I display "Yes". If not, "No".
    So my report currently looks like.
    JobID     Manager     Status     Audit Performed
    1           Manager 1  Closed           N
    2          Manager 2   Closed           Y
    Here are the formula's I use to determine if any records in jobaudit_table contains a record where FormID = 90.
    @ja90exists
    if {jobaudit_table.FormID} = 90 then    1else    0;
    if sum({@ja90exists},{job_table.JobID}) = 0 then    "No"else    "Yes";
    Everything so far works fine. What I would like to do now is add a hyperlink to a script to view the job audit when in the above report the "Audit Performed" column is "Yes"
    So Report is now:
    JobID     Manager     Status     Audit Performed
    1           Manager 1  Closed           N
    2          Manager 2   Closed           Y (hyperlink to view audit)
    I cannot figure out how to gather the valid JobAuditIDs where FormID = 90 grouped by JobID to be used in the Group Heading section of the report.
    Also, it is unlikely, but possible that more than one job_audit record exists with FormID = 90 per JobID. So, my hyperlink could look like http://mysite.com/viewjobaudit.aspx?jobid=[jobaudit_table.JobAuditID],[jobaudit_table.JobAuditID] .
    Thanks for any help. And if this post is not clear let me know and I will clarify.
    wm5

    Post Author: bettername
    CA Forum: Formula
    Although I can't think of a way to get multiple hyperlinks, this should be a start.  It (should) hyperlink to the last job/audit in the group that formID of 90.  Oh, I assumed that the hyperlink should have been  xxxx...jobID,jobAuditID! 
    I think there may be a way of getting hyperlinks to every "90" record, but that will involve a subreport, so lets try this first...
    1 - everything from your group header to the group footer...
    2 -  add a formula into the group header that says:
    whileprintingrecords;
    stringvar jobauditID="";
    stringvar jobID:=";
    3 - Then add a formula to the details section:
    whileprintingrecords;
    stringvar jobauditID;
    stringvar jobID;
    if {jobaudit_table.FormID} = 90
    then (jobID:=totext({job_table.job_id},0,""); jobauditID:=totext({jobaudit_table.jobaudit_id},0,"")
    4 - Finally, on your "Audit Performed" formula, have a conditional hyperlink that says:
    whileprintingrecords;
    stringvar jobauditID;
    stringvar jobID;
    if {@audit performed} = "Y" then http://mysite.com/viewjobaudit.aspx?jobid=jobID","+jobauditID

  • One to many table insert in JDBC

    hi all, I have an online form when it submit the value will get into three table, one child table is one to many relation to parent , like
    parent  table have(     UserId        int Not null,     UniversityN      varchar(10) Not null,   ...   PRIMARY KEY  (UserId)   PaymentId          int Not null  auto_increment ,     UserId        int Not null, ) child Table( PaymentId          int Not null  auto_increment , UserId        int Not null, UniversityN      varchar(10) Not null, record1            varchar(50) Not null, record2            varchar(50) Not null, record13          varchar(50) Not null,     PRIMARY KEY  (PaymentId),     FOREIGN Key(UserId) REFERENCES Parent(UserId) on Delete     Cascade on update cascade)Type=InnoDB DEFAULT CHARSET=utf8; )
    then I have
    conn.setAutoCommit(false); calstat1 = (CallableStatement) conn.prepareCall(                     "{ call Insert_Parent(?,?,?,?,?,?,?,?,?,?,?,? )}"); calstat2 = (CallableStatement) conn.prepareCall(                     "{ call Insert_ChildRecords(?,?,?,?,?,?,?,?,?,?,?,? )}");
    and the UniversityN , recored1, record2, record3 all come from the input form, how can i handle this one to many insert? for each submit the parent table always one row, and the child table is a lease one up to five rows the if the did have five the userId , and UniversityN is same, but the recore 1. record2... is different
    thank you

    I think you have a problem with your database table definitions that you need to fix before coding java.
    In the above, I dont think you need the first PaymentId (in the 'have' table). I also dont think your tables are normalized since I see 'UniversityN' in both the parent and child record. Also, you should rename your tables to something meaningfull rather than 'have' and 'table'. Also, rename the fields better. Ideally get your friendly neighborhood DBA to review your tables. Only when they are well defined should you start to work on java.
    Here's an example:
    parent  table:
    Customer(
        id                number, not null, primary key, must be unique, auto increment
        userId         number, not null, natural key, must be unique
        universityN  varchar(10), Not null
    child Table:
    Payment(
        id                      number, not null, primary key, must be unique, auto increment
       customer_id        number, not null, foreign key to the customer table's id field
       record1               varchar(50), not null,
       record2               varchar(50), not null,
       record3               varchar(50), not null,
        Cascade on delete record when parent is deleted
        dont cascase update record
    )Note: in the above, record1,record2, record3 should probably be put in its own table, with a foreign key back to the payment table.
    Note: each table in your database has its own id that is auto generated. Some have a natural key (like userID) that can be used to look up records independent of the auto generated key.
    Note the customer_id (foreign key) has the name of table it refers to (customer) and the key its refering to in that table (id).
    Note: when you insert a new customer, you need to get the newly generated id. Use the natural key to retreive the id in order to put it in the new payment table's customer_id field.
    I suggest you dont cascade delete any child table. Do it programmatically so you can better learn the issues that come up as you insert, update, and delete various parent and child combinations.

  • Using models for multiple one-to-many table relationships

    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
    A     A_B     B     B_C     C
    a_id     a_id     b_id     b_id     c_id
    b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron

    Byron,
    You can create a separate "modifying" model for each table and do
    inserts/deletes/updates in a transaction across the tables with the
    three models. That's really the easy part.
    The somewhat more tedious part is the "join" models, but not hard to do.
    You just have to decide what you need from the different tables and
    quite possibly create multiple join models for different select scenarios.
    So let's just run through a simple two table join model.
    Create a SQL model. I usually name them based on the table joins. Let's
    use a somewhat more real example:
    table = customer
    columns = custid, firstname, lastname, email
    table = address
    columns = addrid (seqid), custid (fk), type
    ('w'ork,'h'ome,'b'illing,'s'hipping,'o'ther), address1, address2, city,
    state, zip
    Suppose we want to select a customer and show a list of all his/her
    addresses.
    I would create a SQL model class (extending QueryModelBase of course)
    called CustomerAddressJoinModel (this naming convention gets tough with
    three or more tables, so you have to be creative).
    In that model, I would create the fields just like any single table
    model. You need only include the columns you need. Maybe you create one
    join model that only has custid, lastname, firstname, type, city, zip.
    OK, so we only cut out 2 columns, but you get the point. If you had a
    table with lots of columns with data you rarely need to display and/or
    update, then you can exclude them. Probably a slick way to exclude
    dynamically, but this is straight forward.
    Another join model could have all the columns of both tables.
    So the trick is to set the static where criteria (using the
    setStaticWhereCriteria method) in the model's constructor. I think the
    sql model template has this in it.
    setStaticWhereCriteria(customer.custid=address.custid);
    Now you just set your criteria like any other model, and execute it.
    For a 3 table join, you just set the static criteria like this:
    tableA.aid=tableB.aid AND tableB.bid=tableC.bid
    does that make sense?
    You can also set the "modifying table" (setModifyingTable(table) - i
    think that's right) in the model and inserts/updates/deletes will only
    operate on that table within the model. Problem is maybe in the the
    field binding in your views. You may want to select from one field, and
    modify using another field. Can be done though, just not directly supported.
    In the next release of JATO, you will be able to set a display fields
    binding for read and write using different fields and even different models.
    craig
    Byron Servies wrote:
    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
         A     A_B     B     B_C     C
         a_id     a_id     b_id     b_id     c_id
         b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron
    To download the latest version of JATO, please visit:
    http://www.sun.com/software/download/developer/5102.html
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp

  • One to Many table level replication

    Hi All,
    I was configuring Streams replication between one table to many(3) tables in the same database(10.2.0.4)
    Below figure states my requirement.
                                        |--------->TEST2.TAB2(Destination) 
                                        |
    TEST1.TAB1(Source) ---------------->|--------->TEST3.TAB3(Destination)
                                        |
                                        |--------->TEST4.TAB4(Destination)Below are the steps i followed. But replication is not working.
    CREATE USER strmadmin
    IDENTIFIED BY strmadmin
    GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE, DBA to strmadmin;
    BEGIN
    DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee => 'strmadmin',
    grant_privileges => true);
    END;
    check  that the streams admin is created:
    SELECT * FROM dba_streams_administrator;
    SELECT supplemental_log_data_min,
    supplemental_log_data_pk,
    supplemental_log_data_ui,
    supplemental_log_data_fk,
    supplemental_log_data_all FROM v$database;
    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
    alter table test1.tab1 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test2.tab2 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test3.tab3 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test4.tab4 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    conn strmadmin/strmadmin
    var first_scn number;
    set serveroutput on
    DECLARE  scn NUMBER;
    BEGIN
      DBMS_CAPTURE_ADM.BUILD(
             first_scn => scn);
      DBMS_OUTPUT.PUT_LINE('First SCN Value = ' || scn);
      :first_scn := scn;
    END;
    exec dbms_capture_adm.prepare_table_instantiation(table_name=>'test1.tab1');
    begin
    dbms_streams_adm.set_up_queue(
    queue_table => 'strm_tab',
    queue_name => 'strm_q',
    queue_user => 'strmadmin');
    end;
    var first_scn number;
    exec :first_scn:= 2914584
    BEGIN
      DBMS_CAPTURE_ADM.CREATE_CAPTURE(
         queue_name         => 'strm_q',
         capture_name       => 'capture_tab1',
         rule_set_name      => NULL,
         source_database    => 'SIVIN1',
         use_database_link  => false,
         first_scn          => :first_scn,
         logfile_assignment => 'implicit');
    END;
    BEGIN
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
         table_name         => 'test1.tab1',
         streams_type       => 'capture',
         streams_name       => 'capture_tab1',
         queue_name         => 'strm_q',
         include_dml        => true,
         include_ddl        => false,
         include_tagged_lcr => true,
         source_database    => 'SIVIN1',
         inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test2.tab2',
              streams_type       => 'apply',
              streams_name       => 'apply_tab2',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test3.tab3',
              streams_type       => 'apply',
              streams_name       => 'apply_tab3',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test4.tab4',
              streams_type       => 'apply',
              streams_name       => 'apply_tab4',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    select STREAMS_NAME,
          STREAMS_TYPE,
          TABLE_OWNER,
          TABLE_NAME,
          RULE_TYPE,
          RULE_NAME
    from DBA_STREAMS_TABLE_RULES;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB245' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test2.tab2',
           step_number     => 0,
           operation       => 'add');
    end;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB347' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test3.tab3',
           step_number     => 0,
           operation       => 'add');
    end;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB448' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test4.tab4',
           step_number     => 0,
           operation       => 'add');
    end;
    col apply_scn format 999999999999
    select dbms_flashback.get_system_change_number apply_scn from dual;
    begin 
      dbms_apply_adm.set_table_instantiation_scn(
      source_object_name   => 'test1.tab1',
      source_database_name => 'SIVIN1',
      instantiation_scn    => 2916093);
    end;
    exec dbms_capture_adm.start_capture('capture_tab1');
    exec dbms_apply_adm.start_apply('apply_tab2');
    exec dbms_apply_adm.start_apply('apply_tab3');
    exec dbms_apply_adm.start_apply('apply_tab4');Could anyone please help me....Please let me where i have gone wrong.
    If above steps are not correct, then please let me know the desired steps.
    -Yasser

    First of all I suggest implement it to one destination side.
    here is a good example, which I have done
    Just use it and test. Then prepare your other schema`s table (3 destination I mean)
    alter system set global_names =TRUE scope=both;
    oracle@ulfet-laptop:/MyNewPartition/oradata/my$ mkdir Archive
    shutdown immediate
    startup mount
    alter database archivelog
    alter database open
    ALTER SYSTEM SET log_archive_format='MY_%t_%s_%r.arc' SCOPE=spfile;
    ALTER SYSTEM SET log_archive_dest_1='location=/MyNewPartition/oradata/MY/Archive MANDATORY' SCOPE=spfile;
    # alter system set streams_pool_size=25M scope=both;
    create tablespace streams_tbs datafile '/MyNewPartition/oradata/MY/streams_tbs01.dbf' size 25M autoextend on maxsize unlimited;
    grant dba to strmadmin identified by streams;
    alter user strmadmin default tablespace streams_tbs quota unlimited on streams_tbs;
    exec dbms_streams_auth.grant_admin_privilege( -
    grantee => 'strmadmin', -
    grant_privileges => true)
    grant dba to demo identified by demo;
    create table DEMO.EMP as select * from HR.EMPLOYEES;
    alter table demo.emp add constraint emp_emp_id_pk primary key (employee_id);
    begin
    dbms_streams_adm.set_up_queue (
         queue_table     => 'strmadmin.streams_queue_table',
         queue_name     => 'strmadmin.streams_queue');
    end;
    select name, queue_table from dba_queues where owner='STRMADMIN';
    set linesize 150
    col rule_owner for a10
    select rule_owner, streams_type, streams_name, rule_set_name, rule_name from dba_streams_rules;
    BEGIN
         dbms_streams_adm.add_table_rules(
         table_name          => 'HR.EMPLOYEES',
         streams_type          => 'CAPTURE',
         streams_name          => 'CAPTURE_EMP',
         queue_name          => 'STRMADMIN.STREAMS_QUEUE',
         include_dml          => TRUE,
         include_ddl          => FALSE,
         inclusion_rule     => TRUE);
    END;
    select capture_name, rule_set_name,capture_user from dba_capture;
    BEGIN
         DBMS_CAPTURE_ADM.INCLUDE_EXTRA_ATTRIBUTE(
         capture_name           => 'CAPTURE_EMP',
         attribute_name     => 'USERNAME',
         include          => true);
    END;
    select source_object_owner, source_object_name, instantiation_scn from dba_apply_instantiated_objects;
    --no rows returned   - why?
    DECLARE
         iscn      NUMBER;
    BEGIN
    iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_nUMBER();
         DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN(
         source_object_name     => 'HR.EMPLOYEES',
         source_database_name     => 'MY',
         instantiation_scn     => iscn);
    END;
    conn strmadmin/streams
    SET SERVEROUTPUT ON
    DECLARE
         emp_rule_name_dml VARCHAR2(30);
         emp_rule_name_ddl VARCHAR2(30);
    BEGIN
         DBMS_STREAMS_ADM.ADD_TABLE_RULES(
         table_name           => 'hr.employees',
         streams_type           => 'apply',
         streams_name           => 'apply_emp',
         queue_name           => 'strmadmin.streams_queue',
         include_dml           => true,
         include_ddl           => false,
         source_database      => 'my',
         dml_rule_name      => emp_rule_name_dml,
         ddl_rule_name      => emp_rule_name_ddl);
    DBMS_OUTPUT.PUT_LINE('DML rule name: '||emp_rule_name_dml);
    DBMS_OUTPUT.PUT_LINE('DDL rule name: '||emp_rule_name_ddl);
    END;
    BEGIN
         DBMS_APPLY_ADM.SET_PARAMETER(
         apply_name => 'apply_emp',
         parameter => 'disable_on_error',
         value => 'n');
    END;
    SELECT a.apply_name, a.rule_set_name, r.rule_owner, r.rule_name
    FROM dba_apply a, dba_streams_rules r
    WHERE a.rule_set_name=r.rule_set_name;
    -- select rule_name field`s value and write below -- example EMPLOYEES16
    BEGIN
         DBMS_STREAMS_ADM.RENAME_TABLE(
         rule_name           => 'STRMADMIN.EMPLOYEES14',
         from_table_name     => 'HR.EMPLOYEES',
         to_table_name          => 'DEMO.EMP',
         operation          => 'ADD'); -- can be ADD or REMOVE
    END;
    BEGIN
         DBMS_APPLY_ADM.START_APPLY(
         apply_name => 'apply_emp');
    END;
    BEGIN
         DBMS_CAPTURE_ADM.START_CAPTURE(
         capture_name => 'capture_emp');
    END;
    alter user hr identified by hr;
    alter user hr account unlock;
    conn hr/hr
    insert into employees values
    (400,'Ilqar','Ibrahimov','[email protected]','123456789',sysdate,'ST_MAN',30000,0,110,110);
    insert into employees values
    (500,'Ulfet','Tanriverdiyev','[email protected]','123456789',sysdate,'ST_MAN',30000,0,110,110);
    conn demo/demo
    grant all on emp to public;
    select last_name, first_name from emp where employee_id=300;
    strmadmin/streams
    select apply_name, queue_name,status from dba_apply;
    select capture_name, status from dba_capture;

  • Modelling a one to many table's in a form

    I'm looking at creating a program with two tables, Riders and Group. A Group can have many riders and I'm not sure how I can model this in a form. This is my first attempt at righting a full scale program in Java so would like to do it correctly from the start. I've looked at the MVC pattern to keep the view's updated but I'm having problem's getting my head around how to keep the list updated for the group.
    My question to you is to ask for an example, maybe open source, example that I can see how someone managed to create this and learn from it. Any help would be greatly appreciated.

    bikingbadger wrote:
    I'm looking at creating a program with two tables, Riders and Group. A Group can have many riders and I'm not sure how I can model this in a form. This is my first attempt at righting a full scale program in Java so would like to do it correctly from the start. I've looked at the MVC pattern to keep the view's updated but I'm having problem's getting my head around how to keep the list updated for the group.
    My question to you is to ask for an example, maybe open source, example that I can see how someone managed to create this and learn from it. Any help would be greatly appreciated.What I have done in the past is use a DropDown and a List, the selection on the DropDown causes the list to populate with the available options/children.

  • Unidirectional one-to-many with join table

    According to http://docs.jboss.org/hibernate/orm/3.5/reference/en-US/html/associations.html#assoc-unidirectional-12m "A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended", instead they recommend using a join table, e.g.
    create table Person ( personId bigint not null primary key )
    create table PersonAddress ( personId not null, addressId bigint not null primary key )
    create table Address ( addressId bigint not null primary key )
    However if doing this, when using SQLDeveloper the Address table does not appear as a child table of Person, which it should be as a unidirectional one-to-many meaning that I can't create a cache group for Person and subsequently Person.
    Is this something that can be worked around as I'm using a legacy schema created from Hibernate/JPA and the implications of changing are quite substantial?
    Thanks

    Hi Gennady,
    Apologies but my question was not clear enough. The schema structure that I have inherited is as follows:
    CREATE TABLE T_PERSON ( PERSONID NUMBER PRIMARY KEY, PERSONFIRSTNAME VARCHAR2(20), PERSONLASTNAME VARCHAR2(20) );
    CREATE TABLE T_PERSONADDRESS (PERSONID NUMBER NOT NULL, ADDRESSID NUMBER NOT NULL PRIMARY KEY );
    CREATE TABLE T_ADDRESS ( ADDRESSID NUMBER  PRIMARY KEY, ADDRESSTEXT VARCHAR2(200) );
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_PERSON_ID FOREIGN KEY (PERSONID) REFERENCES T_PERSON(PERSONID);
    ALTER TABLE T_PERSONADDRESS ADD CONSTRAINT FK_PERSON_ADDR_ADDR_ID FOREIGN KEY (ADDRESSID) REFERENCES T_ADDRESS(ADDRESSID);This is implementing a unidirectional one-to-many relationship between T_PERSON and T_ADDRESS according to the Hibernate and JPA recommendation. As far as I can see most schema designers would do this using by adding a column "PERSON_ID" (and associated FK) on the T_ADDRESS table and therefore not needing the T_PERSONADDRESS table.
    This being what it is, I would then like to create a cache-group as follows:
    CREATE READONLY CACHE GROUP "CACHEGROUPADDRESSES"
    AUTOREFRESH MODE INCREMENTAL INTERVAL 5 MINUTES
    STATE PAUSED
    FROM
      "SCHEMA1"."T_PERSON" (
        "PERSONID"        NUMBER            NOT NULL,
        "PERSONFIRSTNAME" VARCHAR2(20 BYTE),
        "PERSONLASTNAME"  VARCHAR2(20 BYTE),
        PRIMARY KEY("PERSONID")
      "SCHEMA1"."T_ADDRESS" (
        "ADDRESSID" NUMBER NOT NULL,
        "ADDRESSTEXT" VARCHAR2(20 BYTE),
        PRIMARY KEY("ADDRESSID")
      "SCHEMA1"."T_PERSONADDRESS" (
        "PERSONID"  NUMBER NOT NULL,
        "ADDRESSID" NUMBER NOT NULL,
        PRIMARY KEY("ADDRESSID"),
        FOREIGN KEY("PERSONID")
          REFERENCES "SCHEMA1"."T_PERSON"("PERSONID"),
        FOREIGN KEY("ADDRESSID")
          REFERENCES "SCHEMA1"."T_ADDRESS"("ADDRESSID")
      )This however gives me the error "TT8222: Multiple parent tables found" because TimesTen has failed to identify the one-to-many-using-link-table pattern.
    Without a schema re-write is there anything that I can do, alternatively will this be looked at for a future release of TimesTen?
    Edited by: TrisStev on Apr 16, 2012 10:37 AM

  • WCF RIA zero-one to many ultimate treeview

    Hi,
    I am using ultimate treeview extension (http://visualstudiogallery.msdn.microsoft.com/ca292c74-661c-48ba-8262-d79a2671c33f)
    This requires a zero-one to many table. I have this working with a table.
    However I need to connect to a WCF RIA service from the control. Currently using 
     public class WorksOrderTree
            [Key()]
            public int id { get; set; }
            [Association("ProductPart", "id", "ParentID")]
            public IEnumerable<WorksOrderTree> Children { get; set; }
            [Association("ProductPart", "ParentID", "id", IsForeignKey = true)]
            public WorksOrderTree Parent { get; set; }
            public int ParentID { get; set; }
    This gives the following error
    Error 1
    f0rmoum1..csdl(26,6) : error 0113: Multiplicity is not valid in Role 'WorksOrderTree' in relationship 'ProductPart'. Because all the properties in the Dependent Role are nullable, multiplicity of the Principal Role must be '0..1'.
    Any idea to to how create zero-one to many in the ria service.
    Thanks
    Steve

    Thanks for your reply Paul.
    Yes I read your blog about the Telerik treeview and it was very helpful. the problem is that I want to use the Telerik RadTreeListView control instead, and It seem that it cannot be used with LightSwitch (for threading problems...)
    So I am obliged to create a RIAService ( that I hope) it can return a hierarchical structure without any lazy loading, so the RadTreeListView can work....
    but It seem that RIAService (Or LightSwitch) Insists on lazy load, and I don't know how to avoid it...
    I know that I can create a service in my UserControl project as you say in your blog but I am trying to create a LightSwitch extention ....
    AAK

  • 3 way one-to-many through a single link table

    I have 3 tables that are linked through one to many relationships in a single link table. Here's the real relationships:
    assay(id)
    multiplex(id, assays)
    markerset(id, assays, multiplexes)
    Here's the database schema:
    assay(id, name)
    markerset(id, name)
    multiplex(id, name)
    assay_marker_set(assay_id[not null], marker_set_id[not null], multiplex_id[nullable])
    I've mapped one-to-many relationships between markersets and assays, and multiplexes and assays, and BOTH of these one-to-manys need to be writable. In the record creation process, assays are associated with markersets, and then assays are associated with multiplexes, which in turn are associated with markersets.
    Here's our dilemma. When committing multiplexes through a unit of work, the one-to-many with assays can't see the one-to-many with markersets, so the commit fails because the markerset key is null.
    We've gotten around the problem by creating a postSave() method in markerset that writes multiplex changes once they are created. But again, in a unitofwork commit, saving a markerset fires the postSave() method, which writes assays and multiplexes that have not yet been written to the database.
    We've gotten around THAT by only turning on postSave() when creating multiplexes, not when associating assays with markersets.
    My question is, is there a more conventional approach to this problem? Clearly, the database needs to be reworked, but time constraints and the quantity of data to be curated makes changing the schema impossible. Or have we arrived at the most sensible solution to a ridiculous problem? Currently what we have works, it's just incredibly complicated, and nearly unmaintainable.
    Thanks for the time to even read this post, and mocking is permitted ;-)
    Paul Cooper
    GlaxoSmithKline US Bioinformatics

    Looks like your object model does not match your data model.
    From you object model you seem to have,
    Assay
    MarkerSet 1-m Assay, 1-m Multiplex
    Multiplex 1-m Assay
    From your data model you have,
    Assay 1-m AssayMarkerSetAssociation
    MarkerSet 1-m AssayMarkerSetAssociation
    Multiplex 1-m AssayMarkerSetAssociation
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    (your object model seems to be also missing the name)
    I'm not exactly sure how you have your mapping working, but it would seem the best solution is to introduce an AssayMarkerSetAssociation object into your object model.
    If you do not wish to use this object in your model, you could just use it internally to store the relationship and still have get/set methods for the relationships that you want that initialize themselves from the associations.
    So your object model would be,
    Assay
    MarkerSet 1-m AssayMarkerSetAssociation (+ getAssays, getMultiplexes methods)
    Multiplex 1-m AssayMarkerSetAssociation (+ getAssays, method)
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    In general you seem to be able to get your mapping working without changing your object model, but are probably better off for maintainability to change your model slightly.

  • ONE-to-MANY relationship between tables and forms in APEX

    I recently started using APEX and I have run into an issue.
    I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
    A1:
    A1_ID
    Item
    A2:
    A2_ID
    SubItem
    A1_ID
    I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
    On F2, I have the following fields that are setup to capture data:
         A2.A1_ID
    **A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
         A2.SubItem (user would enter SubItem)
    Note: A2.A2_ID is populated using a SEQ
    Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
    If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
    If this will work, how do I go about implementing this solution?
    Can someone help me?

    I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
    chris.

  • One to Many with multiple tables on One side and one table on Many side

    Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
    ENTITY_ONE (
    ID
    NAME
    ENTITY_TWO (
    ID
    NAME
    ATTACHMENTS (
    ID
    ENTITY_ID
    ATTACHMENT_NAME
    ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • Help with multi-table mapping for one-to-many object inheritance

    Hi,
    I have posted on here before regarding this (Toplink mapping for one-to-many object inheritance but I am still having problems mapping my object model to my schema.
    Object model
    The Person and Organisation objects contain base information and have the primary keys person_id and organisation_id. It is important that there is no duplication of person and organisation records, no matter how many times they are saved in different roles.
    There are two types of licenceholder in the problem domain, and the ILicenceHolder interface defines information and methods that are common to both. The PersonalLicenceHolder object represents one of these types of licenceholder, and is always a person, so this class extends Person and implements ILicenceHolder.
    The additional information and methods that are required by the second type of licenceholder are defined in the interface IPremisesLicenceHolder, which extends ILicenceHolder. Premises licence holders can either be people or organisations, so I have two objects to represent these - PremisesLicenceHolderPerson which implements IPremisesLicenceHolder and extends Person, and PremisesLicenceHolderOrganisation which implements IPremisesLicenceHolder and extends Organisation.
    The model is further complicated by the fact that any single Person may be both a PersonalLicenceHolder and a PremisesLicenceHolderPerson, and may be so several times over. In this case, the same basic Person information needs to be linked to several different sets of licenceholder information. In the same way, any single Organisation may be a PremisesLicenceHolderOrganisation several times over.
    Sorry this is complicated!
    Schema
    I have Person and Organisation tables containing the basic information with the primary keys person_id and organisation_id.
    I have tried to follow Donald Smith's advice and have created a Role table to record the specialised information for the different types of licence holder. I want the foreign keys in this table to be licenceholder_id and licence_id. Licenceholder_id will reference either organisation_id or person_id, and licence_id will reference the primary key of the Licence table to link the licenceholder to the licence. Because I am struggling with the mapping, I have changed licenceholder_id to person_id in an attempt to get it working with the Person object before I try the Organisation.
    Then, when a new licenceholder is added, if the person/organisation is already in the database, a new record is created in the Role table linking the existing person/organisation to the existing licence rather than duplicating the person/organisation information.
    Mapping
    I am trying to use the toplink mapping workbench to map my PremisesLicenceHolderPerson object to my schema. I have mapped all inherited attributes to superclass (Person). The primary table that the attributes are mapped to is Person, and I have used the multi-table info tab to add Roles as an additional table and map the remaining attributes to that.
    I have created the references PERSON_ROLES which maps person.person_id to roles.person_id, ROLES_PERSON which maps roles.person_id to person.person_id and ROLES_LICENCE which maps roles.licence_id to licence.licence_id.
    I think I have put in all the relationships, but I cannot get rid of the error message "The following primary key fields are unmapped: PERSON_ID".
    Please can somebody tell me how to map this properly?
    Thank you.

    I'm not positive about your mappings, but it looks like the Person object should really have a 1:M or M:M mapping to the Licenceholder table. This then means that your object model should be similar, in that Person object could have many Licenses, instead of being LicenceHolders. From the looks of it, you have it set up from the LicenceHolder perspective. What could be done instead if a LicenceHolder could have a 1:1 reference to a person data object, rather than actually be a Person. This would allow the person data to be easily shared among licences.
    LicenceHolder1 has an entry in the LicenceHolder table and Person table. LicenceHolder2 also has entries in these tables, but uses the same entry in the Person table- essentially it is the same person/person_ID. If both are new objects, TopLink would try to insert the same person object into the Person table twice. I'm not sure how you have gotten around or are planning to get around this problem.
    Since you are using inheritance, it means that LicenceHolder needs a writable mapping to the person.person_id field- most commonly done through a direct to field mapping. From the description, it looks like roles.person_id is a foreign key in the multiple table mapping, meaning it would be set based on the value in the person.person_id field, but the person.person_id isn't actually mapped in the object. Check to make sure that the ID attribute LicenceHolder is inheriting from person hasn't been remapped in the LicenceHolder descriptor to a different field.
    Best Regards,
    Chris

  • How to implement one to many relationship between two Document Line Table

    Hi,
    I want to implement the following relationship into user defined tables:
    Example Situation:
    There are tables A, B and C.
    For one record of Table A, there could be multiple records in table B.
    For one record of Table B, there could be multiple records in table C.
    i.e. A(1) -> B(n) [One to many relationship]
         B(1) -> C(n) [One to many relationship]
    finally: A(1) -> B(n) -> C(n)
    How can I achieve this? If I make Table A as Document and table B & C as Document Line and then make them UDO, will it work? Kindly suggest me a solution.
    Regards,
    Sudeshna.

    Hi,
    I think that the database representation is exactly what you ask for. 3 tables, A, B, C. A should have a UDF that is linked to B table, and B should have a UDF that is linked to C table.
    You should manage the database transactions, and the UI to support all this stuff.
    Regards,
    IBai Peñ

  • Creating a single context index on a one-to-many and lookup table

    Hello,
    I've been successfully setting up text indexes on multiple columns on the same table (using MULTI_COLUMN_DATASTORE preferences), but now I have a situation with a one-to-many data collection table (with a FK to a lookup table), and I need to search columns across both of these tables. Sample code below, more of my chattering 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 lump these fields together:
    SUBMISSION_ADVISORS.FIRST_NAME
    SUBMISSION_ADVISORS.LAST_NAME
    SUBMISSION_ADVISORS.SUFFIX
    ADVISOR_TYPE.ADVISOR_TYPE_NAME
    I've looked at DETAIL_DATASTORE and USER_DATASTORE, but the examples in Oracle Docs for DETAIL_DATASTORE leave me a little bit perplexed. It seems like this should be pretty straightforward.
    Ideally, I'm trying to avoid creating new columns, and keeping the trigger adjustments to a minimum. But I'm open to any and all suggestions. Thanks for for your time and thoughts.
    -Jamie

    I would create a procedure that creates a virtual document with tags, which is what the multi_column_datatstore does behind the scenes. Then I would use that procedure in a user_datastore, so the result is the same for multiple tables as what a multi_column_datastore does for one table. I would also use either auto_section_group or some other type of section group, so that you can search using WITHIN as with the multi_column_datastore. Please see the demonstration 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, '<first_name>');
    13          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.first_name), r1.first_name);
    14          DBMS_LOB.WRITEAPPEND (p_clob, 13, '</first_name>');
    15        END IF;
    16        IF r1.last_name IS NOT NULL THEN
    17          DBMS_LOB.WRITEAPPEND (p_clob, 11, '<last_name>');
    18          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.last_name), r1.last_name);
    19          DBMS_LOB.WRITEAPPEND (p_clob, 12, '</last_name>');
    20        END IF;
    21        IF r1.suffix IS NOT NULL THEN
    22          DBMS_LOB.WRITEAPPEND (p_clob, 8, '<suffix>');
    23          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.suffix), r1.suffix);
    24          DBMS_LOB.WRITEAPPEND (p_clob, 9, '</suffix>');
    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, '<submission_name>');
    32          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r2.submission_name), r2.submission_name);
    33          DBMS_LOB.WRITEAPPEND (p_clob, 18, '</submission_name>');
    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, '<advisor_type_name>');
    41          DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r3.advisor_type_name), r3.advisor_type_name);
    42          DBMS_LOB.WRITEAPPEND (p_clob, 20, '</advisor_type_name>');
    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  /
    <first_name>John</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
    Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
    <first_name>Jane</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
    Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
    <first_name>Johan</first_name><last_name>Smith</last_name><submission_name>Thesis on 17th Century
    Weather Patterns</submission_name><advisor_type_name>Professor</advisor_type_name>
    <first_name>Magnus</first_name><last_name>Jackson</last_name><suffix>MS</suffix><submission_name>The
    sis on 17th Century Weather Patterns</submission_name><advisor_type_name>Associate
    Professor</advisor_type_name>
    <first_name>Williard</first_name><last_name>Forsberg</last_name><suffix>AMS</suffix><submission_name
    Statistical Analysis on Sunny Days inMarch</submission_name><advisor_type_name>Scientist</advisor_type_name>
    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.

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Maybe you are looking for

  • HT1766 How do I save the music from my iphone 5c to my laptop?

    Hi, How do I save the the music from my iphone 5c to my laptop? Thank you.

  • Newbie Question: Importing (from PC) and Organizing Photos in iPhoto

    Hi everyone, I am currently a PC user and am contemplating buying an iMac, and I'm trying to determine if iPhoto will meet my needs for photo importing and organization. I currently have around 20-30 gigs of digital photos and am using Windows Photo

  • How to create a status bar in Forms 6i

    Hi, I am using Forms6i. I am calling a C application which takes some time to execute...So I would like to display a status bar in forms saying....Processing..Please Wait... And, once the control comes back to forms from the C program, this status sh

  • Safari repeatedly crashes, This is a crash log

    Process: Safari [152] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 3.2.3 (5525.28.3) Build Info: WebBrowser-55252803~5 Code Type: X86 (Native) Parent Process: launchd [75] Interval Since Last Report: 534

  • I7+10GBddr3+raid0+2layersofLQfootage=painfully slow

    Im trying to simply blend two layers together of 500x300 divx footage and it cant playback in realtime and takes about 4x as long to render. This has been the case more or less with any footage ive used and any settings ive tried ever since CS5 came