Grouping Table Problem

Using CF8. I'm creating a report using cfdocument what will export as a PDF. I want the report to look like the following:
Vendors Within the City
   comm_cd sub-heading
     vendor name
address
loc_code
     vendor name
address
loc_code
   comm_cd sub-heading
     vendor name
address
loc_code
   comm_cd sub-heading
     vendor name
address
loc_code
Vendors Outside the City
   comm_cd sub-heading
     vendor name 
address
loc_code
     vendor name
address
loc_code
The loc_code is what determines which grouping the record will be in. Here is the code I'm working with so far without the second heading...not sure where to put it.
My query that is being called from the switch 
<cfquery dbtype="query" name="getVendor">
     SELECT DISTINCT
     comm_cd,
     comm_desc,
     vend10,
     mbe,
     gender,
     ethnic,
     lgl_nm,
     street_address,
     city,
     state,
     zip,
     loc_code,
     phone,
     fax
     FROM
          variables.savedlist
     ORDER BY
     comm_cd,
     lgl_nm
</cfquery> 
<cfscript>
   variables.location = 0;
</cfscript>
<cfif listFind('LO,AU,SL',getvendor.loc_code)>
     <cfset variables.location = 1 />
</cfif>
<cfif variables.location EQ 1>
    <div style="text-align:left;font-size:10pt;font-weight:bold;font-family:arial;">Vendors Within City</div>
<cfoutput query="getvendor" group="comm_cd">
     <table>
          <div style="width: 100%; border: 1px; table-layout:fixed;">
          <colgroup>
               <col align="left" style="width:400px;"/>
               <col align="left" style="width:400px;"/>
               <col align="left" style="width:300px;"/>
               <col align="left" style="width:300px;"/>
               <col align="left" style="width:300px;"/>
          </colgroup>
          <tbody>
          <tr>
               <td colspan="6"><div style="text-align:left;font-size:8pt;font-weight:bold;font-family:arial;">#getVendor.COMM_CD#  #getVendor.comm_desc#</div></td>
          </tr>
<cfoutput>
          <tr>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;"> </div></td>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.VEND10#<br>#getVendor.LGL_NM#<br>#getVendor.street_address#<br>#getVendor.city# #getVendor.state# #getVendor.zip#</div></td>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.phone#<br>#getVendor.fax#</div></td>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.MBE#</div></td>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.GENDER#/#getVendor.ETHNIC#</div>
               <td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.loc_code#</div></td>
          </tr>
</cfoutput>
          <tr> </tr>
          </tbody>
               </div>
</table>
</cfoutput>
</cfif>            
    What am I doing wrong?  I know I need a <cfelse> in there along with the heading 'Vendors Outside the City'.  But no matter where I put it nothing seems to work correctly.
     Thanks

Hi,
in that case you can group them using Sort table parameter. you can build the sort table based on month, and the data will be grouped based on month. this is another possibility.
sort-fieldname = 'MONTH'.
sort-up = 'X'.
append sort to it_sort.
pass this IT_sort to alv grid FM.
Regards
Vjay

Similar Messages

  • Group by problem at pivot table

    Hi,
    firstly i am making a table, everything is ok,
    after i click pivot table, st_desc column writes same value again, i couldnt understand the reason.
    please check my screen shots below,
    http://www.odilibrary.com/index.php/oracle-data-integrator/99-group-by-problem
    kindly advise please

    that my fault
    there is a null at the beginning of the value, they are different,
    sorry

  • Mobility Group Table *MUST* be populated in each WLC in same mobility group

    For what it's worth,
    I recently discovered that when you have multiple controllers and want to implement Mobility Groups, more is needed than simply entering the same Default Mobility Group Name for each controller within the mobility group. The following is required:
    a) The IP address of the "Virtual" interface on each controller must be identical on each controller within the mobility group.
    b) The Default Mobility Group Name must be identical on each controller within the mobility group (case sensitive).
    c) The mobility table must be populated with an entry for each controller within the mobility group.
    Otherwise, you will see some inexplicable behavior such as:
    * LWAP access points refusing to change to a different controller, even if their primary controller is explicitly set and the LWAP is rebooted.
    * LWAP access points unable to find any other wireless controller other than the one pointed to by the "CISCO-LWAPP-CONTROLLER" DNS entry (presumably, this would also be the case if DHCP Option 43 is used to point the LWAP to a controller). Once the first controller reaches its max. capacity of LWAPs, no more LWAPs can join.
    * Even MASTER CONTROLLER MODE has no effect.
    Cisco TAC was able to explain the great mystery of the Mobilty Group Table to me. However, unless you know your problem is related to mobility groups issues, you might not know to start there (I know I didn't).
    The least difficult method I have found for populating the mobility group table is as follows:
    Build a text file with one entry for each controller in the mobility group as follows:
    Log into the GUI for each controller and selecting: Controller -> Mobility Management -> Mobility Groups, click the "EDIT ALL" button and copy the MAC and IP address from the text box into a text file using NOTEPAD. Repeat this for each controller, creating a new line for each:
    The format for the entries is as follows:
    00:1a:6c:91:22:A0 192.168.20.44
    00:1a:6c:91:22:B4 192.168.20.45
    Once the text file is completed (one entry for each controller in the mobilit group), click the EDITALL button and copy the entire contents of the text file and paste it into the text box on the controller GUI, click the APPLY button and click Save Changes. Repeat for each controller.
    Again, make sure that the following settings are IDENTICAL in each of the controllers in the Mobility Group:
    * The IP address of the "virtual" interface ( Controller -> interfaces ) must be the same on all controllers.
    * The "Default Mobility Domain Name" ( Controller -> General ) must be identical on each controller in the mobility group (note: the Mobility Domain Name is case sensitive).
    After making changes directly to the controllers, a "refresh from controller" in the WCS might be needed to get the WCS to attempt to synchronize itself with the controllers.
    Here is a link to the 4.2 Wireless Controller Configuration Guide which discusses this in greater detail.
    http://www.cisco.com/en/US/products/ps6366/products_configuration_guide_chapter09186a00808e638b.html
    It is unfortunate that there are currently no mechanisms in the WCS 4.2 to make these changes in bulk (i.e.: The WCS has no Controller Template to do this).
    Also, if you ever need to replace a controller, you will need to update the Mobility Group Table in each controller in the Mobility Group (since the tables will have the MAC address of the old controller which will now be different in the new replacement controller).
    Despite having used the "unified" product for some time now, there are still surprises from time to time. I just thought that I would share my experience for those who may want avoid it and/or who may be encountering any of odd the behavior described above.
    - John

    Hi John,
    Nice work with this very relevant info! Please post a short reply here so that we can give this the nice rating it deserves :)
    Thanks again!
    Rob

  • Grouping Table Columns

    Hi All,
    In my webdynpro application we need to "Group Table Column".  I am using NWDS 2.0.9. The "Insert Group COlumn" feature is not there in NWDS 2.0.9. If so how ca i group my table columns. Can anyone provide me a solution for this.
    Regards,
    Divya

    Hi Divya,
    I have done this in my application too.
    I have used two tables,
    The things you need to do is,
    1. Create a scroll container
    2. Create 1st table,
    3. assign the columns coming under its header.
    4. create the 2nd table,
    5. assign the rest of the columns under that header.
    6. Table properties to be set
    7. Now make footer visible false for both the table.
    8. visible no of rows = -1
    9. assigning same context or model node to both the tables will make it as one table itself, and selecting row in one table will also select same row in other table.
    10.Dont keep wrapping as true in any table cell editor, because if there occurs any wrapping in one table, the alignment of rows will be disturbed for both.
    11.And using scroll container instead of footer will not create the scrolling event of footer in the application.
    This will solve your problem.
    Mohak.

  • How to maintain TEXT ID GROUP (table TTXERN)

    Dear SAP,
    I am having a problem on how to maintain TEXT ID GROUP (table TTXERN). Where is it configured and why after upgraded to ECC6, this table doesn't cover all data availbale in table TTXER?
    Your expert advice is realy much appreciated. will give points for those who help me out this problem.
    TQ
    Regards,
    Nazrul

    You need to run the program SDTXT1AID, it will list all entries present in TTXER but missing in TTXERN.
    It is very common to come across this issue during SAP upgrade.
    You can refer to the std documentation of the program &/or Google it to find further details

  • Mutating table problem help required

    Hi. I am rather hoping someone will be able to help me with this problem.
    I have two tables, sa and mv. Create script below:
    create table mv (
    moduleId Char(2) CONSTRAINT ck_moduleId CHECK(moduleId in ('M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8')),
    credits Number(2) CONSTRAINT ck_credits CHECK(credits in (10, 20, 40)),
    constraint pk_mv primary key(moduleId)
    create table sa (
    stuId Char(2) CONSTRAINT ck_stuId CHECK(stuId in ('S1', 'S2', 'S3', 'S4', 'S5')),
    moduleId Char(2),
    constraint pk_sa primary key(stuId, moduleId),
    constraint fk_moduleid foreign key(moduleId) references mv(moduleId)
    And the scripts below is to insert data into both:
    insert into mv VALUES('M1', 20)
    insert into mv VALUES('M2', 20)
    insert into mv VALUES('M3', 20)
    insert into mv VALUES('M4', 20)
    insert into mv VALUES('M5', 40)
    insert into mv VALUES('M6', 10)
    insert into mv VALUES('M7', 10)
    insert into mv VALUES('M8', 20)
    insert into sa VALUES('S1', 'M1')
    insert into sa VALUES('S1', 'M2')
    insert into sa VALUES('S1', 'M3')
    insert into sa VALUES('S2', 'M2')
    insert into sa VALUES('S2', 'M4')
    insert into sa VALUES('S2', 'M5')
    insert into sa VALUES('S3', 'M1')
    insert into sa VALUES('S3', 'M6')
    Now for the actual problems.
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    Just one or the other. I have created a single trigger, but if fails because of the mutating table problem.
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table.
    Many thanks in advance for any assistance.

    Use a statement level trigger:
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13  end;
    14  /
    Trigger created.
    SQL> select * from sa;
    ST MO
    S1 M1
    S1 M2
    S1 M3
    S2 M2
    S2 M4
    S2 M5
    S3 M1
    S3 M6
    8 rows selected.
    SQL> insert into sa values ('S1','M5');
    1 row created.
    SQL> insert into sa values ('S1','M6');
    insert into sa values ('S1','M6')
    ERROR at line 1:
    ORA-20001: S1 on both M5 and M6!!
    ORA-06512: at "SCOTT.SA_TRG", line 9
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13 
    14    select count(*) into c from (
    15    select stuid
    16    from mv, sa
    17    where sa.moduleid=mv.moduleid
    18    group by stuid
    19    having sum(credits)>120);
    20 
    21    if c > 0 then
    22       raise_application_error(-20002,'A student cannot have more than 120 credits!!');
    23    end if;
    24 
    25  end;
    26  /
    Trigger created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          100
    SQL> insert into sa
      2  values ('S1','M4');
    1 row created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          120
    SQL> insert into sa
      2  values ('S1','M7');
    insert into sa
    ERROR at line 1:
    ORA-20002: A student cannot have more than 120 credits!!
    ORA-06512: at "SCOTT.SA_TRG", line 20
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'Max
    http://oracleitalia.wordpress.com

  • Grouped tables not grouping

    I don't know if it's a coincidence or not, but recently I installed the iPhone SDK 3.0 beta 2, and I can't seem to create grouped tables anymore. It's a bit strange, and I keep looking for a possible code error, but I don't see one. I'm building for 2.2.1, so I'm not even trying to use any of the newer libs.
    It's a really simple static table, two sections, one row in the first, one row in the second. Title on each section. Each of the rows ends up in the right section, the UITableView just isn't using the grouped table style. It's set in the nib file in IB, and if I open up the nib in a text editor the setting looks correct. Has anybody else experienced any kind of issue like this?
    Other grouped tables that I created pre-upgrade to 3.0 beta 2 are still working just fine, I just can't seem to create any new nibs that work.
    This is all testing in the simulator, btw.

    Are you overriding the methods that declare the number of rows and sections in your view controller class as shown below?
    - (NSInteger) numberOfSectionsInTableView: (UITableView *) tv {
    return 2;
    - (NSInteger) tableView: (UITableView *) tv numberOfRowsInSection: (NSInteger) section {
    return 1;
    If you have already done this, you could try re-creating the xib file to see if it helps.
    And finally, you may want to install beta 3 to see if you are still having this problem.
    Good luck!

  • Cost element group - Table name

    Hi Guru,
    Can any body knew cost element group - Table name
    Regards,
    Bharathi.S

    Hi,
    It's stored in SETNODE and SETLEAF tables (class '0102').
    Regards,
    Eli

  • Fund group table

    hi all,
    I am trying to find fund group table. I have created fund group from public sector --> fund mgt --> master data --> fund --> fund group. But as this is a hierarchy so it is only shown in the setnode and setleaf table. Is it also given at some other place.
    Thanks for your assistance.
    Regards,
    FS

    Hi ,
    do u want to get the same from SET IDs ?
    try this sample program
    RGSEX001
    regards
    Prabhu

  • Autonomous Trigger / Mutating Table Problem

    We have a specific problem in one of our applications being developed where by the database needs to enforce a specific business requirement.
    We need to use a database trigger to enforce some data integrity which involves more than one table as such cannot use standard constraint. The integrity has to be maintained in the database as the DML statements may be coming from a Java application or PL/SQL code as such we need the logic all in one place.
    The problem being that within the trigger we need to examine the state of the table the trigger is associated with as well as one other table. Obviously using a trigger on a table that is being affected by DML statements causes the dreaded mutating table problem.
    One suggested solution to this was to make the trigger or the code the trigger called autonomous. This allows the trigger to execute by only showing the trigger the original state of the table before any of the DML statements have affected it.
    The problem is this seems to work for single row DML statements but not for multi row DML statements. In multi row the trigger only sees the original state of the table, not the state of the table plus the changes made by any other actions in the same DML statement.
    Below I have shown an example of what I'm seeing.
    I have grossly simplified the example code below to only refer to a single table and use stupidly simple logic
    I do realise i appear to be implementing uniqueness in my own PL/SQL code, this is purely for the example.
    CREATE TABLE mutate_test
    id INTEGER NOT NULL,
    value VARCHAR2(255) NOT NULL
    ALTER TABLE mutate_test ADD CONSTRAINT pk_mutate_test PRIMARY KEY(id);
    ALTER TABLE mutate_test ADD CONSTRAINT ck_mutate_test CHECK (value = UPPER(value));
    CREATE OR REPLACE FUNCTION duplicate_found(in_value IN mutate_test.value%TYPE) RETURN BOOLEAN IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_value_found INTEGER;
    BEGIN
    SELECT COUNT(*)
    INTO v_value_found
    FROM mutate_test
    WHERE value = in_value;
    IF v_value_found > 0 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;
    CREATE OR REPLACE TRIGGER tr_mutate_test BEFORE INSERT OR UPDATE ON mutate_test
    FOR EACH ROW
    BEGIN
    IF duplicate_found(:new.value) = TRUE THEN
    RAISE_APPLICATION_ERROR(-20000,'Duplicate value found');
    END IF;
    END;
    INSERT INTO mutate_test (id,value) VALUES (1,'CLIFF');
    INSERT INTO mutate_test (id,value) VALUES (2,'SULA');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 already has a value of CLIFF
    INSERT INTO mutate_test (id,value) VALUES (3,'CLIFF');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 is already set to CLIFF
    UPDATE mutate_test SET value = 'CLIFF' WHERE id = 2;
    COMMIT;
    SELECT * FROM mutate_test;
    UPDATE mutate_test SET value = 'CLIFFORD' WHERE id = 1;
    COMMIT;
    SELECT * FROM mutate_test;
    INSERT INTO mutate_test (id,value) VALUES (3,'RONNY');
    INSERT INTO mutate_test (id,value) VALUES (4,'TIM');
    INSERT INTO mutate_test (id,value) VALUES (5,'MONIQUE');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Wanted result would be row 1 would be updated from CLIFFORD to CLIFF
    -- and the others raise errors, or all of them raise errors.
    UPDATE mutate_test SET value = 'CLIFF' WHERE id IN (1,3,4);
    COMMIT;
    SELECT * FROM mutate_test;

    This is all from a University application that deals with eLearning.
    Shell = Mapping from the system to an external eLearning application, ie: unique id of the Blackboard course shell, or WebBoard board.
    Term = Academic term
    Sector = University sector, ie: Higher Education, TAFE, etc..
    Resource = eLearning tool, ie: Blackboard, WebBoard, etc..
    Resource Level = Whether the resource is being offered at a Course or Program level
    Resource Mapping = Association of a resource to shell
    What we are trying to achieve is that shells cannot be used across sector boundaries.
    The real table structure is (grossly simplified again)
    CREATE TABLE sector (sector_pk INTEGER PRIMARY KEY);
    CREATE TABLE sector_pattern (sector_pk INTEGER REFERENCES sector(sector_pk), pattern CHAR(2) NOT NULL UNIQUE CHECK (pattern = UPPER(pattern)));
    CREATE TABLE term (term_pk INTEGER PRIMARY KEY, term CHAR(4) NOT NULL UNIQUE CHECK (term = UPPER(term)));
    CREATE TABLE resource_level (resource_level_pk INTEGER PRIMARY KEY, term_pk INTEGER REFERENCES term(term_pk));
    CREATE TABLE shell_detail (shell_detail_pk INTEGER PRIMARY KEY);
    CREATE TABLE resource_mapping (resource_mapping INTEGER PRIMARY KEY, resource_level_pk INTEGER REFERENCES resource_level(resource_level_pk), shell_detail_pk INTEGER REFERENCES shell_detail(shell_detail_pk));
    Based on the Ask Tom article linked I'd liked to use a MATERIALIZED VIEW on the following query
    SELECT DISTINCT rm.shell_detail_pk,sp.sector_pk
    FROM resource_mapping rm, resource_level rl, term t, sector_pattern sp
    WHERE rm.resource_level_pk = rl.resource_level_pk
    AND rl.term_pk = t.term_pk
    AND SUBSTR(t.term,3,2) = sp.pattern;
    Then apply a UNIQUE constraint on that VIEW.
    But I'm receiving a
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    I'm not sure how to create the MATERIALIZED VIEW LOG entries for the above VIEW.
    Any ideas anyone? ;)
    Need to do some more reading and research but as Tom says
    "I'm asking around about the future of "SQL" as far as enhancments go like that
    (will update when I get some feedback), but -- you are not limited to triggers
    (in fact, I would avoid triggers as it is virtually IMPOSSIBLE to implement
    cross row/cross object constraints with them!!!! at least correctly)"
    So I think i'll give up on the TRIGGER approach as it doesn't meet our requirements.

  • Possible new feature for SQL Data modeler: grouping tables by subfolder/

    When creating models of more than 500 tables. it would be nice if there was a way to be able group sets of tables into subfolders.
    while I might have a centralized schema, meaning the physical schema inside a database can have all 500 tables.
    for example:
    I might choose to group tables by product.
    HR folder contains all my HR_<tables>
    OrderEntry folder contains all my OE_<tables>
    Inventory folder conatins all my INV_<tables>
    this will help to view in the explorer window when searching for a table.

    I might choose to group tables by product.
    HR folder contains all my HR_<tables>
    OrderEntry folder contains all my OE_<tables>
    Inventory folder conatins all my INV_<tables>You can use subviews for that. Subview can be created in different ways:
    - drag&drop from browser
    - using selected objects on diagram
    - context menu for table in browser
    - context menu for subview in browser - you can create similar subview and use it as starting point
    - context menu for schema object in relational model - such subview becomes schema bound - you can update it later with tables added/removed to/from that svchema
    Philip

  • Aggregate query on global cache group table

    Hi,
    I set up two global cache nodes. As we know, global cache group is dynamic.
    The cache group can be dynamically loaded by primary key or foreign key as my understanding.
    There are three records in oracle cache table, and one record is loaded in node A, and the other two records in node B.
    Oracle:
    1 Java
    2 C
    3 Python
    Node A:
    1 Java
    Node B:
    2 C
    3 Python
    If I select count(*) in Node A or Node B, the result respectively is 1 and 2.
    The questions are:
    how I can get the real count 3?
    Is it reasonable to do this query on global cache group table?
    I have one idea that create another read-only node for aggregation query, but it seems weird.
    Thanks very much.
    Regards,
    Nesta
    Edited by: user12240056 on Dec 2, 2009 12:54 AM

    Do you mean something like
    UPDATE sometable SET somecol = somevalue;
    where you are updating all rows (or where you may use a WHERE clause that matches many rows and is not an equality)?
    This is not something you can do in one step with a GLOBAL DYNAMIC cache group. If the number of rows that would be affected is small and you know the keys or every row that must be updated then you could simply execute multiple individual updates. If the number of rows is large or you do not know all the ketys in advance then maybe you would adopt the approach of ensuring that all relevant rows are in the local cache grid node already via LOAD CACHE GROUP ... WHERE ... Alternatively, if you do not need Grid functionality you could consider using a single cache with a non-dynamic (explicitly loaded) cache group and just pre-load all the data.
    I would not try and use JTA to update rows in multiple grid nodes in one transaction; it will be slow and you would have to know which rows are located in which nodes...
    Chris

  • SQL recursion problem in custom groups table

    hi all,
    Consider the following seemingly simple table structure ( with sample rows ) :
    PERMISSION_ID P_ID DESCRIPTION DESIGNATION
    ============= ==== =========== =======
    1776 Null Z-ENGINEERING 88888
    1860 Null Z-LABORATORY 88888
    1909 Null Z-RESEARCH 88888
    1902 Null Z-PLANT 88888
    1905 Null Z-SOFTWARE DESIGN 88888
    1903 Null Z-BLANKET 88888
    1904 Null Z-OFFICE 88888
    40000 1909 James Gosling 67890
    40001 1909 Edgar Codd 21135
    40002 1904 Alan Turing 85542
    40003 1909 Z-SOFTWARE DESIGN 88888
    40004 1905 Dennis Ritchie 12111
    40005 1909 Z-OFFICE 88888
    40006 1776 Brian Kernighan 84251
    40007 1904 Z-ENGINEERING 88888
    Explanation of table structure :
    (1) All rows with P_ID = {Null} are the root groups, and they all have a uniform DESIGNATION of 88888.
    (2) All rows that starts with 40000 are memberships; under these memberships scheme, a root group can become a member of another root group, cascaded, which means that root groups can be members of another root group or they can be members of multiple root groups ( and cascaded even ), as long as the cascade do not end up in a circular reference, or an endless cycle. The idea here is so that the memberships for both groups and human members can be chained.
    (3) Both root groups and human memberships are stored in the same table above, using rules (1) & (2) as the logic.
    (4) No additional table may be added to this table in order to implement rules (1), (2), & (3); columns may be added, though.
    (5) Use only plain SQL statements ( SELECT, CONNECT BY, PRIOR, NOCYCLES, etc ... ); PL/SQL, functions, and procedures are strongly discouraged.
    Desired output of the query is as follows :
    The SELECT query should return a list of all human members which belongs to a specific root group. Using the example table above, the initial query should have the following intended result set:
    (start with p_id = 1909) -- 1909 is root group Z-RESEARCH
    PERMISSION MEMBERS
    ========== =======
    40000 James Gosling
    40001 Edgar Codd
    40003 Z-SOFTWARE DESIGN
    40005 Z-OFFICE
    However, Z-SOFTWARE DESIGN has it's own member , Dennis Ritchie, so the updated result set should be :
    PERMISSION MEMBERS
    ========== =======
    40000 James Gosling
    40001 Edgar Codd
    40004 Dennis Ritche
    40005 Z-OFFICE
    Same is true for Z-OFFICE, but it's member is another root group, Z-ENGINEERING, whose member is Brian Kernighan, thus the final result set list would be as follows, which is the final intended list :
    PERMISSION MEMBERS
    ========== =======
    40000 James Gosling
    40001 Edgar Codd
    40004 Dennis Ritche
    40002 Alan Turing
    40006 Brian Kernighan
    The problem now would be, how to generate the final intended list using the table scheme illustrated above, with no additional tables, but possible additional columns, using Oracle's SELECT ... START WITH ... CONNECT BY PRIOR ?
    Any theoretical advice is greatly appreciated; even our consulting firm cannot solve this problem. Coming here to the Oracle Forums itself is a last resort. Perhaps someone here can take a gander at this seemingly simple problem. Fact is, solving this problem has lots of applications, one of which is the ability to mimic Outlook's nested distribution groups list.
    Thank you so much for your time.

    Ok, first time back at a database, here my 2 cent.
    I use the with-clause to simulate your sample-data, i have also added the master-reference-column i suggested. Just restrict the result to the group you want to. (i only put the id's in the query)
    WITH DATA AS (SELECT 1776 PERMISSION_ID, TO_NUMBER(NULL) P_ID, TO_NUMBER(NULL) MASTER_PERMISSION_ID, 'Z-ENGINEERING' DESCRIPTION,  88888 DESIGNATION FROM DUAL
                  UNION ALL
                  SELECT 1860, Null, Null, 'Z-LABORATORY', 88888 FROM DUAL
                  UNION ALL
                  SELECT 1909, Null, Null, 'Z-RESEARCH', 88888 FROM DUAL
                  UNION ALL
                  SELECT 1902, Null, Null, 'Z-PLANT' ,88888 FROM DUAL
                  UNION ALL
                  SELECT 1905, Null, Null, 'Z-SOFTWARE DESIGN', 88888 FROM DUAL
                  UNION ALL
                  SELECT 1903, Null, Null, 'Z-BLANKET', 88888 FROM DUAL
                  UNION ALL
                  SELECT 1904, Null, Null, 'Z-OFFICE', 88888 FROM DUAL
                  UNION ALL
                  SELECT 40000, 1909, Null, 'James Gosling', 67890 FROM DUAL
                  UNION ALL
                  SELECT 40001, 1909, Null, 'Edgar Codd', 21135  FROM DUAL
                  UNION ALL
                  SELECT 40002, 1904, Null, 'Alan Turing', 85542 FROM DUAL
                  UNION ALL
                  SELECT 40003, 1909, 1905, 'Z-SOFTWARE DESIGN', 88888 FROM DUAL
                  UNION ALL
                  SELECT 40004, 1905, Null, 'Dennis Ritchie', 12111 FROM DUAL
                  UNION ALL
                  SELECT 40005, 1909, 1904, 'Z-OFFICE', 88888 FROM DUAL
                  UNION ALL
                  SELECT 40006, 1776, Null, 'Brian Kernighan', 84251  FROM DUAL
                  UNION ALL
                  SELECT 40007, 1904, 1776, 'Z-ENGINEERING', 88888  FROM DUAL
    SELECT GROUP_REFERENCE,
           THE_USERS.PERMISSION_ID,
           USER_NAME,
           FROM_GROUP
      FROM (SELECT PERMISSION_ID,
                   DESCRIPTION FROM_GROUP,
                   CONNECT_BY_ROOT(PERMISSION_ID) GROUP_REFERENCE
              FROM (SELECT PERMISSION_ID, TO_NUMBER(NULL) P_MASTER, DESCRIPTION
                      FROM DATA
                     WHERE DESIGNATION=88888
                       AND P_ID IS NULL
                    UNION ALL
                    SELECT MASTER_PERMISSION_ID PERMISSION_ID,  P_ID P_MASTER, DESCRIPTION
                      FROM DATA
                     WHERE DESIGNATION=88888
                       AND P_ID IS NOT NULL       
            CONNECT BY PRIOR PERMISSION_ID=P_MASTER
            START WITH P_MASTER IS NULL
           ) THE_GROUPS,
           (SELECT P_ID PERMISSION_REFERENCE,
                   PERMISSION_ID,
                   DESCRIPTION USER_NAME
              FROM DATA
             WHERE MASTER_PERMISSION_ID IS NULL
               AND P_ID IS NOT NULL
           ) THE_USERS
    WHERE THE_GROUPS.PERMISSION_ID=THE_USERS.PERMISSION_REFERENCE

  • Group by problem from huge table

    Hi,
    I have a huge cdr table which contains 700 million records. There s no partition only , index on gsm_no column. (main_cdr_table)
    And i have another table with the following columns . gsm_no , cdr_count , last_digit. (gsm_temp)
    What i want to do is ,  to get a sum from main_cdr_table for each gsm_no  and store it another table , like this.
    insert into my_temp
    select gsm_no,sum(price_amount)
    from main_cdr_table
    group by gsm_no
    As you see this way is not efficient. What can you offer to perform this operation?
    Thanks...

    Alas I'm a rather underprivileged user . (some thirteenth pig we use to say)
    Nevertheless I could try to find out something useful (reporting to investigate big table compression(s) should look serious enough in these vacation times )
    As far as I can remember, maybe a year ago, I was investigating various table compressions but using only a 3M rows table collecting 100% sample statistics to check the results.
    There was quite a difference when comparing the number of blocks, but a rather small one when comparing select timings. A 3M rows table seems too small for the task.
    A 92M table might reveal new facts.
    At the moment I know collecting 100% sample statistics took 4.5 hours.
    Regarding automagical things I cannot check how things get done (I can only read in the documentation about that), the storage is definitely data aware (usually you don't need an index for each and every low cardinality - storage full scan seems to be smart enough to almost always get just the blocks where the required rows are located)
    I'll let you know about the findings.
    Regards
    Etbin
    Sorry, no further findings possible for now - ORA-01625: unable to extend temp segment by 8192 in tablespace ...
    Message was edited by: Etbin

  • Update Nested Table Problem

    Hi All,
    I have a update problem in nested table.
    Below is my query:
    CREATE OR REPLACE TYPE TRACER.SEARCH_DATA AS TABLE OF VARCHAR2(20);
    UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM
    SET NOT_FOUND_SOR_LOT_NUM = SEARCH_DATA(
    SELECT
    COLUMN_VALUE
    FROM
    TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
    WHERE
    TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
    ) WHERE JOB_ID = 8;
    ORA-00936: missing expression
    or I try as following
    DECLARE
    sor_lot_num_not_found SEARCH_DATA :=
    SEARCH_DATA
    SELECT
    FROM
    TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
    WHERE
    TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
    BEGIN
    UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM SET NOT_FOUND_SOR_LOT_NUM = sor_lot_num_not_found WHERE JOB_ID = 8;
    END;
    ORA-06550: line 5, column 9:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( ) - + case mod new not null others <an identifier>
    table avg count current exists max min prior sql stddev sum
    variance execute multiset the both leading trailing forall
    merge year month DAY_ hour minute second timezone_hour
    timezone_minute timezone_region timezone_abbr time timestamp
    interval date
    <a string literal with character set specificat
    ORA-06550: line 11, column 5:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
    ; for and or group having intersect minus order start union
    where connect
    ORA-06550: line 14, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted d
    I have try on the Select Statement, it work. So is it the way that I assign data from nested table and update method is wrong?
    Edited by: skymonster84 on Mar 8, 2011 5:12 PM

    Hi,
    I think MULTISET operators might interest you.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/operators006.htm
    Not tested :
    UPDATE tracer_search_schedule_lot_num
    SET not_found_sor_lot_num =
          sorting_lot_number
          MULTISET EXCEPT ALL
          CAST(
            MULTISET(
              SELECT distinct sorting_lot_number
              FROM search_schedule_result_lot_num
              WHERE job_id = 8
            AS search_data
    WHERE job_id = 8
    ;

Maybe you are looking for

  • Create Service Consumer BS: java.lang.NoClassDefFoundError

    Hello, I am trying to create service Consumer Business Service (consume a Web Service from JD Edwards Enterprise One). To do that I have followed the next steps: 1) Download the WSDL file from CRM On Demand’s web page 2) From JDE: a. Create a busines

  • Unable to export the schema by the name OPS$BDIT  using expdp

    Hi, oracle - BDMSD> expdp directory=EXPORT_BACKUP_DIR schemas=OPS$BDIT dumpfile=test.dmp logfile=test.log Export: Release 10.2.0.4.0 - 64bit Production on Monday, 30 January, 2012 10:08:27 Copyright (c) 2003, 2007, Oracle. All rights reserved. Userna

  • How to send the Adobe page as mail attachement from webdynpro...

    Hi Experts, How to send the Adobe page as external mail attachment from webdynpro automatically (for example: If I input the data for sales order in a view and created the sales order, if the sales order is created then have to place the created sale

  • IPhone backup (in icloud) doesn't appear later (for restoring)

    Hello, I have all these iDevices, with iOS 5 and with backups in iCloud: iphone 3GS iPad iPhone 4S (let's call this "4S1") I have received a second (new) iPhone 4S (let's call it "4S2"), and want to use it instead of 4S1, so I thought I could iCloud

  • Suggested feature - wire-format aware binary extractor

    I would like to suggest another feature, which might or might not improve performance of querying unindexed attributes (possibly at the cost of some more bytes in the wire-format).      We found that in case of querying caches with many keys, but no