UNION, function

Good Morning Everyone,
We have a query used UNION for requirement output.
Is it possible to put as in function?
If YES, please let us know how to do it.
If NO:
Do we have any other options?
Thanks in advance,
NY

Thanks for promptly responds!
This is our query:
SELECT DISTINCT R.CLASS_ID, (to_date(C.End_DATE) - to_date( C.START_date)+ 1),FF.FORMAT_NAME,C.START_DATE,C.END_DATE,C.START_TIME, C.END_TIME, LF.LOCATION_DESC, SF.SPONSOR_NAME,CO.COURSE_TITLE,
C_S.CRED_ETHICS, C_S.CRED_SKILLS,C_S.CRED_PRAC_MGMT, C_S.CRED_PROF_PRAC, C_S.CRED_GENERAL, C.TOTAL_HOURS, U.LNAME, U.FNAME,
BF.BARG_NAME, AF.AGENCY_CODE
FROM (SELECT CO.CRED_ETHICS, CO.CRED_SKILLS, CO.CRED_PRAC_MGMT,
CO.CRED_PROF_PRAC, CO.CRED_GENERAL
FROM CLASSES C, COURSES CO, REGISTRATIONS R
WHERE (
(R.CLASS_ID = C.CLASS_ID)
AND (C.COURSE_ID = CO.COURSE_ID)
AND ((PRJ.HAS_CLASS_OVERRIDE(2) = 'N'))
AND (C.CLASS_ID =2))
UNION
SELECT OC.CRED_ETHICS, OC.CRED_SKILLS, OC.CRED_PRAC_MGMT,
OC.CRED_PROF_PRAC, OC.CRED_GENERAL
FROM CLASSES C, REGISTRATIONS R, OVERRIDE_CREDITS OC
WHERE (
(R.CLASS_ID = C.CLASS_ID)
AND (OC.CLASS_ID = C.CLASS_ID)
AND (PRJ.HAS_CLASS_OVERRIDE(2) = 'Y')
AND (C.CLASS_ID =2))
) C_S, COURSES CO, USERS U, CLASSES C, REGISTRATIONS R,
CLASS_DETAILS CD, LOCATIONS_RF LF, FORMATS_RF FF,
SPONSORS_RF SF, BARG_UNITS_RF BF,AGENCIES_RF AF
WHERE (
(R.USER_ID = U.USER_ID) AND (R.CLASS_ID = C.CLASS_ID)
AND (CD.LOC_ID = LF.LOC_ID) AND (R.CLASS_DET_ID = CD.CLASS_DET_ID)
AND (CD.FORMAT_ID = FF.FORMAT_ID) AND (C.COURSE_ID = CO.COURSE_ID)
AND( (CD.FORMAT_ID IN (1,4,5)))
AND (C.SPONSOR_ID = SF.SPONSOR_ID) AND ( U.BARG_ID = BF.BARG_ID )
AND ( U.AGENCY_ID = AF.AGENCY_ID )
AND (R.ATTENDANCE_LIST_IND<>'Y')
And (C.CLASS_ID = 2)
) ORDER BY U.LNAME
If you have any more questions for me, please let us know.
Edited by: New Yorker on Aug 27, 2010 8:48 AM
Edited by: New Yorker on Aug 27, 2010 8:55 AM

Similar Messages

  • Union All Function

    HI All,
    I am trying to make one query in wich i want territory wise sales report but i want to reflect it as territory 1 and its total than territory 2 and its total will union function will give me that result.
    So need help.
    Thanks-
    Mona

    Try:
    SELECT T2.descript,SUM(T0.DocTotal) 'Total Revenue',SUM(T0.GrosProfit) 'Gross Profit', 100*SUM(T0.DocTotal)/(SELECT SUM(DocTotal)
    FROM OINV) '% Total Revenue',100*SUM(T0.GrosProfit)/(SELECT SUM(GrosProfit)
    FROM OINV) '% Total Gross Profit'
    FROM OINV T0
    INNER JOIN OCRD T1 ON T1.CardCode=T0.CardCode
    INNER JOIN OTER T2 ON T2.territryID=T1.Territory
    GROUP BY T2.descript
    UNION ALL
    SELECT 'Total',SUM(T0.DocTotal) 'Total Revenue',SUM(T0.GrosProfit) 'Gross Profit', 100,100
    FROM OINV T0
    INNER JOIN OCRD T1 ON T1.CardCode=T0.CardCode
    INNER JOIN OTER T2 ON T2.territryID=T1.Territory

  • Need Help in Union of Columns in FX

    Hello Experts,
    In database I have a table having two columns, Version From, Version To.
    Column "Version Start" data is like
    V0, V1, V2, V3, V4....upto V11 (fixed value)
    Column "Version End" data is like
    V1, V2, V3..... upto V11 (fixed value V0 is not present)
    User requirement is like create two prompts on these columns and select the data
    between these two fields and see the report. This is achieved by prompt and presentation variable.
    But the problem is let say user select V1 from Version Start, then Version End prompt should show all values apart from V1.
    If user select V2 then it should all value in Version End apart from V2.
    I tried but it seems 'union' function does not work in rpd bmm, nor in fx in OBIEE 10g.
    Can you all please help.
    Thanks

    The easiest way to do this, and it could be done in a few minutes, would be to move to a currently supported version of Oracle, 11gR1 or 11gR2, where we have the PIVOT and UNPIVOT operators.
    In the desupported version you have the best choice is to hit http://asktom.oracle.com and look up the solution he published there some years ago.
    I don't have the link so you can find it as fast as I can but look under "pivot" and "crosstab."

  • How to use the SQL 'union' in Business Objects???

    Post Author: tatun
    CA Forum: Data Integration
    Hi eveyone. I have to write the following SQL code in Business Objects.The code has some 'union' inside the same query. I have tried to make some unions in the Data Provider, but I can just do 8 unions, and I need to do much more.
    How could I do it?
    SELECT '20 ERRORES' TIPO, COUNT() NUM, CONCAT (TO_CHAR(ROUND((count()*100)/8023,2)),' %') PORCENTAJE
    FROM PALETS
    WHERE posicion is not null
    and PALET NOT IN
    -- MATERIAS PRIMAS
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.tipo_producto = 'ROH'
    and (p.cod_producto like '%QA%' or p.cod_producto like 'E00%' or p.cod_producto like 'PU%')
    and p.estado_m not in ('E','P','F','M','A','B','C')
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- GRANELES
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and ((p.tipo_producto = 'ROH'
    and (p.cod_producto not like '%QA%'
    and p.cod_producto not like 'E00%'
    and p.cod_producto not like 'PU%'))
    or p.tipo_producto = 'HALB')
    and p.estado_m not in ('E','P','F','M','A','B','C')
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- MATERIAL DE ACONDICIONAMIENTO
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.tipo_producto = 'VERP'
    and p.estado_m not in ('E','P','F','M','A','B','C')
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- PRODUCTO TERMINADO PLANTA 0008
    select P.PALET
    from palets p, estanteria e, license l
    where p.posicion = e.posicion
    and p.palet = l.single_plate
    and p.tipo_producto = 'FERT'
    and p.estado_m not in ('E','P','F','M','A','B','C')
    and p.posicion is not null
    and e.estado = 'O'
    and l.ctry_code = '0008'
    and p.clase_palet = 'P'
    union
    -- PRODUCTO TERMINADO PLANTA 0012
    select P.PALET
    from palets p, estanteria e, license l
    where p.posicion = e.posicion
    and p.palet = l.single_plate
    and p.tipo_producto = 'FERT'
    and p.estado_m not in ('E','P','F','M','A','B','C')
    and p.posicion is not null
    and e.estado = 'O'
    and l.ctry_code = '0012'
    and p.clase_palet = 'P'
    union
    -- PALETS ASOCIADOS A ORDENES DE EXPORTACIONES
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'E'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- PALETS ASOCIADOS A ORDENES DE EMPAQUETADO
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'P'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- PALETS ASOCIADOS A ORDENES DE FABRICACION
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'F'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- PALETS DE MANTENIMIENTO
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'A'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- MUESTRAS DE RETENCION
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'B'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- MISCELANEO DE SUSTANCIA CONTROLADA
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.estado_m = 'C'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- MISCELANEOS
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.tipo_producto = 'NONI'
    and p.estado_m = 'M'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- PALETS VACIOS
    select P.PALET
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.tipo_producto = 'NONI'
    and p.estado_m = 'D'
    and p.posicion is not null
    and e.estado = 'O'
    and p.clase_palet = 'P'
    union
    -- UNIDADES DE TRANSPORTE
    select p.palet
    from palets p, estanteria e
    where p.posicion = e.posicion
    and p.clase_palet = 'T')
    Thanks

    Post Author: bhofmans
    CA Forum: Data Integration
    In Data Integrator we provide UNION functionality via the MERGE transform. However, it looks like your question is related the the IDD product line (Business Objects Enterprise), so please post your question to the appropriate sub-forum to get answers for BOE.
    Thanks,

  • Compiling Procedures/Packages/Functions

    I'm fairly new to the arena of compiling Procedures/Packages/Funcitons but I was given the task of updating a development DB with a lot of newly created/updated Objects. I have created a shell script to go through all the new files and create or replace all the new objects in sqlplus. My question is how to compile all the newly created objects and their dependencies correctly? I have been using SQL Developer to verify that everything has compiled but I see that some are marked invalid which I assume is because a dependency was compiled after it. What would be my best way to making sure everything is valid? I hope this makes sense but any help would be appreciated.

    You can use a script like this to build your own sql statement to compile the invalid objects. You can add your own statement for other object types at the end with a union, ie TYPE body.
    You will probably need to run it repeated until all objects are VALID. You can put it in a PL/SQL block with a loop and execute immediate so reduce the manual work.
    --PACKAGE
    select 'alter package ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PACKAGE'
    union
    -- PACKAGE BODY
    select 'alter package ' || object_name || ' compile body;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PACKAGE BODY'
    union
    --PROCEDURE
    select 'alter procedure ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PROCEDURE'
    union
    --FUNCTION
    select 'alter function ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'FUNCTION'
    union
    --TRIGGER
    select 'alter trigger ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'TRIGGER'
    union
    --VIEW
    select 'alter view ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'VIEW'

  • Inventory on Hand Report - Using Union ALL - need two fields to be part of the group

    Hi all,
    I have created an Inventory "on Hand" Report that takes the Current Inventory from the Item Entry table and the Sales from Unposted Sales Line table and Transfers in and out from the Unposted Transfer Line table.  I have joined the tables
    using the UNION ALL function. 
    My problem is that the Transfer table has two locations whereas the other tables only have one.  I am grouping on Location code from the Item Entry table which is equivalent to BOTH Transfer from location and the Transfer to.    
    As an example, there are 15lbs of inventory for Product A in Location #1 with a transfer out of 15 lbs.  The Transfer out is going to Location #2
    I don't know how to write the query or set up the group so that it recognizes both the Transfer to and the Transfer From fields
    I want the report to look similar to the one below but I can only get it to show one of the locations.  Is there some way to use the Union function and have one field in the first table be or equivalent to two fields in another?
    Location   Code
    Item No.
    Lbs
    Sales Orders
    Transfer Out
    Transfer In
    Available   Inventory
    Location #1
    Product A
    15
    -15
    Location #1
    15
    -15
    Location #2
    Product A
    15
    15
    Location #2
    15
    15

    Hi Igor,
    You can get a custom sort order added to your IP column without the need for a second column.
    Consider that the sorting is done strictly left-to-right across a string in the column. The string can be any valid HTML content. So, you could wrap your string within, say, a SPAN tag and add an attribute to that tag that contains the sort order you need before the text that is displayed to the user. As long as the attribute is correctly structured (that is, all instances are of the same length, for example), then sorting will work correctly. For example:
    SELECT
    '<span title="' || PAD_IP_ADDRESS(IP) || '">' || IP || '</span>' Y
    FROM ...Now you need to ensure that the PAD_IP_ADDRESS() function returns the correct values. In IP addresses, you have anything from "0.0.0.0" to "255.255.255.255". To get them to sort "numerically", you need to pad one or two digit numbers to get three digit numbers for each value - so, "0.0.0.0" becomes "000.000.000.000". You could create a function to do this - something like:
    CREATE OR REPLACE FUNCTION PAD_IP_ADDRESS
      pIP IN VARCHAR2
    RETURN VARCHAR2
    IS
      vIP VARCHAR2(15);
      vTEMP APEX_APPLICATION_GLOBAL.VC_ARR2;
      vSEP VARCHAR2(1);
    BEGIN
      vSEP := '';
      vIP := '';
      vTEMP := APEX_UTIL.STRING_TO_TABLE(pIP,'.');
      FOR x IN 1..vTEMP.COUNT
      LOOP
        vIP := vIP || vSEP || TRIM(TO_CHAR(TO_NUMBER(vTEMP(x)),'000'));
        vSEP := '.';
      END LOOP;
      RETURN vIP;
    END;The output from this would look something like:
    &lt;span title="001.001.001.001"&gt;1.1.1.1&lt;/span&gt;
    &lt;span title="002.255.255.255"&gt;2.255.255.255&lt;/span&gt;
    &lt;span title="010.001.199.098"&gt;10.1.199.098&lt;/span&gt;Andy

  • Aggregate Union

    Hi Dan,
    You wrote in some message that "...in 9i we have an aggregate union function that..."
    I'd like to know more about it and how can I perform the union all using
    this aggregate function besides the procedure below:
    UNIAO_BUF:=NULL;
    FOR TabAux IN AREA_CUR
    LOOP
    UNIAO_BUF := SDO_GEOM.SDO_UNION(UNIAO_BUF,TabAux.Geom,0.005);
    END LOOP;
    Thanks,
    Rosbngela.

    How about something like:
    SELECT /*+ ordered */
    sdo_aggr_union(mdsys.sdoaggrtype(a.geom, 0.5)) aggr_geom,
    uniao_bug
    FROM tab1 b,
    tab2 a
    WHERE b.geom = 'GEOM_YOU_ARE_INTESRESTED_IN'
    AND sdo_relate(a.geom, b.geom,
    'mask=ANYINTERACT querytype=WINDOW')='TRUE' ;

  • Refer Multiset Union value from cursor

    Hi everyone,
    I am new to the concept of pseudo functiona and was just trying to use the multiset union function. I have written a cursor which gives me a column 'buyer' and a corresponding dataset. Now my dilemna is how to refer the elements in the dataset using the cursor. Could anyone please help?
    CREATE TABLE BUYER
      BUYER        NUMBER(4)                        NOT NULL,
      BUYER_NAME   VARCHAR2(120 BYTE)               NOT NULL,
      BUYER_PHONE  VARCHAR2(20 BYTE),
      BUYER_FAX    VARCHAR2(20 BYTE)
    SET DEFINE OFF;
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
    Values
       (110, 'Kendr', '5147, 876', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
    Values
       (101, 'Amelie Dube', '(514),808', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
    Values
       (102, 'Jennifer Baie', '51962,860', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
    Values
       (103, 'Loriannstris', '5333962,785', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
    Values
       (104, 'Sandra St-re', '513962,736', NULL);
    COMMIT;
    create or replace type tab1 is table of varchar2 (30);    
    DECLARE
    cursor c1 is
    select buyer,
          CAST (multiset(select buyer_name from buyer where rownum<4) as tab1) as data1
          from buyer
    MULTISET UNION ALL
    select  buyer,
              CAST(multiset(select buyer_name from buyer where rownum<5) as tab1) as data2
    from buyer;
    BEGIN
      for c_rec in c1
        loop
          DBMS_OUTPUT.PUT_LINE(c_rec.buyer||'~'||c_rec.column_value(1)); --  i want to print all the values in the 'data set' along with the buyer id.
       end loop;
    end;
    error:
    PLS-00302: component 'COLUMN_VALUE' must be declared

    Thanks a lot for your help. Now the one i posted was just to simplify the actual problem. But let me try and give you the complete picture.
    I have a nested table structure:
    Table structure:
                                              ->ExtOfXOrderSkuDesc_TBL -> ExtOfOrderExpDesc_TBL    
        I_message -> ExtOfXOrderDesc_TBL
                                              ->ExtOfXOrderPackDesc_TBL -> ExtOfOrderExpDesc_TBLCould not post the whole table detail as its too big
    CURSOR c_insert_item IS
       SELECT im.item,
              item_diff.import_country_id,
              item_diff.hts_no,
              item_diff.ExtOfOrderExpDesc_TBL --needs to be casted
         FROM TABLE(CAST(I_message.ExtOfXOrderDesc_TBL(1).ExtOfXOrderSkuDesc_TBL AS "RIB_ExtOfXOrderSkuDesc_TBL")) item_diff,
              item_master im
        WHERE item_diff.style_no = im.item_parent
       UNION ALL
       SELECT im.item,
              pack_diff.import_country_id,
              pack_diff.hts_no,
              pack_diff.ExtOfOrderExpDesc_TBL --needs to be casted
         FROM TABLE(CAST(I_message.ExtOfXOrderDesc_TBL(1).ExtOfXOrderPackDesc_TBL AS "RIB_ExtOfXOrderPackDesc_TBL")) pack_diff,
              item_master im
        WHERE pack_diff.style_no = im.item_parent;Now i need to make an union of all the elements including the ExtOfOrderExpDesc_TBL . So i wanted the cast it as multiset. But pardon my ignorance i feel i am lost somewhere. Based on you reply could you suggest how can i make the union and access each element using the cursor record?
    Thanks

  • SSRS report with tabular model – Create a dropdown report parameter with "None" option as the top value.

    Hello Everyone,
    I would like to create SSRS single select dropdown list parameter (it is using MDX query in dataset) with "None" option at the top. Note: this parameter is dependent parameter and getting filtered based on the selection of another parameter.
    How can I add hard-coded "None" text at the top of the parameter values? Can Union function help me to add this hard-coded value? The purpose is, when user selects None from the dropdown ignore the condition of the parameter from MDX query else
    use the selected value in query condition.
    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html

    Hi Ankit,
    In your scenario, you can achieve your requirement in report level other than in query. Add a Filter like:
    Expression: =IIF(Parameters!Name.Value="None",1,Fields!Name.Value)
    Operator:=
    Value: =IIF(Parameters!Name.Value="None",1,Parameters!Name.Value)
    In this case, report will ignore this parameter, and show all the records on the report when selecting “None” value. I have tested it on my local environment, the screenshots below are for you reference.
    Reference:
    Add a Filter to a Dataset (Report Builder and SSRS)
    Regards,
    Charlie Liao
    TechNet Community Support

  • Partial data clear in ASO possible for multiple tuples?

    Hi,
    I am trying to do a partial data clear in an ASO cube. I need to clear FY12->Oct & FY13->Nov (consecutive periods). Here's what I tried:
    +alter database 'GL_TXT'.'GL_TXT' clear data in region '{([FY12],[Oct]),([FY13],[Nov])}' physical;+
    No error is thrown but the data isn't cleared either. The statement finishes execution almost immediately.
    I tried the UNION function but that didn't work either. Here's how my statement looks with the UNION function:
    +alter database 'GL_TXT'.'GL_TXT' clear data in region '{UNION({([FY12],[Oct])},{([FY13],[Nov])})}' physical;+
    Again, no error but no clear either. The UNION pulls the correct data set when used in a Select statement:
    +SELECT UNION({([FY12],[Oct])},{([FY13],[Nov])}) ON COLUMNS FROM GL_TXT.GL_TXT;+
    I can get it to clear if I write separate statements for each period but I want to have them in a single script as I suspect two scripts wouldn't be very efficient.
    Please help!
    Thanks,
    Shashi

    Thanks for your reply Vasavya! Running the region clear scripts twice (once for each month) is still faster for me than using the report script approach. I want to see if having both periods in one statement will improve the performance :)
    Regards,
    Shashi

  • Multi provider data

    Hi,
    We have a Multi Provider which is built on a Master data object and a DSO.
    We included 2 navigational attributes of the master data object in the Multi Provider.
    But the Multi Provider is not displaying any data for the Navigational attributes.
    When we check the master data object, we have 2 records for one product .
    one record has all the values are filled in and the 2nd record is not filled up with values.
    Our Multi Provider is picking up the 2nd record for each product.
    But in query, we have display the values.
    Please suggest us how to get these values in the Multi Provider.
    Thanks & Regards,
    Jyothi.

    Hi Jyothi,
    Multiprovider works on Union functionality and it fetches data from all the underlying infoproviders. In case of navigation attributes data is displayed in the query from actual master data objects, you do not need to include the master data object in multiprovider for using navigation attributes.
    Once navigation attributes are marked for available for reporting in underlying infoprovider they will be available in query and data shown will be from masterdata infoobject.
    Just check that you have activated master data infoobject properly and then see the query output. Finally check if there is any filter in report.
    Regards,
    Durgesh.

  • SDO_AGGR_UNION very slow

    Hello friends,
    I'm having problems with SDO_AGGR_UNION function in Oracle 11.2.0.3. The performance is very bad.
    I need to aggregate several polygons (645) using SDO_AGGR_UNION.
    My table is:
    SQL> DESC GC_MUNICIPALITY;
    Nome Nulo Tipo
    STATE_ID NOT NULL NUMBER(5)
    GEOLOC SDO_GEOMETRY()
    First I ran the following query:
    SELECT SDO_AGGR_UNION(SDOAGGRTYPE(geoloc, 0.5)) geoloc
    FROM GC_MUNICIPALITY
    WHERE STATE_ID = 35
    Execution time: 57 minutes
    Then, I ran then aggregate union with groupings:
    SELECT SDO_AGGR_UNION(SDOAGGRTYPE(geoloc,0.5)) geoloc
    FROM
    (SELECT SDO_AGGR_UNION(SDOAGGRTYPE(geoloc,0.5)) geoloc
    FROM
    (SELECT SDO_AGGR_UNION(SDOAGGRTYPE(geoloc,0.5)) geoloc
    FROM
    (SELECT SDO_AGGR_UNION(SDOAGGRTYPE(geoloc, 0.5)) geoloc
    FROM GC_MUNICIPALITY
    WHERE STATE_ID = 35
    GROUP BY MOD(ROWNUM, 15))
    GROUP BY MOD (ROWNUM, 7))
    GROUP BY MOD (ROWNUM, 2)
    Execution time: 15 minutes
    The second execution was faster than the first, but still very slow.
    If I use ArcGis, PostGis or JTS, the same aggregation is executed in few seconds.
    Why is this function so slow in Oracle?
    Is there another way to accomplish this aggregation with better performance?
    I read in another forum that if I convert from SDO_GEOMETRY to SDO_TOPO_GEOMETRY the aggregation is faster. However, the SDO_AGGR_UNION works only with SDO_GEOMETRY type. Is there any way to aggregate SDO_TOPO_GEOMETRY?
    Thanks!
    Edited by: user12000327 on 03/04/2012 09:30
    Edited by: user12000327 on 03/04/2012 09:33

    Siva,
    This group by won't work as you hit that internal limit in the server.Patently! I provided this example because this is what people want in an aggregate and it is the way most people think of it.
    So try the other approach described in the user guide using a function that creates a geometry array and passes it to the union function.OK, two more assertions:
    1. Working with users over the years I have discovered they can use SQL reasonably well but I am surprised how many simply don't want to go down a PL/SQL function route!
    2.The example given is very opaque as to how to do a SELECT ... GROUP BY aggregation using sdo_aggr_set_union.
    Personally, I would prefer to expose the grouping value....
    CREATE OR REPLACE FUNCTION Set_Geometry(p_value in varchar2)
    RETURN SDO_GEOMETRY_ARRAY
    deterministic
    AS
      c_query   SYS_REFCURSOR;
      v_g       sdo_geometry;
      v_GeomArr sdo_geometry_array;
    BEGIN
      v_GeomArr := SDO_GEOMETRY_ARRAY();
      OPEN c_query FOR 'select a.geometry from admin a where a.blockcode = :1'
                 USING p_value;
       LOOP
        FETCH c_query into v_g;
         EXIT when c_query%NOTFOUND ;
         v_GeomArr.extend;
         v_GeomArr(v_GeomArr.count) := v_g;
       END LOOP;
       RETURN v_GeomArr;
    END;
    -- Which is called like so:
    select a.group_code, count(*) as aggrCount, sdo_aggr_set_union(set_geometry(a.group_code),0.005) as geoms
    from admin a
    where a.hierarchy_code = 'WA'
    group by a.group_code;But this is quite inflexible because it really isn't a generic function but rather a function for a specific piece of SQL.
    Because of this I prefer something more generic:
    CREATE OR REPLACE FUNCTION Set_Geometry(p_cursor in SYS_REFCURSOR)
    RETURN SDO_GEOMETRY_ARRAY
    DETERMINISTIC
    AS
       v_geom    sdo_geometry;
       v_GeomArr sdo_geometry_array;
    BEGIN
       v_GeomArr := SDO_GEOMETRY_ARRAY();
       LOOP
        FETCH p_cursor INTO v_geom;
         EXIT when p_cursor%NOTFOUND ;
         v_GeomArr.extend;
         v_GeomArr(v_GeomArr.count) := v_geom;
       END LOOP;
       RETURN v_GeomArr;
    END;
    -- Results
    FUNCTION Set_Geometry compiled
    -- Now here's how to use it in a SELECT .... GROUP BY ...
    select group_code,
           count(*) as aggrCount,
           sdo_aggr_set_union(set_geometry(CURSOR(SELECT b.geometry FROM test_table b WHERE b.group_code= a.group_code)),0.005) as geoms
    from test_table a
    where a.hierarchy_code = 'WA'
    group by a.group_code;Now I agree SDO_AGGR_SET_UNION is much faster and, with my function, more flexible but it is still ugly.
    I am not an expert on this issue of that system limit of 30k sort area. When we talk to internal groups about it, they always
    ask us to show the customer filed ER. So it will really help if customers like you file an official ER for this.Surely someone in the spatial team is an expert!
    I can't file an ER because my Oracle use is under an OTN license for development purposes. I have asked complaining customers to do so over the years but for some reason they don't so I am left to make a fool of myself on their behalf.
    Having said that, the main problem with this approach is still the multiple copies of the data which tends to take up
    most of the time. So we are coming up with a better way to call sdo_aggr_set_union that avoid this multiple copies of the data.In your UC presentation? It is good for the public to know that the OS team is always trying to make things better and faster.
    regards
    Simon

  • Row Wise Control position in OBIEE

    Hi,
    I have report secenario like this , a columne has 3 rows, but each row as a calculation
    Column1 Column2
    row1 row1
    row2 row2
    row3 row3 by using union function i am getting columns as rows .In column1 - row1,row2 and row3 has hard code information and column2 row1,row2,row3 has value from tables. Now i need to change the value in column2 row3 dynamically and background color also .How to acheive this Please suggest me in right way.
    Regards,
    Manikumar

    log your query in below OBIEE forum
    http://forums.oracle.com/forums/category.jspa?categoryID=145
    Now i need to change the value in column2 row3 dynamically and background color also .How to acheive this Please suggest me in right way.you can change the background color dynamically. but what the exact meaning of dynamically.
    Cheers
    Nawneet

  • Sales order in EURO - invoice in PLN currency

    we have 2 customers
    for them we need to create price list for 150 materials in EURO
    these customers could put orders only via mail or phone
    when they would send mail with sales order to our Sales Department we need to put this order in Euro currency
    but invoice for that order shoud be in Polish cirrency
    in other cases we use our Polish currency...
    could you guide me ?

    Hi,
    Please follow this link.
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/6d/53d3ce162f11d2a5b70000e835329b/content.htm
    Please also try on following menupath
    SPRO-IMG-Cross application components-european monetary union-function and setting for dual currency phase-sales & distribution.
    Thanks,
    Vrajesh

  • Visual Composer cookie

    Hi,
    I'm developing a iView in VC. This iView shall show the updated result from 5 different queries from SAP BI system.
    The iView must be showing the queries as a circle shaped cookie with different colors.
    How do I proceed this task;
    - 1 iView pr. query and put them together in a page?
    -  Create 1 iview that proposes the 5 different queries in one, by using union function?
    - How do I set different colors to the queries (I need to separate the results in the circle iView).
    Kr.,
    hilde

    The problem was access to the SAP R3 system RFC authorization.
    Check st22--> RFC NO AUTHORITY.
    After getting the auth. for RFC, its now working.
    Bye..
    Ajay

Maybe you are looking for