Product owner commissions

Hi,
My client sells downloadable products which are created by the public. After every sale, my client wants to be able to pay a commission to the product creator, but I am having problems working out the best way to do this.
A standard BC affiliate program  pays out a percentage but relies on affiliate urls so the correct affiliate receives a payment. This wouldn't work in this case as when product A is sold, the creator of product A is to receive a commission and nobody else.
A support member suggested manually creating an order report and then paying commissions on this basis.
Is there an easier, automated way of getting this to work?

Look at the actual products, you have all the commision stuff there on the product

Similar Messages

  • Mass Updating Opportunity Product Owner field

    We need to change the owner of hundreds of opportunities. We were able to do a batch update on the Owner/Account Manager field for the opportunity, but the opportunity product records still have the old owner.
    Is there a way to mass updates that field without doing an export then reimport with an over-ride?

    This could be done using web services.

  • Product Owner Assessment Survey - Have your say!

    Hi all
    The User Design and Research Team is calling for your feedback on our products and we are listening hard.
    Please just take a few minutes to check out this article with details. 
    Thank you in advance!
    Community Advocate Program Manager
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

    I have a need to supply a guest network, ideally without introducing additional APs. I have APs that can have additional SSIDs with their own VLANs. I have a router that is not VLAN-aware, but has two physical ports, one of which is for the corp network and the other for the guest (the router ports are isolated). Everything connects through a switch that is VLAN-aware.
    What I'd like to be able to do, is connect both ports from the router to the switch, and configure so that VLAN2 can only communicate to the guest port on the router. And the default VLAN (VLAN1) can only communicate to the default VLAN ports on the switch.A picture is worth a lot more:DLink switch is a DGS-1210-24.I'm getting confused between VID, PVID, 'tagged', 'untagged', and 'not a member', and asymmetrical/symmetrical VLANs.
    I think what I want is:- enable...

  • Product Owner Assessment Survey - we are listening!

    Hi all
    The User Design and Research Team is calling for your feedback on our products and we are listening hard.
    Please just take a few minutes to check out this article with details. 
    Thank you in advance!
    Community Advocate Program Manager
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

    @ Onepamopa - thank you for voicing out. I really thought I was one unlucky customer and one of a few to experience such inconvenience and distress over a product and design that Lenovo took pride in. I too have spent 1 month trying to solve the problems with a brand new Lenovo Yoga Pro 3. I am now using laptop number four of the same model in 1 month, a proof of my blind faith in this product and increasing disillusionment....and deludedness... I was already advised by friends and colleagues, after laptop 1 that I should perhaps change brands... Objectively speaking, the after sales service i.e. technical and service support were very helpful, however, when purchasing a brand new product you wouldn't think you'd have problems already from hour 1. Front line and customer service attitude were less than professional and frankly quite rude. I was lucky that I'd purchased through a retailer...otherwise my brand new laptop would be out of the shop and sent straight to repair. @ Limpaar - also thank you for sharing your point. I thought it was great when this assessment came out (though also somewhat ironic)... that there was a channel where I could communicate with Lenovo...where customers' views would be valued and heard... I then was filtered out on the second page and that was the end of that... Is there a Lenovo representative online? I'm not one to cry online without first assessing and taking alternative steps to solve the problem...I have been co-operating and I'd say pretty patient...  Lenovo.... where are you?... Those that do... 

  • Product ownership

    I am doing a lot of opportunity-product history reporting using custom fields in the 'Owned by User' section to add extra information about the opportunity owner
    In the opportunity-product history the Owned by User relates to the product owner and not the opportunity owner. This is fine when specific products have been created by the user but I am having big problems where no products have been specified yet.
    Unlike other posts here I want to report opportunities with 'Unspecified' products
    My reports are going wrong where the 'owner' of the Unspecified' product does not agree with the opportunity owner
    My tests suggest the person who created the opportunity is not automatically the owner of the Unspecified product
    Does anyone know HOW CRM on Demand decides who the owner of the Unspecified Product should be?
    So far I have reviewed over 100 opportunity records and it is definitely not always teh person who created the opportunity. There seems to be a link with opportunity and account teams but nothing I can put my finger on....

    Thanks Tim
    The reports contain custom fields in the 'Owned by User' section. Its not a case of displaying the owner but extra information about the owner
    We need to understand how the ownership is assigned or how to change ownership of the Unspecified product
    Best wishes
    Richard

  • VC reference char not auto-populating on Production Order

    Experts,
    I've created a reference char CAUFV_AUTYP & included it on my class 300. Intent is to influence certain behavior on the stand alone Production Order (CO01) configuration using VC (Header >> Configuration section).
    Expectation is that when a Production Order is created, the CAUFV_AUTYP will get defaulted to a value "10" (for Production Orders) & when that happens, I want the VC to enable certain things for me on the configuration screen. I'm trying to write a selection condition & a pre-condition using the value of CAUFV_AUTYP = 10.
    Problem - When I create a stand alone production order, I'm not seeing the CAUFV_AUTYP value auto populate to "10".
    Any ideas on this? I was hoping that even before the Production Order commit to the CAUFV table happens, it shud have been able to read the AUTYP=10 & populate on the production order.
    Thanks

    I don't know whether you can do so.  According to SAP help, you can only change BOM component (STPO table), task list operation (PLPOD), Sequence (PLFLD),  and PRT value (PLFHD).  You can put the object dependencies in BOM or routing. 
    You cannot just change any field in production orders (why would you want to change the field order category in the first place?).
    You can also change the sales order via VCSD_UPDATE table.  The object dependencies should reside in your configuration profile in this case.
    Rgrds,
    See the link for more detail.
    [http://help.sap.com/saphelp_erp60_sp/helpdata/en/92/58d455417011d189ec0000e81ddfac/frameset.htm]
    Edited by: ayethebing on Apr 17, 2011 3:37 PM

  • Recovery - Product Key unreadable

    I have a Satellite A505-S6960 whose hard drive failed.  Got new HD.  I don't have recovery media and the Product key on bottom of laptop is unreadable.  Is it worth it to get recovery media if I can't read the product key?  I assume product key is needed during recovery, is that a correct assumption?
    Thanks,
    Solved!
    Go to Solution.

    Old thread but lots of interest to new product owners.
    This seems to be the generic response to questions about doing a "clean install".
    In the previous question, it was stated the HD was trashed, and no Toshiba back up was available.
    It's rather pointless to point out something that is irreverent to the question.
    Here's the deal, new owners. When the HD gets trashed, and you attempt to install another legal windows copy, the OEM product number will do you no good. Even in doing a Toshiba back up, the product will not be reloaded registered, and you will be without a means to register your back up reinstall.
    Hope that you purchased an extended warranty. It will go something like this over the phone. They will step you through the back up process. You will tell the person no back up image is available, and they will provide a service number, send you a box, and you will send you're new computer in to have the OS reinstalled.
    Now one would think during service, since the Toshiba recovery disk does not cost (aside shipping $29.00), they the process would be well thought out enough to include the "Free" copy when returning the unit.
    This isn't just with this brand. Most all manufactures do business this way now.
    Not a happy customer, especially when direct questions are posted wanting information on how to activate Windows after  clean install go unanswered, other than to say "you don't need one".
    IF any of this is in error, please provide information as to what product number to enter when reinstalling Windows 7. Make sure it's one that is acceptable to MicrosoFt as they won't activate the product number supplied on the bottom of your brand spanking new laptop.

  • Product team for Edge

    Hi I have some specific road map questions regarding Edge, can someone provide me with a product owner contact for Edge?  Thank youAaron G.Systems EngineerUS DoD

    Hi
    check the keys in lines 72 and 73 of the actual version of the temporary BOBJ keys excel file.
    You can download the file in SMP. Go to http://service.sap.com/support, navigate to Keys & Requests and click on the Obtain BusinessObjects temporary license key (ZIP file) link.
    Regards,
    Stratos

  • Cursor within the cursor showing error

    Hi,
    I am using a cursor within the cursor to create a procedure.I am getting the below error while compiling this
    15/7 PL/SQL: SQL Statement ignored
    16/14 PL/SQL: ORA-00942: table or view does not exist
    79/10 PL/SQL: Statement ignored
    82/31 PLS-00364: loop index variable 'I' use is invalid
    84/10 PL/SQL: Statement ignored
    84/50 PLS-00364: loop index variable 'I' use is invalid
    98/10 PL/SQL: Statement ignored
    101/31 PLS-00364: loop index variable 'I' use is invalid
    103/10 PL/SQL: Statement ignored
    103/50 PLS-00364: loop index variable 'I' use is invalid
    Am i using a wrong syntax,Could anyone help me on this..Please find my procedure code below
    CREATE OR REPLACE PROCEDURE DM_EIS.YOY_PURGE_PRC
    AS
    VAR_TEMP NUMBER := 1;
    VAR_TAB_NAME VARCHAR2(100);
    VAR_TAB_OWNER VARCHAR2(100);
    --For fetching table list to be processed
    CURSOR CUR_ONE IS
    SELECT OWNER,TABLE_NAME,FILTER_DATE,FILTER_VALUE
    FROM DM_EIS.NONPART_PURGE_CTL WHERE NVL(STATUS,'NULL') <> 'COMPLETED'
    AND PURGE_PREFERENCE='Y';
    --For fetching indexs that are to be disabled
    CURSOR CUR_IND IS
    SELECT * FROM DBA_INDEXES WHERE TABLE_NAME = var_tab_name
    AND OWNER = var_tab_owner
    AND UNIQUENESS <> 'UNIQUE';
    BEGIN
    FOR C IN CUR_ONE
    LOOP
    --CHECK IF TEMP TABLE IS ALREADY PRESENT, IF SO DROP IT.
    SELECT COUNT(*) INTO VAR_TEMP FROM ALL_TABLES WHERE TABLE_NAME = 'T_NOPART_PURGE';
    IF VAR_TEMP = 1
    THEN
    EXECUTE IMMEDIATE 'DROP TABLE DM_EIS.T_NOPART_PURGE';
    END IF;
    ---update the columns of Control table
    UPDATE DM_EIS.NONPART_PURGE_CTL
    SET STATUS = 'RUNNING'
    WHERE TABLE_NAME = C.TABLE_NAME
    AND OWNER = C.OWNER;
    COMMIT;
    UPDATE DM_EIS.NONPART_PURGE_CTL
    SET START_TIME = SYSDATE
    WHERE TABLE_NAME = C.TABLE_NAME
    AND OWNER = C.OWNER;
    COMMIT;
    --Check whether the column value is date or year
    IF C.FILTER_VALUE = 'YEAR' THEN
    --Move data to temp table and truncate main table
    execute immediate 'create table DM_EIS.T_NOPART_PURGE as select /*+ PARALLEL(ext,4) */ ext.* from '||c.owner||'.'|| c.table_name || ' ext where nvl(' || c.FILTER_DATE || ',''01-Feb-2009'') >= ''2009''';
    DBMS_OUTPUT.PUT_LINE('Truncating the main table'||C.OWNER||'.'|| C.TABLE_NAME);
    EXECUTE IMMEDIATE 'TRUNCATE TABLE ' ||C.OWNER||'.'|| C.TABLE_NAME;
    else
    --Move data to temp table and truncate main table               
    execute immediate 'create table DM_EIS.T_NOPART_PURGE as select /*+ PARALLEL(ext,4) */ ext.* from '||c.owner||'.'|| c.table_name || ' ext where nvl(' || c.FILTER_DATE || ',''01-Feb-2009'') >= ''01-Jan-2009''';
    DBMS_OUTPUT.PUT_LINE('Truncating the main table'||C.OWNER||'.'|| C.TABLE_NAME);
    EXECUTE IMMEDIATE 'TRUNCATE TABLE ' ||C.OWNER||'.'|| C.TABLE_NAME;
    end if;
    var_tab_name := c.table_name;
    var_tab_owner := c.owner;
    --Disable the indexes and load data back to main table,
    for i in cur_ind
    loop
    execute immediate 'Alter index '||c.OWNER ||'.'|| i.index_name || ' unusable';
    dbms_output.put_line(c.OWNER ||'.'|| i.index_name||' is unusable');
    end loop;
    ---insert back the data into the table from temporary table
    execute immediate 'insert /*Append*/ into '||c.OWNER ||'.'|| c.table_name || ' select /* PARALLEL(tmp,4) */ tmp.* from DM_EIS.T_NOPART_PURGE tmp';
    commit;
    --Rebuild the indexes
    for i in cur_ind
    loop
    execute immediate 'Alter index '||c.OWNER ||'.'|| i.index_name || ' rebuild compute statistics';
    dbms_output.put_line(c.OWNER ||'.'|| i.index_name||' is rebuilt');
    end loop;
    --Gather stats for the table
    DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>c.OWNER,
    TABNAME=>c.table_name,
    CASCADE=>TRUE,
    ESTIMATE_PERCENT=>dbms_stats.auto_sample_size
    dbms_output.put_line(c.OWNER ||'.'|| c.table_name||' is analyzed');
    ---update the columns of Control table
    update DM_EIS.NONPART_PURGE_CTL
    set status = 'COMPLETED'
    where TABLE_NAME = c.TABLE_NAME
    AND OWNER = C.OWNER;
    commit;
    UPDATE DM_EIS.NONPART_PURGE_CTL
    SET END_TIME = SYSDATE
    WHERE TABLE_NAME = C.TABLE_NAME
    AND OWNER = C.OWNER;
    COMMIT;
    UPDATE DM_EIS.NONPART_PURGE_CTL
    SET ELAPSED_TIME =ROUND((END_TIME-START_TIME)*1440,2)
    WHERE TABLE_NAME = C.TABLE_NAME
    AND OWNER = C.OWNER;
    COMMIT;
    UPDATE DM_EIS.NONPART_PURGE_CTL
    SET LAST_UPDATED_DT = SYSDATE
    WHERE TABLE_NAME = C.TABLE_NAME
    AND OWNER = C.OWNER;
    COMMIT;
    dbms_output.put_line('Data Purging is done for '||c.OWNER ||'.'|| c.table_name);
    end loop;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20003,' ERROR IN DM_EIS.NONPART_PURGE_PRC'|| SQLCODE||'-'||SQLERRM);
    End;
    /

    Oracle is not a Microsoft product. What it appears you are doing is a phenomenally efficient way to bring your database to its knees whimpering and begging that you take a class from Oracle University.
    Temporary tables in Oracle are permanent tables and that is the proper design for working with the product. Creating "temp" tables using dynamic SQL in a stored procedure is multiple layers of bad practice layered on top of each other. Something made more obvious by the fact that you appear to not have read that portion of the docs that explain the differences between explicit privilege grants and grants made via roles when it comes to PL/SQL.
    My recommendation is that you throw this code away and read the docs. First on the security model, roles, and object privileges. Next on the use of Global Temporary Tables.

  • Documentation around the Oracle to CfTE integration

    Hi,
    Have a good day!
    Do you have any documentation around the Oracle to Cloud for travel and expense integration? I would like to gain some knowledge around the Integration of CfTE with a Non-SAP system (Oracle).
    Please guide/share any documents.
    Thanks in advance!
    Regards,
    Abiuth Animon S

    Hello Abiuth,
    So far there is no standard documentation Oracle to Cloud for travel and expense integration is available.
    But SAP Product owner / Development colleagues are in process to prepare the same.
    Once it is available , we will update in SCN.
    Unfortunately we cannot commit any time line for the same.
    Regards,
    Rahul Mishra

  • OLAP View Generator Sample

    Creating relational views over dimensions and cubes in an analytic workspace has never been easier. Check out the new sample plug-in for Analytic Workspace Manager 10.2.0.3 that makes creating views a snap.
    1) Right-click a dimension or cube object, then choose Create Relational View...
    2) Choose the columns you'd like to see in your view, then click Create View.
    Your OLAP data is now available to any relational tool. Download the OLAP View Generator from OTN and give it a try. It's fun for the whole family!
    http://www.oracle.com/technology/products/bi/olap/index.html

    I logged a TAR with Oracle and they gave me a pl/sql fix, which works for me now. It looked to be a bug of sorts.
    This is the whole install_olap_view_generator.sql but beware it drops and creates things.....
    prompt Installing OLAP View Generator sample - Version 1.0.2
    prompt
    prompt >> Turning off prompting for substitution variables (set scan off)
    set scan off
    prompt >> Removing the olap_views user. Ignore error if user does not exist.
    drop user olap_views cascade;
    prompt >> Creating OLAP_VIEWS tablespace...
    CREATE TABLESPACE OLAP_VIEWS
    DATAFILE 'OLAP_VIEWS.DBF' SIZE 20M AUTOEXTEND ON NEXT 5M;
    prompt >> Creating OLAP_VIEWS_TEMP temporary tablespace...
    CREATE TEMPORARY TABLESPACE OLAP_VIEWS_TEMP
    TEMPFILE 'OLAP_VIEWS_TEMP.DBF' SIZE 20M AUTOEXTEND ON NEXT 5M
    UNIFORM SIZE 256K;
    prompt >> Creating OLAP_VIEWS user...
    CREATE USER OLAP_VIEWS
    IDENTIFIED BY OLAP_VIEWS DEFAULT TABLESPACE OLAP_VIEWS
    TEMPORARY TABLESPACE OLAP_VIEWS_TEMP
    QUOTA UNLIMITED ON OLAP_VIEWS;
    grant olap_user to OLAP_VIEWS;
    grant create public synonym to olap_views;
    prompt >> Connecting as olap_views user
    connect olap_views/olap_views
    prompt >> Creating tables that store information about OLAP views and mappings
    CREATE TABLE OLAP_VIEWS.OLAP_MAPPINGS
    (     LAST_UPDATED DATE,
         AW_LAST_UPDATED DATE,
         AW_OWNER VARCHAR2(30 BYTE),
         AW_NAME VARCHAR2(30 BYTE),
         CUBE_NAME VARCHAR2(30 BYTE),
         CLAUSE VARCHAR2(30 BYTE),
         OBJECT_NAME VARCHAR2(30 BYTE),
         HIERARCHY VARCHAR2(30 BYTE),
         LEVEL_NAME VARCHAR2(30 BYTE),
         COLUMN_NAME VARCHAR2(30 BYTE),
         AW_OBJECT VARCHAR2(100 BYTE),
         DATA_TYPE VARCHAR2(30 BYTE),
         DIMENSION_DESC VARCHAR2(100 BYTE),
         POSITION NUMBER,
         COLUMN_LABEL VARCHAR2(100 BYTE),
    DESCRIPTION VARCHAR2(1000),
    INCLUDE NUMBER DEFAULT 1
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.LAST_UPDATED IS 'Timestamp when the view was created';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.AW_LAST_UPDATED IS 'Timestamp of the AW when the view was created';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.AW_OWNER IS 'Schema containing the analytic workspace';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.AW_NAME IS 'Name of the analytic workspace';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.CUBE_NAME IS 'Name of the cube for the given measure';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.CLAUSE IS 'Clause in the limitmap (FAMILYREL, DIMENSION, etc.)';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.OBJECT_NAME IS 'The name of the object (measure or dimension) being mapped';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.HIERARCHY IS 'The hierarchy for the dimension. A dimension may have multiple hierarchies.';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.LEVEL_NAME IS 'A level within a hierarchy.';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.COLUMN_NAME IS 'Column name for an AW object';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.AW_OBJECT IS 'The mapped AW object';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.DATA_TYPE IS 'Relational data type for the column';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.DIMENSION_DESC IS 'AW object representing the description for a dimension member';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.POSITION IS 'Sort order for levels in a hierarchy (aggregate to detail)';
    COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.COLUMN_LABEL IS 'Label that can be displayed to users in client tools';
    CREATE TABLE OLAP_VIEWS.OLAP_VIEW_OBJECTS
    (     LAST_UPDATED DATE,
         AW_OWNER VARCHAR2(30),
         AW_NAME VARCHAR2(30),
         VIEW_NAME VARCHAR2(61),
         DIMENSION_NAME VARCHAR2(30),
         CUBE_NAME VARCHAR2(30)
    CREATE TABLE OLAP_VIEWS.OLAP_VIEW_LIMITMAP
    (     LAST_UPDATED DATE,
         AW_OWNER VARCHAR2(30),
         AW_NAME VARCHAR2(30),
         VIEW_NAME VARCHAR2(61),
         LIMITMAP CLOB
    CREATE TABLE OLAP_VIEWS.OLAP_VIEW_LOG
    ( msg_key number,
    MSG_ID TIMESTAMP (9),
         MESSAGE VARCHAR2(4000)
    create sequence OLAP_VIEWS.olap_log_seq
    start with 1
    increment by 1
    nomaxvalue;
    create trigger OLAP_VIEWS.olap_log_trigger
    before insert on OLAP_VIEWS.OLAP_VIEW_LOG
    for each row
    begin
    select OLAP_VIEWS.olap_log_seq.nextval into :new.msg_key from dual;
    end;
    CREATE or REPLACE VIEW olap_views.version as
    SELECT 'Version 1.0.2' version
    FROM dual;
    prompt >> Create synonyms for the tables
    CREATE OR REPLACE PUBLIC SYNONYM olap_mappings FOR olap_views.olap_mappings;
    CREATE OR REPLACE PUBLIC SYNONYM OLAP_VIEW_LIMITMAP FOR olap_views.OLAP_VIEW_LIMITMAP ;
    CREATE OR REPLACE PUBLIC SYNONYM OLAP_VIEW_OBJECTS FOR olap_views.OLAP_VIEW_OBJECTS;
    CREATE OR REPLACE PUBLIC SYNONYM OLAP_VIEW_LOG FOR olap_views.OLAP_VIEW_LOG;
    prompt >> Grant privileges on synonyms to PUBLIC
    grant all on olap_mappings to public;
    grant all on OLAP_VIEW_LIMITMAP to public;
    grant all on olap_view_objects to public;
    grant all on olap_view_log to public;
    grant select on olap_views.version to public;
    prompt >> Define PL/SQL Package OLAP_VIEWGENERATOR
    create or replace PACKAGE OLAP_ViewGenerator authid current_user AS
    -- Create a report of the views created over the cube
    PROCEDURE reportViewInfo (
    strOwner varchar2,
    strAWname varchar2
    -- Create views over all the dimensions and cubes in the AW
    PROCEDURE createAWViews (
    strOwner varchar2,
    strAWname varchar2);
    -- Generate a view over a cube
    PROCEDURE createCubeView (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2);
    -- Generate a view over a dimension
    -- RETURN: name of generated view
    PROCEDURE createDimensionView (
    strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2);
    -- Get the limitmap text for a cube
    -- RETURN: limitmap text
    FUNCTION getCubeLimitmap (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2) return clob;
    -- Get the limitmap text for a dimension
    -- RETURN: limitmap text
    FUNCTION getDimensionLimitmap (strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2) return clob;
    -- Updates the OLAP_MAPPINGS table with info describing a dimension, including the following:
    -- AW object, column mapped to object, type of object (e.g. dimension, hierarchy, familyrel, etc.),
    -- label for the object, etc
    -- RETURN: true if successful, false if fails
    FUNCTION generateDimensionMap (
    strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2) RETURN number;
    -- Updates the OLAP_MAPPINGS table with the info describing a cube's measures:
    -- AW object, column mapped to object, label for the object, etc
    -- RETURN: true if successful, false if fails
    FUNCTION generateCubeMap (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2) return number;
    FUNCTION getDataType (
    strOwner varchar2,
    strAWname varchar2,
    strPhysObj varchar2) return varchar2;
    END OLAP_ViewGenerator;
    create or replace PACKAGE BODY OLAP_ViewGenerator AS
    cachedate date; -- Date for the current run of the generator
    bad_limitmap exception;
    ATTACHED_RW constant number := 2;
    ATTACHED_RO constant number := 1;
    NOT_ATTACHED constant number := 0;
    INCLUDE_LEVEL_ID constant number := 0; -- 0=FALSE, 1=TRUE
    type log_record_type is record (msg_key number, msg_id timestamp, message varchar2(4000));
    type log_table_type is table of log_record_type INDEX BY BINARY_INTEGER;
    log_table log_table_type;
    -- PRIVATE METHODS and PROCEDURES
    -- Update the OLAP_VIEW_LOG table with contents of PL/SQL table
    PROCEDURE updateLogTable as
    BEGIN
    delete olap_view_log;
    commit;
    FORALL i IN INDICES OF log_table
    INSERT INTO olap_view_log
    VALUES log_table (i);
    commit;
    -- Clear the log table
    log_table.delete;
    END updateLogTable;
    -- Shortcut for displaying output
    PROCEDURE show (message varchar2) as
    msg varchar2(4000);
    i number;
    log_record log_record_type;
    BEGIN
    msg := '>> ' || to_char(systimestamp, 'MON-DD-YYYY HH:MI:SS') || ' - ' || message;
    dbms_output.put_line(substr(msg, 1, 254));
    i := log_table.count + 1;
    log_record.msg_id := systimestamp;
    log_record.message := message;
    log_table(i) := log_record;
    END show;
    FUNCTION getDataType (
    strOwner varchar2,
    strAWname varchar2,
    strPhysObj varchar2) return varchar2 as
    dataType varchar2(10);
    objName varchar2(100);
    BEGIN
    objName := upper(strOwner || '.' || strAWname || '!' || strPhysObj);
    dataType := dbms_aw.interp('show obj(data ''' || objName || ''')');
    -- Return NUMBER for all the number types
    if dataType in ('INTEGER', 'LONGINTEGER', 'SHORTINTEGER', 'DECIMAL', 'SHORTDECIMAL')
    then dataType := 'NUMBER';
    else dataType := null;
    end if;
    return dataType;
    EXCEPTION
    when others then
    return null;
    END getDataType;
    -- Attaches the specified AW r/w first
    -- Returns the previous state of the AW:
    -- 2 : Attached r/w
    -- 1 : Attached r/o
    -- 0 : Not attached
    -- This state will be passed to detachAW in order to restore the AW to the previous state
    FUNCTION attachAW (
    strOwner varchar2,
    strAWName varchar2) return number as
    owner varchar2(30);
    awname varchar2(30);
    awlongname varchar2(100);
    cmd varchar2(400);
    isAttached number;
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWName);
    awlongname := upper(strOwner || '.' || strAWname);
    -- Check if the AW is attached:
    -- 2 : Attached r/w
    -- 1 : Attached r/o
    -- 0 : Not attached
    cmd := 'if aw(attached ''' || awlongname || ''') and aw(rw ''' || awlongname || ''') then ' || ATTACHED_RW ||
    ' else if aw(attached ''' || awlongname || ''') and aw(ro ''' || awlongname || ''') then ' ||
    ATTACHED_RO || ' else ' || NOT_ATTACHED;
    isAttached := dbms_aw.eval_number(cmd);
    -- Attach the AW r/w first
    if isAttached = NOT_ATTACHED then
    dbms_aw.aw_attach(owner, awname, true, false, 'FIRST');
    elsif isAttached = ATTACHED_RO then
    dbms_aw.aw_detach(owner, awname);
    dbms_aw.aw_attach(owner, awname, true, false, 'FIRST');
    else
    dbms_aw.aw_attach(owner, awname, true, false, 'FIRST');
    end if;
    return isAttached;
    exception
    when others then
    show ('**');
    show ('** ERROR: Unable to attach AW ' || owner || '.' || awname || ' read-write.');
    show ('** Ensure that you have priviliges to access the AW in this mode.');
    show ('**');
    raise;
    END attachAW;
    -- "Detaches" the specified AW. Note - this is really a restore the attach
    -- mode of the AW to its previous state. So, if the AW was previously attached R/W - then
    -- the AW will remain attached.
    -- This previous state was returned by the attachAW function
    PROCEDURE detachAW (
    strOwner varchar2,
    strAWName varchar2,
    awState number
    ) as
    owner varchar2(30);
    awname varchar2(30);
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWName);
    if awState = ATTACHED_RW
    then return;
    elsif awState = NOT_ATTACHED
    then dbms_aw.AW_DETACH(owner, awname);
    else
    dbms_aw.AW_DETACH(owner, awname);
    dbms_aw.aw_attach(owner, awname, false);
    end if;
    return;
    exception
    when others then
    -- shouldn't hit this condition
    show ('**');
    show ('** ERROR: Unable to restore attach state to AW ' || owner || '.' || awname || '.');
    show ('**');
    raise;
    END detachAW;
    FUNCTION getLastUpdateDate (
    strOwner varchar2,
    strAWName varchar2) return date as
    owner varchar2(30);
    awname varchar2(30);
    awlongname varchar2(100);
    last_updated varchar2(100);
    isAttached number;
    BEGIN
    awlongname := upper(strOwner || '.' || strAWname);
    owner := upper(strOwner);
    awname := upper(strAWName);
    isAttached := attachAW(owner, awname);
    last_updated := dbms_aw.interp('show to_char(aw(date, ''' || awlongname || '''), ''YYYY-MON-DD,HH:MI:SS AM'')');
    detachAW(owner, awname, isAttached);
    return to_date(last_updated, 'YYYY-MON-DD,HH:MI:SS AM');
    exception
    when others then
    show ('**');
    show ('** ERROR: Unable to retrieve last updated date for AW ' || awname || '.');
    show ('** Ensure that you have priviliges to access the AW.');
    show ('**');
    raise;
    return null;
    END getLastUpdateDate;
    FUNCTION getDepthVar (
    strOwner varchar2,
    strAWName varchar2,
    strDimname varchar2,
    strHierDim varchar2,
    strParentRel varchar2) return varchar2 as
    owner varchar2(30);
    awname varchar2(30);
    awlongname varchar2(100);
    isAttached number;
    varName varchar2(100);
    shortName varchar2(100);
    varExists number;
    cmd varchar2(1000);
    BEGIN
    awlongname := upper(strOwner || '.' || strAWname);
    awname := upper(strAWname);
    owner := upper(strOwner);
    shortName := strDimname || '_DEPTHVAR';
    varName := awlongname || '!' || shortName;
    isAttached := attachAW(owner, awname);
    -- Check if the depth variable exists
    cmd := 'convert(exists(''' || varName || '''), int)';
    varExists := dbms_aw.eval_number(cmd);
    -- Define variable if it does not exist
    -- DEFINE [dim]_DEPTHVAR VARIABLE INTEGER <[dim] [hierdim]>
    -- PROPERTY '$NATRIGGER' 'statlen(limit(limit(organization to organization + 0 ) to ancestors using organization_parentrel))+1'
    -- PROPERTY '$VARCACHE' 'VARIABLE'
    if varExists = 0 then
    show ('..... creating ' || shortname || ' object to support value hierarchies');
    cmd := 'define ' || varName || ' variable integer <' || strDimname || ' ' || strHierDim || '>';
    dbms_aw.execute(cmd);
    cmd := 'PROPERTY ''$NATRIGGER'' ''statlen(limit(limit(' ||
    strDimname || ' to ' || strDimname || ' + 0 ) to ancestors using ' || strParentRel || '))+1''';
    dbms_aw.execute(cmd);
    cmd := 'PROPERTY ''$VARCACHE'' ''VARIABLE''';
    dbms_aw.execute(cmd);
    show ('..... populating depth information in variable ' || shortName);
    cmd := 'limit ' || strDimname || ' to ' || varName || ' eq 1';
    dbms_aw.execute(cmd);
    dbms_aw.AW_UPDATE(strOwner, strAWName);
    end if;
    detachAW(owner, awname, isAttached);
    return shortName;
    exception
    when others then
    show ('**');
    show ('** ERROR: Unable to set up depth object for value based hierarchy in dimension ' || strDimname || '.');
    show ('**');
    show (sqlerrm);
    raise;
    return null;
    END getDepthVar;
    -- Return the generated column name for an AW object.
    FUNCTION getColumnName (
    parent varchar2,
    awObj varchar2,
    objType varchar2) return varchar2 as
    displayName varchar2(100);
    retval varchar2(100);
    i number;
    j number;
    BEGIN
    case
    when objType = 'MEMBER_PARENTREL' then
    retval := substr(parent, 1, 10) || '_' || substr(awObj, 1, 12) || '_PRNT';
    when objType = 'LEVEL_LONG_DESCRIPTION' then
    -- retval := substr(awObj, 1, 20) || '_LDSC';
    retval := substr(parent, 1, 10) || '_' || substr(awObj, 1, 10) || '_LDSC';
    when objType = 'MEMBER_LONG_DESCRIPTION' then
    retval := substr(parent, 1, 10) || '_LDSC';
    when objType = 'MEMBER_SHORT_DESCRIPTION' then
    retval := substr(parent, 1, 10) || '_SDSC';
    when objType = 'END_DATE' then
    retval := substr(parent, 1, 10) || '_END_DATE';
    when objType = 'TIME_SPAN' then
    retval := substr(parent, 1, 10) || '_TIME_SPAN';
    when objType = 'MEMBER_LEVELREL' then
    retval := substr(parent, 1, 10) || '_' || substr(awObj, 1, 10) || '_LVL';
    when objType = 'MEMBER_LEVELREL_DESC' then
    retval := substr(parent, 1, 10) || '_' || substr(awObj, 1, 10) || '_LVLDSC';
    when objType = 'LEVEL_ATTRIBUTE' then
    retval := substr(parent, 1, 10) || '_LEVEL';
    when objType = 'USER' then
    retval := substr(parent, 1, 10) || '_' || substr(awObj, 1, 19);
    else
    retval := awObj;
    end case;
    return retval;
    END getColumnName;
    -- Generate a limitmap for a dimension based on the information in the cache
    FUNCTION getDimensionLimitmap (
    strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2) return clob as
    owner varchar2(30);
    awname varchar2(30);
    dimname varchar2(30);
    limitmap clob;
    ov_rec olap_mappings%ROWTYPE;
    type hier_table is table of olap_mappings.hierarchy%TYPE INDEX BY BINARY_INTEGER;
    hierlist hier_table;
    target varchar2(2500);
    aw_source varchar2(2500);
    label_var varchar2(100);
    run_date date;
    no_values boolean;
    yesno number;
    aw_date date;
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    dimname := upper(strDimname);
    no_values := false;
    show('... generating limitmap for ' || dimname);
    -- Update the olap_mappings table if nec.
    begin
    aw_date := getLastUpdateDate(owner, awname);
    SELECT aw_last_updated
    INTO run_date
    FROM olap_mappings
    WHERE aw_name = awname and
    aw_owner = owner and
    object_name = dimname and
    rownum = 1;
    exception
    when NO_DATA_FOUND then
    no_values := true;
    end;
    -- Check if the dimension mapping table needs to be updated.
    -- This occurs if this current run is newer than the AW timestamp (i.e. an update
    -- has occurred in the AW)
    if no_values or run_date < aw_date
    then
    show ('..... mapping table out of date for dimension ' || dimname || '. Updating mapping table.');
    yesno := generateDimensionMap(owner, awname, dimname);
    if yesno = 0
    then return null;
    end if;
    end if;
    -- DIMENSION clause
    -- e.g. DIMENSION category_id AS varchar2(100) FROM category WITH
    SELECT *
    INTO ov_rec
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    CLAUSE = 'DIMENSION';
    limitmap := 'DIMENSION ' || ov_rec.column_name || -- ' AS ' || ov_rec.data_type ||
    ' FROM ' || dimname || ' WITH ';
    -- Process each dimension hierarchy.
    -- Begin by retrieving the list of hierarchies for the dimension
    SELECT hierarchy
    BULK COLLECT
    INTO hierlist
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    CLAUSE = 'HIERARCHY' and
    include = 1;
    for i in 1 .. hierlist.count loop
    -- HIERARCHY clause
    -- e.g. HIERARCHY category_primary_parent AS varchar2(100) FROM category_parentrel(category_hierlist 'PRIMARY')
    SELECT *
    INTO ov_rec
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    hierarchy = hierlist(i) and
    CLAUSE = 'HIERARCHY' and
    include = 1;
    limitmap := limitmap || '-' || chr(10) || ' HIERARCHY ' || ov_rec.column_name ||
    -- || ' AS ' || ov_rec.data_type ||
    ' FROM ' || ov_rec.aw_object;
    -- INHIERARCHY clause
    -- e.g. INHIERARCHY category_inhier
    SELECT *
    INTO ov_rec
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    clause = 'INHIERARCHY' and
    include = 1;
    limitmap := limitmap || ' -' || chr(10) || ' INHIERARCHY ' || ov_rec.aw_object;
    -- HATTRIBUTE clause (hierarchical attributes)
    -- e.g HATTRIBUTE time_end_date FROM aw_time_end_date
    DECLARE CURSOR hattr_cur is
    SELECT *
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    clause = 'HATTRIBUTE' and
    include = 1;
    BEGIN
    for ov_rec in hattr_cur loop
    limitmap := limitmap || ' -' || chr(10) || ' HATTRIBUTE ' || ov_rec.column_name ||
    ' FROM ' || ov_rec.aw_object;
    end loop;
    end;
    -- FAMILYREL clause
    -- e.g. FAMILYREL total_category_id AS varchar2(10),
    -- category_id AS varchar2(10),
    -- item_id AS varchar2(10)
    -- FROM category_familyrelval (category_levellist 'TOTAL_CATEGORY'),
    -- category_familyrelval (category_levellist 'CATEGORY'),
    -- category_familyrelval (category_levellist 'ITEM')
    -- show('..... FAMILYREL clause');
    DECLARE CURSOR familyrel_cur is
    SELECT *
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    hierarchy = hierlist(i) and
    clause = 'FAMILYREL' and
    include = 1
    ORDER BY position;
    BEGIN
    target := null;
    aw_source := null;
    for ov_rec in familyrel_cur loop
    if target is null
    then
    target := ' -' || chr(10) || ' FAMILYREL ' || ov_rec.column_name; -- || ' AS ' || ov_rec.data_type;
    aw_source := ' -' || chr(10) || ' FROM ' || ov_rec.aw_object;
    else
    target := target || ', -' || chr(10) || ' ' || ov_rec.column_name; -- || ' AS ' || ov_rec.data_type;
    aw_source := aw_source || ', -' || chr(10) || ' ' || ov_rec.aw_object;
    end if;
    end loop;
    end;
    limitmap := limitmap || target || aw_source;
    -- FAMILYREL LABEL clause
    -- e.g. FAMILYREL total_category_id AS varchar2(10),
    -- category_id AS varchar2(10),
    -- item_id AS varchar2(10)
    -- FROM category_familyrelval (category_levellist 'TOTAL_CATEGORY'),
    -- category_familyrelval (category_levellist 'CATEGORY'),
    -- category_familyrelval (category_levellist 'ITEM')
    DECLARE CURSOR familyrel_cur is
    SELECT *
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    hierarchy = hierlist(i) and
    clause = 'FAMILYREL_LONG_DESC' and
    include = 1
    ORDER BY position;
    BEGIN
    target := null;
    aw_source := null;
    for ov_rec in familyrel_cur loop
    if target is null
    then
    target := ' -' || chr(10) || ' FAMILYREL ' || ov_rec.column_name; -- || ' AS ' || ov_rec.data_type;
    aw_source := ' -' || chr(10) || ' FROM ' || ov_rec.aw_object;
    else
    target := target || ', -' || chr(10) || ' ' || ov_rec.column_name; -- || ' AS ' || ov_rec.data_type;
    aw_source := aw_source || ', -' || chr(10) || ' ' || ov_rec.aw_object;
    end if;
    label_var := ov_rec.dimension_desc;
    end loop;
    end;
    if aw_source is not null
    then aw_source := aw_source || ' -' || chr(10) || ' LABEL ' || label_var;
    end if;
    limitmap := limitmap || target || aw_source;
    end loop; -- Hierarchy loop
    -- ATTRIBUTE clause
    -- e.g ATTRIBUTE category_long_description AS varchar2(100) FROM category_long_description
    DECLARE CURSOR attr_cur is
    SELECT *
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname and
    clause = 'ATTRIBUTE' and
    include = 1;
    BEGIN
    for ov_rec in attr_cur loop
    limitmap := limitmap || ' -' || chr(10) || ' ATTRIBUTE ' || ov_rec.column_name ||
    -- ' AS ' || ov_rec.data_type ||
    ' FROM ' || ov_rec.aw_object;
    end loop;
    end;
    return limitmap;
    show ('.. completed genrating limitmap for dimension ' || dimname);
    END getDimensionLimitmap;
    -- Returns the limitmap for a cube
    FUNCTION getCubeLimitmap (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2) return clob as
    type dim_table is table of all_olap2_aw_cube_dim_uses.dimension_aw_name%TYPE INDEX BY BINARY_INTEGER;
    dimlist dim_table;
    limitmap clob;
    owner varchar2(30);
    awname varchar2(30);
    cubename varchar2(30);
    meas_rec olap_mappings%ROWTYPE;
    meas_clause varchar2(1000);
    run_date date;
    no_values boolean;
    yesno number;
    dimmap clob;
    aw_date date;
    BEGIN
    show('... generating limitmap for cube ' || cubename);
    owner := upper(strOwner);
    awname := upper(strAWname);
    cubename := upper(strCubename);
    -- Update the metadata cache if nec.
    begin
    -- Get the timestamp for when the AW was last updated
    aw_date := getLastUpdateDate(owner, awname);
    SELECT aw_last_updated
    INTO run_date
    FROM olap_mappings
    WHERE aw_name = awname and
    aw_owner = owner and
    cube_name = cubename and
    rownum = 1;
    exception
    when NO_DATA_FOUND then
    no_values := true;
    end;
    -- Check if the cube cache needs to be updated.
    -- This occurs if the AW has been updated since the view was created
    if no_values or run_date < aw_date
    then
    show ('..... mapping table out of date for cube ' || cubename || '. Updating mapping table.');
    yesno := generateCubeMap(owner, awname, cubename);
    if yesno = 0
    then return null;
    end if;
    end if;
    -- Get the limitmap for each of the cube's dimensions
    show('..... retrieving dimensions for the cube. Need limitmap for each dimension.');
    SELECT dimension_aw_name
    BULK COLLECT
    INTO dimlist
    FROM all_olap2_aw_cube_dim_uses
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_logical_name = cubename;
    for i in 1 .. dimlist.count loop
    dimmap := getDimensionLimitmap(owner, awname, dimlist(i));
    if dimmap is null
    then return null;
    end if;
    if limitmap is null
    then limitmap := dimmap;
    else limitmap := limitmap || '-' || chr(10) || dimmap;
    end if;
    end loop;
    -- Get the limitmap for the measures in the cube
    -- e.g. MEASURE amount AS number FROM expense_amount
    -- show ('..... MEASURE clause');
    DECLARE CURSOR meas_cur is
    SELECT *
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    cube_name = cubename and
    include = 1;
    BEGIN
    for meas_rec in meas_cur
    loop
    meas_clause := ' MEASURE ' || meas_rec.column_name;
    -- Add data type if necessary (for numeric columns)
    if meas_rec.data_type is not null then
    meas_clause := meas_clause || ' AS ' || meas_rec.data_type;
    end if;
    meas_clause := meas_clause || ' FROM ' || meas_rec.aw_object;
    limitmap := limitmap || '-' || chr(10) || meas_clause;
    end loop;
    END;
    -- Add the ROW2CELL calc. This enables arbitrary OLAP DML calcs dynamically thru sql
    limitmap := limitmap || '-' || chr(10) || ' ROW2CELL olap_calc';
    show ('... completed generating limitmap for cube ' || cubename);
    return limitmap;
    END getCubeLimitmap;
    -- Returns the SQL Model Clause or Comments for a Dimension or Cube View
    FUNCTION getSQLText (
    strOwner varchar2,
    strAWName varchar2,
    strObjType varchar2, -- CUBE or DIMENSION
    strObject varchar2, -- Name of cube or dimension
    strType varchar2, -- MODEL or COMMENT
    strViewName varchar2
    ) return varchar2 as
    clause varchar2(10000);
    comments varchar2(32000);
    type om_table_type is table of olap_mappings%ROWTYPE;
    dimlist om_table_type;
    measlist om_table_type;
    owner varchar2(30);
    awname varchar2(30);
    objtype varchar2(30);
    obj varchar2(30);
    comma varchar2(2);
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    objtype := upper(strObjType);
    obj := upper(strObject);
    -- Need to generate a model clause that looks like the following:
    /* MODEL
    DIMENSION BY(
    channel_id
    MEASURES(
    channel_primary_parent,
    channel_total_channel_id,
    channel_total_channel_desc,
    channel_channel_id,
    channel_channel_desc,
    channel_level,
    channel_long_description,
    channel_short_description
    RULES UPDATE SEQUENTIAL ORDER(); */
    clause := 'MODEL ' || chr(10) || ' DIMENSION BY (';
    -- Collect dimension list
    if objtype = 'DIMENSION' then
    -- Retrieve the dimension's column
    SELECT *
    INTO dimlist(1)
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = obj and
    clause = 'DIMENSION';
    else
    -- Retrieve the columns for each of the dimensions for this cube
    SELECT *
    BULK COLLECT
    INTO dimlist
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    clause = 'DIMENSION' and
    object_name in (
    SELECT dimension_aw_name
    FROM all_olap2_aw_cube_dim_uses
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_logical_name = obj);
    end if;
    -- Populate the clause with the dimension id column
    -- Populate the comments if there are any... (e.g. COMMENT ON COLUMN OLAP_VIEWS.OLAP_MAPPINGS.LAST_UPDATED IS 'Timestamp when the view was created'; )
    comments := '';
    for i in 1 .. dimlist.count loop
    if dimlist(i).description is not null
    then comments := comments || chr(10) || 'COMMENT ON COLUMN ' || strViewName || '.' || dimlist(i).column_name
    || ' IS ''' || dimlist(i).description || ''';';
    end if;
    if i = 1 then
    clause := clause || chr(10) || ' ' || dimlist(i).column_name;
    else
    clause := clause || ',' || chr(10) || ' ' || dimlist(i).column_name;
    end if;
    end loop;
    -- Close DIMENSION BY clause and add MEASURES clause
    clause := clause || ')' || chr(10) || ' MEASURES (';
    -- Begin by adding all the dimension attributes
    -- This is required for both dimensions and cubes
    comma := null;
    for i in 1 .. dimlist.count loop
    SELECT *
    BULK COLLECT
    INTO measlist
    FROM olap_mappings
    WHERE clause in ('HIERARCHY', 'FAMILYREL', 'FAMILYREL_LONG_DESC', 'ATTRIBUTE', 'HATTRIBUTE' ) and
    aw_name = awname and
    aw_owner = owner and
    include = 1 and
    object_name in (SELECT object_name
    FROM olap_mappings
    WHERE column_name = dimlist(i).column_name);
    for j in 1 .. measlist.count loop
    clause := clause || comma || chr(10) || ' ' || measlist(j).column_name;
    comma := ',';
    end loop;
    end loop;
    -- If this is a cube, then get all the measures as well
    measlist.delete;
    if objtype = 'CUBE'
    then
    SELECT *
    BULK COLLECT
    INTO measlist
    FROM olap_mappings
    WHERE cube_name = obj and
    aw_name = awname and
    aw_owner = owner and
    include = 1;
    for i in 1 .. measlist.count loop
    clause := clause || ',' || chr(10) || ' ' || measlist(i).column_name;
    end loop;
    -- Add the olap_calc column
    clause := clause || ',' || chr(10) || ' ' || 'OLAP_CALC';
    end if;
    clause := clause || chr(10) || ' ) RULES UPDATE SEQUENTIAL ORDER()';
    if strType = 'MODEL'
    then return clause;
    else return comments;
    end if;
    return null;
    END getSQLText;
    -- Returns the SQL Model Clause for a Dimension or Cube View
    FUNCTION getModelClause (
    strOwner varchar2,
    strAWName varchar2,
    strObjType varchar2, -- CUBE or DIMENSION
    strObject varchar2 -- Name of cube or dimension
    ) return varchar2 as
    clause varchar2(10000);
    type col_table is table of olap_mappings.column_name%TYPE INDEX BY BINARY_INTEGER;
    dimlist col_table;
    measlist col_table;
    owner varchar2(30);
    awname varchar2(30);
    objtype varchar2(30);
    obj varchar2(30);
    comma varchar2(2);
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    objtype := upper(strObjType);
    obj := upper(strObject);
    -- Need to generate a model clause that looks like the following:
    /* MODEL
    DIMENSION BY(
    channel_id
    MEASURES(
    channel_primary_parent,
    channel_total_channel_id,
    channel_total_channel_desc,
    channel_channel_id,
    channel_channel_desc,
    channel_level,
    channel_long_description,
    channel_short_description
    RULES UPDATE SEQUENTIAL ORDER(); */
    clause := 'MODEL ' || chr(10) || ' DIMENSION BY (';
    -- Collect dimension list
    if objtype = 'DIMENSION' then
    -- Retrieve the dimension's column
    SELECT column_name
    INTO dimlist(1)
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = obj and
    clause = 'DIMENSION';
    else
    -- Retrieve the columns for each of the dimensions for this cube
    SELECT column_name
    BULK COLLECT
    INTO dimlist
    FROM olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    clause = 'DIMENSION' and
    object_name in (
    SELECT dimension_aw_name
    FROM all_olap2_aw_cube_dim_uses
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_logical_name = obj);
    end if;
    -- Populate the clause with the dimension id column
    for i in 1 .. dimlist.count loop
    if i = 1 then
    clause := clause || chr(10) || ' ' || dimlist(i);
    else
    clause := clause || ',' || chr(10) || ' ' || dimlist(i);
    end if;
    end loop;
    -- Close DIMENSION BY clause and add MEASURES clause
    clause := clause || ')' || chr(10) || ' MEASURES (';
    -- Begin by adding all the dimension attributes
    -- This is required for both dimensions and cubes
    comma := null;
    for i in 1 .. dimlist.count loop
    SELECT column_name
    BULK COLLECT
    INTO measlist
    FROM olap_mappings
    WHERE clause in ('HIERARCHY', 'FAMILYREL', 'FAMILYREL_LONG_DESC', 'ATTRIBUTE', 'HATTRIBUTE' ) and
    aw_name = awname and
    aw_owner = owner and
    include = 1 and
    object_name in (SELECT object_name
    FROM olap_mappings
    WHERE column_name = dimlist(i));
    for j in 1 .. measlist.count loop
    clause := clause || comma || chr(10) || ' ' || measlist(j);
    comma := ',';
    end loop;
    end loop;
    -- If this is a cube, then get all the measures as well
    measlist.delete;
    if objtype = 'CUBE'
    then
    SELECT column_name
    BULK COLLECT
    INTO measlist
    FROM olap_mappings
    WHERE cube_name = obj and
    aw_name = awname and
    aw_owner = owner and
    include = 1;
    for i in 1 .. measlist.count loop
    clause := clause || ',' || chr(10) || ' ' || measlist(i);
    end loop;
    -- Add the olap_calc column
    clause := clause || ',' || chr(10) || ' ' || 'OLAP_CALC';
    end if;
    clause := clause || chr(10) || ' ) RULES UPDATE SEQUENTIAL ORDER()';
    return clause;
    END getModelClause;
    -- PUBLIC FUNCTIONS and PROCEDURES
    -- Populates the olap_mappings table with the structure of the limitmap
    FUNCTION generateDimensionMap (
    strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2) RETURN number as
    owner olap_views.OLAP_MAPPINGS.AW_OWNER%TYPE;
    awname olap_views.OLAP_MAPPINGS.AW_NAME%TYPE;
    dimname olap_views.OLAP_MAPPINGS.OBJECT_NAME%TYPE;
    qdr varchar2(100);
    success boolean;
    columnName olap_views.OLAP_MAPPINGS.COLUMN_NAME%TYPE;
    displayName varchar2(100); -- Name displayed to users in end user tools
    dimDisplayName varchar2(100); -- For a dimension, name displayed to users in end user tools
    parent_obj varchar2(100); -- AW object that contains parent-child relation
    hierlist_obj varchar2(100); -- AW object containing list of hierarchies
    inhier_obj varchar2(100); -- AW object specifying members in a hierarchy
    familyrel_obj varchar2(100); -- AW object specifying family relationship for level-based hiers
    familyrelval_obj varchar2(100); -- AW object specifying family relationship for value-based hiers
    levelrel_obj varchar2(100); -- AW object specifying the level for a dimension member
    levelList_obj varchar2(100);
    gidDimension_obj varchar2(100);
    long_desc_obj varchar2(100);
    depth_obj varchar2(100);
    currentvalue varchar2(100);
    hier_levels all_olap2_aw_dim_hier_lvl_ord%ROWTYPE;
    attrib_record all_olap2_aw_attributes%ROWTYPE;
    str varchar2(100);
    TYPE awinfo_table IS TABLE OF all_olap2_aw_phys_obj_prop.aw_prop_value%TYPE
    INDEX BY varchar2(100);
    level_list awinfo_table;
    physobj_list awinfo_table;
    TYPE awinfo_type is RECORD (
    prop_value all_olap2_aw_phys_obj_prop.aw_prop_value%TYPE,
    prop_name all_olap2_aw_phys_obj_prop.AW_PROP_NAME%TYPE);
    propValue_record awinfo_type;
    isValueBased boolean;
    aw_date date;
    type olapCur is ref cursor;
    physObjCur olapCur;
    isAttached number;
    maxdepth number;
    i number;
    gid_value number;
    description varchar2(1000);
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    dimname := upper(strDimname);
    show ('... populating dimension map for ' || dimname);
    -- Ensure the AW is attached R/W first
    isAttached := attachAW (owner, awname);
    -- Get the timestamp for the last time the AW was updated
    aw_date := getLastUpdateDate(owner, awname);
    * Begin by caching key metadata objects and physical objects that will be required
    * for the dimension table cache.
    show ('..... clearing mappings for the dimension');
    DELETE olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    object_name = dimname;
    * Retrieve physical AW objects that represent the hierarchies, levels, descriptions, etc.
    * Will retrieve information directly from the AW dictionary
    show ('..... retrieving physical objects');
    -- Begin by defining a shadow dimension for the NAME dimension and a formula highlighting the object type.
    -- Populate this shadow dimension with the appropriate AW objects for this dimension
    -- Note: it's okay if the name_id dimension already exists - the define will simply
    -- cause a benign error. name_id is a temporary structure that does not need to be persisted
    begin
    dbms_aw.execute('oknullstatus = yes');
    dbms_aw.execute('define name_id dimension text temp session');
    -- list of AW objects
    dbms_aw.execute('define EXPRESS!name_obj_type formula text <name_id> session');
    dbms_aw.execute('eq if obj(property ''AW$ROLE'', name_id) eq ''ATTRDEF'' then obj(property ''AW$TYPE'', name_id) else obj(property ''AW$ROLE'', name_id)');
    -- list of physical level names
    dbms_aw.execute('define EXPRESS!level_physicalname formula text <name_id> session');
    dbms_aw.execute('eq obj(property ''PHYSICALNAME'', name_id)');
    -- list of level display names
    dbms_aw.execute('define EXPRESS!level_displayname formula text <name_id> session');
    dbms_aw.execute('eq obj(property ''DISPLAYNAME'', name_id)');
    -- list of value hierarchy names
    dbms_aw.execute('define valuehiers dimension text temp session');
    dbms_aw.execute('define EXPRESS!hier_logicalname formula text <valuehiers> session');
    dbms_aw.execute('eq obj(property ''AW$LOGICAL_NAME'', valuehiers)');
    -- maximum depth of a value hierarchy
    dbms_aw.execute('define EXPRESS!hier_maxdepth formula int <valuehiers> session');
    dbms_aw.execute('eq numlines(obj(property ''HIERARCHY_LEVELS'', valuehiers))');
    -- Check for exceptions..... occurs if the object supporting objects already exist.
    exception
    when others then
    null;
    end;
    -- Clear the cached list of names
    dbms_aw.execute('mnt name_id delete all');
    -- Populate the shadow dimension with all the dimension related objects
    dbms_aw.execute('mnt name_id merge limit(name to obj(property ''AW$PARENT_NAME'') eq ''' ||
    dimname || ''' or obj(property ''AW$ROLE'') eq ''GID_DIMENSION'')');
    -- Retrieve the objects and their properties
    open physObjCur for 'SELECT prop_value, prop_name
    FROM table(OLAP_TABLE(''EXPRESS duration session'', null, null,
    ''DIMENSION prop_name FROM name_id
    MEASURE prop_value FROM name_obj_type''))';
    BEGIN
    loop
    fetch physObjCur into propValue_record;
    exit when physObjCur%NOTFOUND;
    physobj_list(propValue_record.prop_value) := propValue_record.prop_name;
    end loop;
    close physObjCur;
    END;
    parent_obj := physobj_list('MEMBER_PARENTREL');
    hierlist_obj := physobj_list('HIERLIST');
    inhier_obj := physobj_list('MEMBER_INHIER');
    familyrel_obj := physobj_list('MEMBER_FAMILYREL');
    familyrelval_obj := physobj_list('MEMBER_FAMILYRELVAL');
    levelList_obj := physobj_list('LEVELLIST');
    levelrel_obj := physobj_list('MEMBER_LEVELREL');
    gidDimension_obj := physobj_list('GID_DIMENSION');
    long_desc_obj := physobj_list('MEMBER_LONG_DESCRIPTION');
    -- Populate the value hierarchy collection
    -- Use a similar technique to the one above to find the hierarchies
    show ('..... checking for value hierarchies');
    dbms_aw.execute('mnt valuehiers delete all');
    -- Populate the valuehiers dimension with all the value hierarchies for this dimension
    dbms_aw.execute('mnt valuehiers merge limit(name to obj(property ''AW$PARENT_NAME'') eq ''' ||
    dimname || ''' and obj(property ''AW$ROLE'') eq ''HIERDEF'' and obj(property ''VALUE_HIERARCHY'') eq True)');
    -- Populate the LEVEL labels collection
    -- Again, use techniques similar to the one above ** CHECK VALUE HIERARCHIES **
    show ('..... retrieving label for dimension levels');
    -- Populate the shadow dimension with all the dimension related objects
    dbms_aw.execute('mnt name_id delete all');
    dbms_aw.execute('mnt name_id merge limit(name to obj(property ''AW$PARENT_NAME'') eq ''' ||
    dimname || ''' and obj(property ''AW$ROLE'') eq ''LEVELDEF'')');
    -- Retrieve the objects and their properties
    open physObjCur for 'SELECT display_name prop_value, physical_name prop_name
    FROM table(OLAP_TABLE(''EXPRESS duration session'', null, null,
    ''DIMENSION level_name FROM name_id
    MEASURE physical_name FROM level_physicalname
    MEASURE display_name FROM level_displayname''))';
    BEGIN
    loop
    fetch physObjCur into propValue_record;
    exit when physObjCur%NOTFOUND;
    level_list(propValue_record.prop_name) := propValue_record.prop_value;
    end loop;
    close physObjCur;
    END;
    -- Update the cache with DIMENSION clause
    -- Example:
    -- DIMENSION category_id AS varchar2(100) FROM category WITH
    show ('..... populating mapping info for the DIMENSION clause');
    dimDisplayName := dbms_aw.eval_text('obj(property ''DISPLAYNAME'' ''' || dimname || ''')') || ' member';
    -- DIMENSION clause
    description := dimname || ' dimension member values';
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'DIMENSION',
    dimname, dimname, dimname,
    dimDisplayName, description);
    -- Update the cache with INHIER clause
    -- Example:
    -- INHIERARCHY category_inhier
    -- INHIERARCHY clause
    show ('..... populating mapping info for the INHIERARCHY clause');
    description := 'Identifies dimension members that are in a given hierarchy';
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'INHIERARCHY',
    dimname, null, inhier_obj,
    null, description);
    -- Loop over the HIERARCHIES for this dimension
    -- Update the cache with HIERARCHY and FAMILYREL clauses
    -- Example:
    -- HIERARCHY category_standard_prnt AS varchar2(100) FROM category_parentrel(category_hierlist \'STANDARD\')
    currentvalue := ' ';
    show ('..... retrieving hierarchy information');
    DECLARE
    CURSOR hier_levels_cur is
    SELECT *
    FROM all_olap2_aw_dim_hier_lvl_ord
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_dimension_name = dimname and
    length(aw_hierarchy_name) > 0
    ORDER BY aw_hierarchy_name asc, position asc;
    BEGIN
    for hier_levels in hier_levels_cur
    loop
    str := hier_levels.aw_hierarchy_name;
    -- If there is a change in hierarchy, then add the HIERARCHY clause
    if str != currentvalue
    then
    show ('..... populating mapping info for the HIERARCHY and FAMILYREL clauses for hierarchy ' || str);
    currentvalue := hier_levels.aw_hierarchy_name;
    columnName := getColumnName (dimname, currentvalue, 'MEMBER_PARENTREL');
    qdr := parent_obj || '(' || hierlist_obj || ' \''' || currentvalue || '\'')';
    description := dimname || ' member''s parent in hierarchy ' || currentvalue;
    displayName := dimDisplayName || ' Parent';
    -- HIERARCHY clause
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, hierarchy, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'HIERARCHY',
    dimname, currentvalue, columnName, qdr,
    displayName, description);
    -- Check if current hierarchy is value based
    dbms_aw.execute('limit valuehiers to hier_logicalname eq ''' || currentvalue || '''');
    if dbms_aw.eval_number('statlen(valuehiers)') = 0
    then isValueBased := false;
    else isValueBased := true;
    end if;
    -- Get the maximum depth of a value hierarchy
    -- Also, set up the depth variable for a value-based hierarchy
    if isValueBased then
    maxdepth := dbms_aw.eval_number('hier_maxdepth');
    i := maxdepth;
    -- The depth object represents a level in a value based hierarchy
    -- This object is not in standard form and will be created if nec by
    -- getDepthVar
    if depth_obj is null then
    depth_obj := getDepthVar(owner, awname, dimname, hierlist_obj, parent_obj);
    end if;
    -- Add a LEVEL hierarchy attribute
    -- There must be a level (or depth) attribute by hierarchy, since the level may change by hierarchy
    columnName := substr(dimname, 1, 10) || '_' || substr(currentvalue, 1, 10) || '_LEVEL';
    description := 'Depth of ' || dimname || ' member in hierarchy ' || currentvalue;
    displayName := dimDisplayName || ' level';
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'HATTRIBUTE',
    dimname, columnName, depth_obj,
    displayName, description);
    end if;
    end if;
    -- Add the FAMILYREL clause for this level
    if isValueBased
    then
    i := i - 1;
    gid_value := power(2, i) - 1;
    -- columnName := getColumnName(dimname, hier_levels.aw_level_name, 'MEMBER_LEVELREL');
    qdr := familyrelval_obj || '(' || gidDimension_obj || ' ' || gid_value || ')';
    displayName := currentvalue || ' Level ' || hier_levels.position;
    str := substr(currentvalue, 1, 8) || hier_levels.position;
    columnName := getColumnName(dimname, str, 'MEMBER_LEVELREL');
    description := dimname || ' member''s ancestor value for level ' || hier_levels.position || ' in hierarchy ' || currentvalue;
    -- FAMILYREL clause
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, hierarchy, level_name, column_name, aw_object,
    position, column_label, description, include)
    VALUES (cachedate, aw_date, owner, awname, 'FAMILYREL',
    dimname, currentvalue, str, columnName, qdr,
    hier_levels.position, displayName || ' ID', description, include_level_id);
    -- FAMILYREL description clause
    description := dimname || ' member''s ancestor descriptive value for level ' || hier_levels.position || ' in hierarchy ' || currentvalue;
    columnName := getColumnName(dimname, str, 'MEMBER_LEVELREL_DESC');
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, hierarchy, level_name, column_name, aw_object,
    dimension_desc, position, column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'FAMILYREL_LONG_DESC',
    dimname, currentvalue, str, columnName, qdr,
    long_desc_obj, hier_levels.position, displayName || ' Description', description);
    else
    -- Level based hierarchies use the level list object
    -- They also use the FAMILYREL as the hierarchy structure
    -- columnName := getColumnName(dimname, hier_levels.aw_level_name, 'MEMBER_LEVELREL');
    columnName := getColumnName(dimname, hier_levels.aw_level_name, 'MEMBER_LEVELREL');
    qdr := familyrel_obj || '(' || levelList_obj || ' \''' ||
    hier_levels.aw_level_name || '\'')';
    displayName := level_list(hier_levels.aw_level_name);
    description := dimname || ' member''s ancestor value for level ' || hier_levels.aw_level_name || ' in hierarchy ' || currentvalue;
    -- FAMILYREL clause
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, hierarchy, level_name, column_name, aw_object,
    position, column_label, description, include)
    VALUES (cachedate, aw_date, owner, awname, 'FAMILYREL',
    dimname, currentvalue, hier_levels.aw_level_name, columnName, qdr,
    hier_levels.position, displayName || ' ID', description, INCLUDE_LEVEL_ID);
    -- FAMILYREL description clause
    -- columnName := getColumnName(dimname, hier_levels.aw_level_name, 'LEVEL_LONG_DESCRIPTION');
    columnName := getColumnName(dimname, hier_levels.aw_level_name, 'MEMBER_LEVELREL_DESC');
    description := dimname || ' member''s ancestor descriptive value for level ' || hier_levels.aw_level_name || ' in hierarchy ' || currentvalue;
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, hierarchy, level_name, column_name, aw_object,
    dimension_desc, position, column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'FAMILYREL_LONG_DESC',
    dimname, currentvalue, hier_levels.aw_level_name, columnName, qdr,
    long_desc_obj, hier_levels.position, displayName || ' Description', description);
    end if;
    END LOOP; -- Loop over hierarchy levels
    END; -- Cursor for hierarchy levels
    -- Add ATTRIBUTES for the dimension
    show ('..... populating mapping info for the ATTRIBUTE clause');
    DECLARE
    CURSOR attributes_cur is
    SELECT *
    FROM all_olap2_aw_attributes
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_dimension_name = dimname;
    BEGIN
    for attrib_record in attributes_cur
    loop
    columnName := getColumnName(attrib_record.aw_dimension_name,
    attrib_record.aw_logical_name,
    attrib_record.attribute_type);
    description := attrib_record.description;
    displayName := attrib_record.display_name;
    /* if attrib_record.attribute_type in ('MEMBER_SHORT_DESCRIPTION', 'MEMBER_LONG_DESCRIPTION')
    then
    description := attrib_record.description;
    displayName := attrib_record.display_name;
    else
    description := attrib_record.aw_dimension_name || ' attribute ' || attrib_record.aw_physical_object;
    displayName := attrib_record.display_name;
    end if;
    -- ATTRIBUTE clause
              --      Throwing column name
         show ('Attribute clause column name= ' || columnName);
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'ATTRIBUTE',
    dimname, columnName, attrib_record.aw_physical_object,
    displayName, description);
    end loop;
    END;
    -- Add the LEVELREL object as an attribute of the dimension.
    columnName := getColumnName(dimname, null, 'LEVEL_ATTRIBUTE');
    description := dimDisplayName || ' level';
    displayName := description;
              --      Throwing column name
         show ('Levelrel clause column name= ' || columnName);
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, clause,
    object_name, column_name, aw_object,
    column_label, description)
    VALUES (cachedate, aw_date, owner, awname, 'ATTRIBUTE',
    dimname, columnName, levelrel_obj,
    displayName, description);
    -- Finally, ensure that the columns are unique across the the AW.
    -- For example, if month_lvl is in two hierarchies, there will need to be two
    -- columns: 1) month_lvl and 2) month_lvl1. Or, if there is a product dimension
    -- and a product measure, these will also be uniquely identified
    UPDATE olap_mappings map
    SET map.column_name =
    (SELECT case when (b.cum_occurrence > 1) then b.column_name || (b.cum_occurrence - 1)
    else b.column_name
    end as column_name
    FROM
    (SELECT a.aw_owner,
    a.aw_name,
    a.cube_name,
    a.column_name,
    SUM(a.occurrence) over(PARTITION BY cube_name, column_name ORDER BY occurrence ROWS unbounded preceding) cum_occurrence
    FROM
    (SELECT aw_owner,
    aw_name,
    cube_name,
    column_name,
    1 occurrence
    FROM olap_mappings
    WHERE aw_name= awname and
    aw_owner=owner) a
    ) b
    WHERE map.rowid = b.rowid)
    WHERE map.aw_name = awname and
    map.aw_owner = owner;
    commit;
    show ('... completed populating mapping for ' || dimname);
    detachAW(owner, awname, isAttached);
    return 1;
    exception
    when NO_DATA_FOUND then
    rollback;
    show ('**');
    show ('** Error retrieving metadata for dimension ' || dimname);
    show ('** You do not have access to the data in the AW.');
    show ('** View creation failed');
    show ('**');
    show (SQLERRM);
    detachAW(owner, awname, isAttached);
    return 0;
    when others then
    rollback;
    show ('**');
    show ('** Error retrieving metadata for dimension ' || dimname);
    show ('** View creation failed');
    show ('**');
    show (SQLERRM);
    detachAW(owner, awname, isAttached);
    return 0;
    END generateDimensionMap;
    -- Updates the OLAP_MAPPINGS table with information about a cube
    FUNCTION generateCubeMap (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2) return number as
    owner varchar2(30);
    awname varchar2(30);
    cubename varchar2(30);
    aw_date date;
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    cubename := upper(strCubename);
    aw_date := getLastUpdateDate(owner, awname);
    show ('... populating mapping for cube ' || cubename);
    show ('..... clearing mappings for the cube');
    DELETE olap_mappings
    WHERE aw_owner = owner and
    aw_name = awname and
    cube_name = cubename;
    -- Retrieve each of the measures
    show ('..... collecting metadata for measures in cube');
    INSERT INTO olap_mappings(last_updated, aw_last_updated, aw_owner, aw_name, cube_name, clause,
    object_name, column_name, aw_object,
    data_type,
    column_label, description)
    (SELECT cachedate, aw_date, aw_owner, aw_name, aw_cube_name, 'MEASURE',
    aw_measure_name, aw_measure_name, aw_physical_object,
    olap_views.olap_viewGenerator.getDataType(aw_owner, aw_name, aw_physical_object),
    display_name, 'Measure ' || aw_measure_name
    FROM all_olap2_aw_cube_measures);
    commit;
    return 1;
    exception
    when others then
    rollback;
    show ('**');
    show ('** Error retrieving metadata for cube ' || cubename);
    show ('** View creation failed');
    show ('**');
    show (SQLERRM);
    return 0;
    END generateCubeMap;
    PROCEDURE createCubeView (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2,
    commitLog boolean) as
    owner varchar2(30);
    awname varchar2(30);
    cubename varchar2(30);
    limitmap clob;
    cmd varchar2(4000);
    output varchar2(4000);
    varname varchar2(100);
    sql_text varchar2(32767);
    viewname varchar2(61);
    cube_rec all_olap2_aw_cubes%rowtype;
    type dim_table is table of all_olap2_aw_cube_dim_uses.dimension_aw_name%TYPE INDEX BY BINARY_INTEGER;
    dimlist dim_table;
    isAttached number;
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    cubename := upper(strCubename);
    varname := cubename || '_CUBE_LIMITMAP';
    viewname := owner || '.' || substr(cubename, 1, 21) || '_CUBEVIEW';
    show ('. Creating view for cube ' || cubename);
    -- Validate the arguments
    begin
    SELECT *
    INTO cube_rec
    FROM all_olap2_aw_cubes
    WHERE aw_name = awname and
    aw_owner = owner and
    aw_logical_name = cubename;
    exception
    when NO_DATA_FOUND then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** Invalid arguments. Ensure that the schema, AW and cube names are valid.');
    show ('** In addition, ensure that you have r/w priviliges to the AW.');
    show ('**');
    if commitLog
    then updateLogTable();
    end if;
    raise;
    end;
    -- Attach the AW
    begin
    isAttached := attachAW(owner, awname);
    exception
    when others then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** Unable to attach AW r/w. Ensure no other users have the AW attached RW - then try again.');
    show ('** In addition, ensure that you have r/w priviliges to the AW.');
    show ('**');
    if commitLog
    then updateLogTable();
    end if;
    raise;
    end;
    -- Define the limitmap variable in the AW and assign the limitmap text to it
    show ('..... generating limitmap for cube');
    limitmap := getCubeLimitmap(owner, awname, cubename);
    if limitmap is null
    then
    if commitLog then
    updateLogTable();
    raise bad_limitmap;
    end if;
    end if;
    -- Define the variable
    show ('..... assigning limitmap to variable in the AW');
    begin
    dbms_aw.execute('define ' || varname || ' variable text');
    -- If the variable already exists, simply update it
    exception
    when others then
    show ('..... ' || varname || ' found. Will update the variable');
    end;
    -- Assign the limitmap. Update and commit changes
    begin
    output := dbms_aw.interpclob(varname || ' = ''' || limitmap || '''');
    dbms_aw.aw_update(owner, awname);
    commit;
    detachAW(owner, awname, isAttached);
    exception
    when others then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** CAUSE: Unable to assign the limitmap variable in the AW.');
    show (SQLERRM);
    detachAW(owner, awname, isAttached);
    -- if commitLog
    -- then updateLogTable();
    -- end if;
    raise;
    end;
    -- Create the view over the AW
    -- Example:
    CREATE or REPLACE VIEW channel_dimview AS
    SELECT *
    FROM table(OLAP_TABLE('GLOBAL.GLOBAL duration session',
    '&(CHANNEL_LIMITMAP)' ))
    show ('..... defining view ' || viewname || ' over the cube');
    sql_text := 'CREATE OR REPLACE VIEW ' || viewname || ' AS ' || chr(10) ||
    ' SELECT * ' || chr(10) ||
    ' FROM table(OLAP_TABLE (''' || owner || '.' || awname || ' duration session'',' || chr(10) ||
    ''''',' || chr(10) ||
    ''''',' || chr(10) ||
    '''&(' || varname || ')''))';
    -- Add SQL Model clause
    sql_text := sql_text || chr(10) ||
    getSQLText(owner, awname, 'CUBE', cubename, 'MODEL', null);
    begin
    execute immediate sql_text;
    exception
    when others then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** CAUSE: CREATE VIEW statement failed');
    show (SQLERRM);
    show ('*** DEBUG INFORMATION ***');
    show ('VIEW CREATION DDL ((truncated after 3900 characters)');
    show (substr(sql_text, 1, 3900));
    show ('LIMITMAP (truncated after 3900 characters):');
    show (substr(limitmap, 1, 3900));
    raise;
    end;
    -- Update the catalog containing the views and their contents
    begin
    -- Update the limitmap catalog
    DELETE olap_view_limitmap
    WHERE aw_owner = owner and
    aw_name = awname and
    view_name = viewname;
    INSERT INTO olap_view_limitmap(last_updated, aw_owner, aw_name,
    view_name, limitmap)
    VALUES (cachedate, owner, awname,
    viewname, limitmap);
    -- Update the object catalog with the cube
    DELETE olap_view_objects
    WHERE aw_owner = owner and
    aw_name = awname and
    view_name = viewname and
    cube_name = cubename;
    INSERT INTO olap_view_objects(last_updated, aw_owner, aw_name,
    view_name, cube_name)
    VALUES (cachedate, owner, awname,
    viewname, cubename);
    -- Update the object catalog with the dimensions for the cube
    SELECT dimension_aw_name
    BULK COLLECT
    INTO dimlist
    FROM all_olap2_aw_cube_dim_uses
    WHERE aw_owner = owner and
    aw_name = awname and
    aw_logical_name = cubename;
    for i in 1 .. dimlist.count loop
    DELETE olap_view_objects
    WHERE aw_owner = owner and
    aw_name = awname and
    view_name = viewname and
    dimension_name = dimlist(i);
    INSERT INTO olap_view_objects(last_updated, aw_owner, aw_name,
    view_name, dimension_name)
    VALUES (cachedate, owner, awname,
    viewname, dimlist(i));
    end loop;
    commit;
    exception
    when others then
    rollback;
    show ('**');
    show ('** ERROR: Unable to update the OLAP_VIEW_OBJECTS and/or OLAP_VIEW_LIMITMAP catalog tables.');
    show (SQLERRM);
    show ('** NOTE: View ' || viewname || ' was successfully created.');
    if commitLog
    then updateLogTable();
    end if;
    return;
    end;
    show ('View ' || viewname || ' successfully created');
    if commitLog
    then updateLogTable();
    end if;
    return;
    exception
    when others then
    rollback;
    show ('**');
    show ('** ERROR: Unable to create view over cube ' || cubename || '.');
    show (SQLERRM);
    if commitLog
    then updateLogTable();
    end if;
    raise;
    END createCubeView;
    PROCEDURE createCubeView (
    strOwner varchar2,
    strAWname varchar2,
    strCubename varchar2) as
    BEGIN
    createCubeView(strOwner, strAWname, strCubename, true);
    END createCubeView;
    PROCEDURE createDimensionView (
    strOwner varchar2,
    strAWname varchar2,
    strDimname varchar2,
    commitLog boolean) as
    owner varchar2(30);
    awname varchar2(30);
    dimname varchar2(30);
    limitmap clob;
    cmd varchar2(4000);
    output varchar2(4000);
    varname varchar2(100);
    sql_create varchar2(32767);
    viewname varchar2(61);
    dim_rec all_olap2_aw_dimensions%ROWTYPE;
    isAttached number;
    BEGIN
    owner := upper(strOwner);
    awname := upper(strAWname);
    dimname := upper(strDimname);
    varname := dimname || '_LIMITMAP';
    viewname := owner || '.' || substr(dimname, 1, 22) || '_DIMVIEW';
    show ('. Creating view for dimension ' || dimname);
    begin
    SELECT *
    INTO dim_rec
    FROM all_olap2_aw_dimensions
    WHERE aw_name = awname and
    aw_owner = owner and
    aw_logical_name = dimname;
    exception
    when NO_DATA_FOUND then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** Invalid arguments. Ensure that the schema, AW and dimension names are valid.');
    show ('** In addition, ensure that you have r/w priviliges to the AW.');
    show ('**');
    if commitLog
    then updateLogTable();
    end if;
    raise;
    end;
    -- Attach the AW
    begin
    isAttached := attachAW(owner, awname);
    exception
    when others then
    show ('**');
    show ('** ERROR: View not created.');
    show ('** Unable to attach AW r/w. Ensure no other users have the AW attached RW - then try again.');
    show ('** In addition, ensure that you have r/w priviliges to the AW.');
    show ('**');
    if commitLog
    then updateLogTable();
    end if;
    raise;
    end;
    -- Define the limitmap variable in the AW and assign the limitmap text to it
    limitmap := getDimensionLimitmap(owner, awname, dimname);
    if limitmap is null
    then
    show ('Error defining limitmap.');
    if commitLog
    then updateLogTable();
    end if;
    raise bad_limitmap;
    end if;
    -- Define the variable
    begin
    dbms_aw.execute('define ' || varname || ' variable text');
    -- If the variable already exists, simply update it
    exception
    when others then
    show ('..... will update variable ' || varname);
    end;
    -- Assign the limitmap. Update and commit changes
    begin
    output := dbms_aw.interpclob(varna

  • Balise - "contenu interdit" (!!!)

    J'ai voulu ajouter une balise:
    contenu de la balise : " always on top " (mais le mot "on" ne "passe" pas)
    le contenu on est interdit dans cette communauté
    comment résoudre ce problème ? Qui contacter ?  (Demoiselle Remondière ?)
    Résolu !
    Accéder à la solution.

    Traduit machine:
    Salut ouadji,
    Je suis désolé pour la confusion ce problème. Les forums de discussion NI sont configurés pour filtrer les balises contenant de petits mots de connecteurs (and, or, to, etc.) afin d'éviter une grande quantité de messages étant étiqueté avec petits mots comme "on". Il ressemble à ceci a également été bloque plus les balises qui inclus ces mots.
    Se il vous plaît essayer de nouveau, et laissez-moi savoir si vous voyez toujours le problème.
    Merci!
    Matt
    Product Owner - NI Community
    National Instruments

  • What is the speed/performance comparison between Soundbooth CS5 and Audition CS6?

    Obviously, I don't need to be convinced about the difference. However, in demonstrating and working with Audition I didn't take a note of these speed differences. Does anyone have this information for business justification reasons?
    I am looking for the speed of a sound file (*.wav, approximately 1-5minutes in length) rendering in Soundbooth CS5 and Audition CS6 as well as a comparison of doing 10 files (approximately 1-5 minutes in length each) in Soundbooth and in Audition CS6 (using batch processing) to *.mp3 with basic processes applied. Basic processes that I am checking are Noise Reduction, Trimming front and end silences, Normalization, and rendering to *.mp3 (from *.wav). If anyone can do this for me, that would be awesome!!

    travis_smith_ wrote:
    Hello _durin_, yes all those are great arguments that I've already included; however, some people like to use accurate measures/times/processes...they want numbers.
    So, do you (or anyone else) happen to know the render engine speed of 1 file in Soundbooth v. 1 file in Audition?
    What Durin hasn't perhaps made quite clear is that you'd have to do this on just one machine to come up with any comparisons at all - and if that machine isn't identical to yours, then it's going to be meaningless anyway; some of the processes (like NR) will vary considerably between two different machines, even running the same software. There is no way on earth that this would be an accurate comparison, and I don't think it would convince anybody who actually understood what was at issue. This is the politest way of saying that it's not going to happen... and if Durin, as Audition's Product Owner, isn't prepared to commit himself, then nobody's going to.... BUT:
    Now I am moving towards the argumentation that it should replace everyone's Soundbooth, which is why I need the justification. I would run the tests myself over the current set of files, but with the license gone, I cannot.
    Your real justification isn't going to be based on anything like dodgy process measurements at all, but this: Soundbooth is discontinued - there's very little, if any, support for it now, and there will be no updates to cope with OS changes, etc. Audition, on the other hand, is a long-term, well-supported software product that's under active development, and this is clearly intended to continue. Also there are business package deals to be done (like active subscriptions, etc) that simply weren't available to Soundbooth users, which companies can use far more flexibly. I think you'll find that arguements like this will cut far more mustard than any odious comparisons of 'speed' will.

  • Detect an open file on a share before the folder is moved

    I'm adding an archive feature to a labview application.
    It will archive all the files and subdirectories within the directory I point to.
    My challenge is as follows: The directory is on a network share drive so before the VI moves the directory to the archive location it needs to know if any files are open.  If any are open then it would try again later.  If the labview move function errored out before it moved a directory with open files it would be the perfect solution but it doesn't function this way - it errors after it moves everything except the open files.  Moving all closed files then moving the others when they become available isn't an option for me.
    In researching this it appears I need to access some kind of network management interface to get this info. 
    Does anyone know what resource I could use for this?  I thought "active directory services", accessed through .net, but it seems "user centric (namespace)" not file status centric - not sure though - haven't worked with ADS much and find it less than user friendly to research.
    I figure there has to be some mechanism I can hook into programmatically as a network client to check if any files within a directory are open.
    My application will run on a network client and I don't have access to the server/s hosting the share.
    I'm sure others have encountered this situation or maybe you could point me to another forum for this?
    Cheers,
    Christopher

    Hi Cristopher,
    It seems like the best way to achieve this functionality would be to use two steps. First, check if any of the files in the directory are open, then create the archive only if none of the files are found to be open.
    You may want to check out the following page: How Can I Check if a File is Already Open? The issue of checking for applications being run on different machines within a network is addressed there, so it may be a good resource for you. There are also several other Knowledge Base and Developer Zone articles linked to that page that should be helpful.
    I hope that helps!
    Matt
    Product Owner - NI Community
    National Instruments

  • HT2905 When I added music to iTunes it seperated some of the songs into the catagories selected and others are lumped into a list at the end where artist and song are in the same space and not sperated like the other songs. It appears I into catagories an

    I've got to be the dumbest Apple product owner there is.
    * Doesn't it seem strange (maybe I'm not finding this option as it's hidden some place?) that there aren't boxes allowing you to select what action you clearly want to take?
    Senerio (sp?) New user (last two years) or for a 7 year old who opens up itunes to any catagory listed, for this exsample their iPhone's hooked up and connected currently what I view it appears iTunes will sync the two but where is it stated clearly what will be over written and what will be replacing it? Because once syncing is done it's done there's no "I didn't want it to do that" button to press to go back!
    Solution for persons such as myself; picture a white plain screen opening up in the catagory you choose (I'll use music) uncluttered no links taking you inadvetaintly to a screen pitching me something from Apple just all my music catagorized by iTunes the way in which I selected it to be by checking as many of the choices as I want that are list in the "sort" menu. Now before I hit sync at the top there are 3 empty boxes. Positioned clearly and designed by the marketing department who has every page in the store laid out clear clean and in your face making it impossible to START HERE so to speak, they'd unmistakably be simply labeled with 3 basic choices for you to choose from (a fourth "advanced" could be optional) which would be; Box#1 Do Noithing (Leave as is) Box#2 Sync from Device to iTunes Box#3 Sync from iTunes to Device . What you checked is what action iTunes would take. When you pressed "sync" a box would pop up Asking are you sure you want to it would have the selected boxes action here further assuring you wre doing as you wanted .
    With these on all the things/catagories that iTunes writes over and erases replacing it with what in my experiance usually is incomplete folders or databases of apps, music, movies, podcasts, books etc.? the misinterpretation of the action you want or choose would almost be eliminated from incorrect interpretation of what you actually want to do.
    Please if there's something I can set for all my choices please tell me where and how.
    Addionally without doing it one song at a time does iTunes seperate song artist from title automatically some how or do I have to go song by song cut artist and paste in the correct colum?
    Any help is appriciated!!!!!!!!!

    I've got to be the dumbest Apple product owner there is.
    * Doesn't it seem strange (maybe I'm not finding this option as it's hidden some place?) that there aren't boxes allowing you to select what action you clearly want to take?
    Senerio (sp?) New user (last two years) or for a 7 year old who opens up itunes to any catagory listed, for this exsample their iPhone's hooked up and connected currently what I view it appears iTunes will sync the two but where is it stated clearly what will be over written and what will be replacing it? Because once syncing is done it's done there's no "I didn't want it to do that" button to press to go back!
    Solution for persons such as myself; picture a white plain screen opening up in the catagory you choose (I'll use music) uncluttered no links taking you inadvetaintly to a screen pitching me something from Apple just all my music catagorized by iTunes the way in which I selected it to be by checking as many of the choices as I want that are list in the "sort" menu. Now before I hit sync at the top there are 3 empty boxes. Positioned clearly and designed by the marketing department who has every page in the store laid out clear clean and in your face making it impossible to START HERE so to speak, they'd unmistakably be simply labeled with 3 basic choices for you to choose from (a fourth "advanced" could be optional) which would be; Box#1 Do Noithing (Leave as is) Box#2 Sync from Device to iTunes Box#3 Sync from iTunes to Device . What you checked is what action iTunes would take. When you pressed "sync" a box would pop up Asking are you sure you want to it would have the selected boxes action here further assuring you wre doing as you wanted .
    With these on all the things/catagories that iTunes writes over and erases replacing it with what in my experiance usually is incomplete folders or databases of apps, music, movies, podcasts, books etc.? the misinterpretation of the action you want or choose would almost be eliminated from incorrect interpretation of what you actually want to do.
    Please if there's something I can set for all my choices please tell me where and how.
    Addionally without doing it one song at a time does iTunes seperate song artist from title automatically some how or do I have to go song by song cut artist and paste in the correct colum?
    Any help is appriciated!!!!!!!!!

Maybe you are looking for

  • How to automatcally uninstall Office 2007 32 bit for installation of Office 2010 64 bit

    I have an MSP that will automatically install my companies 64 bit version of Office 2010 provided Office 2007 32 bit is already uninstalled. However, the option to uninstall previous versions of Office does not work in the MSP. We have Office 2007 32

  • Portlet could not be contacted error in content area

    hi everybody, i've developed an application using Portal Content Area.And i am accessing the content Area like "http://<servername>/pls/portal30/url/folder/<Content area name>". But when i access it shows "Error : Portlet could not be Contacted".then

  • Significance of External Merchandise category in IS Retail

    Can any one help me in understanding what is ext merch category and what is the significance in IS retail? srini

  • Axis2 (0.94) - transport error : Unauthorized

    Dear all, I hving difficulties to consume a custom .Net webservice resides in Ms Sharepoint server. The webservice is tested within a C# windows application and it works fine. I used wsdl2java.bat to generate the neccesary stub and helper. When I tri

  • FORALL and COMMIT

    I am looking for explanation for the following: Version 9.2.08 CREATE TABLE demo (a_col NUMBER, b_date DATE); INSERT INTO demo (a_col, b_date) VALUES (1, TRUNC(SYSDATE - 181)); INSERT INTO demo (a_col, b_date) VALUES (1, TRUNC(SYSDATE - 182)); INSERT