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

Similar Messages

  • 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

  • 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

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

  • Table Join brings in multiple records

    Hi guys,
    I have created a table join for 2 HR master tables to get a view.
    When i output the view however it brings in multiple records for each employee.
    I have set PERNR as the Key field to join the tables but instead of giving me one instance of employee it picks it up 2 records....and in some cases many more, is their a fix for this?
    Thanks

    Hi,
    Try using a combined primary key;
    PERNR, BEGDA and ENDDA
    There are more primary keys to be combined but try with this 3.
    ~BiSu

  • One-to-many outer join in MView, is possible?

    Re: 10g R2
    Is it simply not possible to have fast refresh on outer joins that are 1-to-many relations? I have in this script a unique key addition to "fix" it, but it restricts something that I don't want restricted. If indeed this is how it should work, are there any strategies for improving performance for queries on this type of thing? The "fact_table" in this example is actually another materialized view with simple inner joins, so that works perfectly, but I was trying to improve query performance in this case too.
    Run the script w/ dbms output...all self contained within the schema.
    drop materialized view log on fact_Table;
    drop materialized view log on outer_detail;
    drop materialized view mview_test;
    drop table outer_detail cascade constraints;
    drop table fact_Table cascade constraints;
    create table fact_table (myid number primary key, fact_attrib varchar2(10));
    create table outer_detail (myid number primary key, outer_attrib varchar2(19), fact_table_id number, constraint fk_outer_to_Fact foreign key (fact_table_id) references fact_table(myid));
    CREATE MATERIALIZED VIEW LOG ON fact_table WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON outer_detail WITH ROWID;
    declare
        v_capabilities sys.ExplainMVArrayType ;
    begin
        dbms_mview.explain_mview('SELECT ft.rowid "ftrid", ' ||
           'od.rowid "odrid", ' ||
           'ft.myid fact_id, ' ||
           'od.myid outer_id, ' ||
           'ft.fact_attrib, ' ||
           'od.outer_attrib ' ||
      'FROM fact_table ft, outer_detail od ' ||
    'WHERE ft.myid = od.fact_table_id (+)', v_capabilities);
            dbms_output.put_line('ATTEMPT 1:');
            dbms_output.put_line('==============================================');
        for v_capability in (select capability_name, possible, related_text, msgtxt from table (v_capabilities))
        loop
            dbms_output.put_line('==============================================');
            dbms_output.put_line('==============================================');
            dbms_output.put_line(v_capability.capability_name);
            dbms_output.put_line(v_capability.possible);
            dbms_output.put_line(v_capability.related_text);
            dbms_output.put_line(v_capability.msgtxt);
        end loop;
    end;
    /*CREATE MATERIALIZED VIEW mview_test
    PARALLEL BUILD IMMEDIATE
    REFRESH FAST ON COMMIT WITH ROWID
    AS
    SELECT ft.rowid "ftrid",
           od.rowid "odrid",
           ft.myid fact_id,
           od.myid outer_id,
           ft.fact_attrib,
           od.outer_attrib
      FROM fact_table ft, outer_detail od
    WHERE ft.myid = od.fact_table_id (+);
    -- I'd like it to run without this constraint, is it not possible?
    alter table outer_detail add constraint unk_outer_detail unique (fact_table_id);
    declare
        v_capabilities sys.ExplainMVArrayType ;
    begin
        dbms_mview.explain_mview('SELECT ft.rowid "ftrid", ' ||
           'od.rowid "odrid", ' ||
           'ft.myid fact_id, ' ||
           'od.myid outer_id, ' ||
           'ft.fact_attrib, ' ||
           'od.outer_attrib ' ||
      'FROM fact_table ft, outer_detail od ' ||
    'WHERE ft.myid = od.fact_table_id (+)', v_capabilities);
            dbms_output.put_line('');
            dbms_output.put_line('');
            dbms_output.put_line('');
            dbms_output.put_line('ATTEMPT 2:');
            dbms_output.put_line('==============================================');
        for v_capability in (select capability_name, possible, related_text, msgtxt from table (v_capabilities))
        loop
            dbms_output.put_line('==============================================');
            dbms_output.put_line('==============================================');
            dbms_output.put_line(v_capability.capability_name);
            dbms_output.put_line(v_capability.possible);
            dbms_output.put_line(v_capability.related_text);
            dbms_output.put_line(v_capability.msgtxt);
        end loop;
    end;
    /Edited by: ORA-01435 on Sep 30, 2009 12:54 PM

    That's what I thought too. As far as I'm concerned, this is perfectly acceptable. Of course I'm in 10g R2, but:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/basicmv.htm#sthref534
    I keep re-reading the rules, trying to see why it thinks I'm violating one of them. Might have to meta-link this one.
    Just ran this on a different box, ran fine. Seem to have configuration issues between the boxes.
    Edit: Just determined that the boxes that this doesn't work on have Oracle parameters for compatibility set to 10.1.0.2.0, I'll change them and check if it modifies behavior
    Edited by: ORA-01435 on Oct 1, 2009 7:44 AM

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

  • Getting One to Many Left Join to be in One Result Row...

    11G APEX 4.2
    At this time I don't have access to make a view or anything like that. Just select access to the data.
    BEGIN
    for i in (
    SELECT CAA.NODE_NAME THENODE,CNF.FEATURE_TYPE CNFFT from CMS.CMS_APP_ASSIGN "CAA"
    LEFT JOIN CMS.CMS_NODE_FEATURE "CNF" on CAA.NODE_NAME=CNF.NODE_NAME
    WHERE CAA.NODE_APP = :WHICHAPP and CAA.REMOVE_DT is NULL)
    LOOP
    dbms_output.put_line(i.THENODE||'--'||i.CNFFT||'<BR>');
    END LOOP;
    END;
    When this returns there is a row for each of the left joins.
    server1--CPUCount<BR>
    server1--ContactInfo<BR>
    server1--ContactInfo<BR>
    server1--ContactInfo<BR>
    server2--CPUCount<BR>
    What I would like to do it just have one row:
    NODENAME
    CPUCount
    Contactinfo
    Contact Info
    Contact Info
    ETC
    server1
    value1
    value2
    value4
    c
    Thanks

    Hi,
    Taking 1 column from N rows, and transforming that into N columns on 1 row is called Pivoting.
    The forum FAQ has a page on this subject.  See https://forums.oracle.com/message/9362005#9362005
    While you're in the Forum FAQ, also see https://forums.oracle.com/message/9362002

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

  • Making a one to many relation it to columns per entry of the many relation

    CREATE TABLE main (id number, data varchar2(20));
    INSERT INTO main values (1,'some data1');
    INSERT INTO main values (2,'some data2');
    CREATE TABLE sub(main_id number, data varchar2(20), value number);
    INSERT INTO sub values (1,'data1', 10);
    INSERT INTO sub values (1,'data2', 5);
    INSERT INTO sub values (2,'data3', 10);
    INSERT INTO sub values (2,'data4', 30);
    INSERT INTO sub values (2,'data5', 20);
    I want a result like this
    id | data | sub1 | sub2 | sub3
    1, some data1, data1, data2, NULL
    2, some data2, data4, data5, data1
    That is sub1 is the value sub.data that has the largest value, sub2 is the second largest and so on.
    This is the closest I can get. Is there a way to make the where main_id = 1 dynamic so instead of 1 it refeers to the value of main.id? Or is there a different query that will give me the result I'm looking for?
    SELECT main.id, main.data, sub1.data sub1, sub2.data sub2, sub3.data sub3
    FROM main
    full outer join
    (SELECT main_id, data, value
    FROM(SELECT main_id, data, value, rownum rn
    FROM(SELECT *
    FROM sub
    WHERE main_id = 1
    ORDER BY value desc))
    WHERE rn = 1) sub1
    on main.id = sub1.main_id
    full outer join
    (SELECT main_id, data, value
    FROM(SELECT main_id, data, value, rownum rn
    FROM(SELECT *
    FROM sub
    WHERE main_id = 1
    ORDER BY value desc))
    WHERE rn = 2) sub2
    on main.id = sub2.main_id
    full outer join
    (SELECT main_id, data, value
    FROM(SELECT main_id, data, value, rownum rn
    FROM(SELECT *
    FROM sub
    WHERE main_id = 1
    ORDER BY value desc))
    WHERE rn = 3) sub3
    on main.id = sub3.main_id
    ID     DATA     SUB1     SUB2     SUB3
    2     some data2     -      -      -
    1     some data1     data1     data2     -

    SQL> select main.id
      2       , main.data
      3       , max(decode(sub.rn,1,sub.data)) "sub1"
      4       , max(decode(sub.rn,2,sub.data)) "sub2"
      5       , max(decode(sub.rn,3,sub.data)) "sub3"
      6    from main
      7       , (select t.*, row_number() over (partition by main_id order by data) rn from sub t) sub
      8   where sub.main_id = main.id
      9   group by main.id
    10       , main.data
    11  /
            ID DATA                 sub1                 sub2                 sub3
             1 some data1           data1                data2
             2 some data2           data3                data4                data5
    2 rijen zijn geselecteerd.Regards,
    Rob.

  • 3 table join finding matching audit records

    hi,
    I have the following 3 tables ( simplified for sake of example)
    TOYS ( rec_no, toy_id)
    CHANGE (rec_no, change_id, status, aff_toy_id)
    A_CHANGE (rec_no, change_id, aff_toy_id, status, operation, log_date, log_time)
    I want to find all the TOYS where a change status was made from PENDING to COMPLETE. The audit table A_CHANGE has an operation field which has 2 possible values. PRE_UPDATE and POST_UPDATE.
    the PRE_UPDATE record would have a status of PENDING and the POST_UPDATE record would have a status of COMPLETED.
    However for any record there could have been many status changes, thus i need to pair the PRE and POST UPDATE records correctly. Currently i have used the following SQL which assumes that the date and time for the PRE and POST would be exactlyl the same.
    create or replace view test as
    select a.aff_toy_id
    from a_change a, a_change b, change c, toys d
    where c.aff_toy_id=d.toy_id
    and c.status='COMPLETE'
    and a.change_id=c.change_id
    and a.change_id=b.change_id
    and a.operation='PRE_UPDATE'
    and b.operation='POST_UPDATE'
    and a.log_date=b.log_date
    and a.log_time=b.log_time
    and a.status='PENDING'
    and b.status='COMPLETE';
    this is not reliable as the PRE and POST may be a minute a part. What i need to do is for any given PRE_UPDATE find the associated POST_UPDATE based on the next sequential rec_no and primary key change_id.
    How do i do this? Maybe i need an external function or procedure? Or is this possible within a single select statement?
    big thanks to anyone who can help me here.
    cheers
    D
    Message was edited by:
    user472959

    I have used lead analytical function. Analytical functions were introduced by oracle in realease 8.1.6. There are over 30 of them. You can get more information about them on the net. Lead function retrieves the value of a column in the next record. Next record is determined by the ORDER BY clause of the function. To group the result by a column or set of columns you use PARTITION BY clause.
    Visit http://asktom.oracle.com/pls/ask/f?p=4950:1:
    Anwar

  • User-defined tables, user-defined fields, and records limitation

    Hi,
      I would like to use UDT and UDF as my add on table. I doubt there is the limitation (performance issue) using these. Can someone tell me what is the max UDT, UDF, and records can application support?
    rgds
    ERIC

    Hi Eric,
    There is no limitation on SBO as far as I know. There is a limitation on SQL though. The limitation (on SQL 2000 that is, not sure if it's the same on SQL 2005) you can only add fields in a table that adds up to 8060 characters. The amount of records in that table will depend on the amount of hard disk space you have available.
    Hope it helps,
    Adele

  • Inner join in how many tables

    hi All
    how many tables join thu inner join.

    Hi,
    You can join any number of tables as long as join conditions exist  between the tables. It is not advisable to use more than 4 tables in join. it results in performance issue.
    thanks,
    sksingh

  • 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

Maybe you are looking for

  • How to get selected  row index  of a Table ?

    hi gurus,I'm new  to Webdynpro for abap I'm displaying    just Flight details in a Table  so how to get selected  row index  of a  Table  and need  to be display in Message manager.

  • FF 8 (and 8.0.1) doesn't ask for password until quit

    Ever since version 8 FF only asks for the password after I click on "quit." Updating to 8.0.1 did not help. How do I reset it to ask for the password FIRST, before doing anything or going anywhere?

  • ESB SOAP Fault

    After much of painful efforts, I got my basic flow to work on AIX. But Now, some other application is trying to invoke my application and they are certainly calling the right url and event name. But end up getting the following exception: <env:Envelo

  • Still image export is not exporting interlaced images from interlaced video

    I'm doing some quality tests and the video i have is 60i and i'd like to export stills from the 60i, but when i run it through quicktime conversion>export still image the resulting file has been deinterlaced. i've tried multiple formats and multiple

  • View and Entity creation source code

    I would like to know which jars \ classes in JDeveloper are responsible for writing the XML that defines a view or an entity (The XML created by the "Create a new view" wizard). Thanks.