Create View Statement Hangs

Hello -
I'm running 10g R2 on AIX. I have view A, view B, and view C. View C look like this:
select * from view A;
union all
select * from view B;
View A and View B both contains many left outer joins.
View C will compile when it only references view A or view B (without the union).
What would cause the create view statement to hang when using the union statement? Also, if I leave out the create view for C, then the following select statements will never complete:
select * from view A;
union all
select * from view B;
I have determined that something with the union statement is causing this to hang.
Has anyone ever seen anything like this? Any help is greatly appreciated!
Thanks,
Mike

Thanks all for the postings. Sorry it took me so long to get back to this. I am posting the actual ddl for the views. The TESTA and TESTB views are created without any problems. The TESTC view (with the union all) just hangs when trying to create. It's not the view, but the select with the union all. If I run the sql without the create view statement, it still hangs. If I remove the union, and just select from TESTA or only TESTB, then it works fine. I have never seen anything like this. Any help is greatly appreciated! Thx!
*****************create TESTA****************************************************
CREATE OR REPLACE VIEW TESTA AS
SELECT
addr.addressline1 AS address1,
addr.addressline2 AS address2,
addr.addressline3 AS city,
addr.addressline4 AS state,
addr.addressline5 AS zipcode
FROM fapplication app
INNER JOIN findividual ind
ON ind.fapplicationid = app.fapplicationid
LEFT OUTER JOIN fcreditrequest cr
ON app.fapplicationid = cr.fapplicationid
LEFT OUTER JOIN faddress addr
ON ind.findividualid = addr.findividualid
LEFT OUTER JOIN fvrmaxdealstructure ds
ON cr.fcreditrequestid = ds.fcreditrequestid
LEFT OUTER JOIN fvsystemcollectionentry sce1
ON ds.productratetypeid = sce1.fsystemcollectionentryid
LEFT OUTER JOIN fvsystemcollectionentry sce2
ON cr.loanpurposeid = sce2.fsystemcollectionentryid
AND sce2.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid)
LEFT OUTER JOIN fvsystemcollectionentry sce3
ON ds.productpymtfreqid = sce3.fsystemcollectionentryid
AND sce3.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid)
LEFT OUTER JOIN fvsystemcollectionentry sce4
ON ds.productsecuritytypeid = sce4.fsystemcollectionentryid
AND sce4.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, sce4.flanguageid)
LEFT OUTER JOIN fvproductcategory prodcat
ON ds.fproductcategoryid = prodcat.fproductcategoryid
AND prodcat.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, prodcat.flanguageid)
LEFT OUTER JOIN fvproduct prod
ON ds.fproductid = prod.fproductid
AND prod.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, prodcat.flanguageid, prod.flanguageid)
LEFT OUTER JOIN fvrcommonfields udapp1
ON app.fapplicationid = udapp1.applicationid
LEFT OUTER JOIN fvrloanauthfields1 udapp2
ON app.fapplicationid = udapp2.applicationid
LEFT OUTER JOIN fvrloanauthfields2 udapp3
ON app.fapplicationid = udapp3.applicationid
LEFT OUTER JOIN fvrloanauthfields3 udapp4
ON app.fapplicationid = udapp4.applicationid
LEFT OUTER JOIN fvrloanauthfields4 udapp5
ON app.fapplicationid = udapp5.applicationid
LEFT OUTER JOIN fvrmemofields udapp6
ON app.fapplicationid = udapp6.applicationid
WHERE COALESCE(sce1.languagecd, sce2.languagecd, sce3.languagecd, sce4.languagecd, prodcat.languagecd, prod.languagecd, 'EN') = 'EN'
*****************create TESTB****************************************************
CREATE OR REPLACE VIEW TESTB AS
SELECT
addr.addressline1 AS address1,
addr.addressline2 AS address2,
addr.addressline3 AS city,
addr.addressline4 AS state,
addr.addressline5 AS zipcode
FROM fapplication app
INNER JOIN findividual ind
ON ind.fapplicationid = app.fapplicationid
LEFT OUTER JOIN fcreditrequest cr
ON app.fapplicationid = cr.fapplicationid
LEFT OUTER JOIN faddress addr
ON ind.findividualid = addr.findividualid
LEFT OUTER JOIN fvrmaxdealstructure ds
ON cr.fcreditrequestid = ds.fcreditrequestid
LEFT OUTER JOIN fvsystemcollectionentry sce1
ON ds.productratetypeid = sce1.fsystemcollectionentryid
LEFT OUTER JOIN fvsystemcollectionentry sce2
ON cr.loanpurposeid = sce2.fsystemcollectionentryid
AND sce2.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid)
LEFT OUTER JOIN fvsystemcollectionentry sce3
ON ds.productpymtfreqid = sce3.fsystemcollectionentryid
AND sce3.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid)
LEFT OUTER JOIN fvsystemcollectionentry sce4
ON ds.productsecuritytypeid = sce4.fsystemcollectionentryid
AND sce4.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, sce4.flanguageid)
LEFT OUTER JOIN fvproductcategory prodcat
ON ds.fproductcategoryid = prodcat.fproductcategoryid
AND prodcat.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, prodcat.flanguageid)
LEFT OUTER JOIN fvproduct prod
ON ds.fproductid = prod.fproductid
AND prod.flanguageid = COALESCE (sce1.flanguageid, sce2.flanguageid, sce3.flanguageid, prodcat.flanguageid, prod.flanguageid)
LEFT OUTER JOIN fvrcommonfields udapp1
ON app.fapplicationid = udapp1.applicationid
LEFT OUTER JOIN fvrloanauthfields1 udapp2
ON app.fapplicationid = udapp2.applicationid
LEFT OUTER JOIN fvrloanauthfields2 udapp3
ON app.fapplicationid = udapp3.applicationid
LEFT OUTER JOIN fvrloanauthfields3 udapp4
ON app.fapplicationid = udapp4.applicationid
LEFT OUTER JOIN fvrloanauthfields4 udapp5
ON app.fapplicationid = udapp5.applicationid
LEFT OUTER JOIN fvrmemofields udapp6
ON app.fapplicationid = udapp6.applicationid
WHERE COALESCE(sce1.languagecd, sce2.languagecd, sce3.languagecd, sce4.languagecd, prodcat.languagecd, prod.languagecd, 'EN') = 'EN'
*****************create TESTC****************************************************
CREATE OR REPLACE VIEW TESTC AS
SELECT
     TESTA.ADDRESS1,
TESTA.ADDRESS2,
TESTA.CITY,
TESTA.STATE,
TESTA.ZIPCODE
FROM TESTA
UNION ALL
SELECT
TESTB.ADDRESS1,
TESTB.ADDRESS2,
TESTB.CITY,
TESTB.STATE,
TESTB.ZIPCODE
FROM TESTB;

Similar Messages

  • With As subquery block in create view statement or In pl/sql block

    Hi All,
    Can I use the With as subquery block in create view statement??
    or in pl/sql
    -Thanks
    Edited by: xwo0owx on Mar 31, 2011 11:23 AM
    Edited by: xwo0owx on Mar 31, 2011 11:23 AM

    Hi, Mike,
    Dird wrote:
    Then why do I get an error? :s create view mike_test_view as    
    with carriers as(
    SELECT DISTINCT T0.CARRIER_SHORT_NAME carrier_name,
    T1.COMP_ID            carrier_id
    FROM CS2_CARRIER T0, USER_FUNCTION_QUALIFIER T2, CS2_COMP_SERV_PROV_PROF T1
    WHERE (((T1.SERV_PROV_ID = T2.QUALIFIER_VALUE) AND
    ((T2.FUNCTION_CODE = 'DOC_CCM') AND
    (T2.QUALIFIER_CODE = 'CARRIER_LIST'))) AND
    (T1.SERV_PROV_ID = T0.SERV_PROV_ID))
    ORDER BY T0.CARRIER_SHORT_NAME)
    select *
    from carriers c;ORA-00942: table or view does not exist -- carriers
    If I run every line but the create (just execute the query) it runs fine. It also works fine in a PL/SQL procedure.SQL*Plus abhors a vacuum.
    The default in SQL*Plus is that you can not have a completely blank line (that is, a line containing only white space) in the middle of a SQL statement. (Blank lines are okay in PL/SQL, including SQL statements embedded in PL/SQL.)
    If you want some space between the end of the WITH clause and the beginning of the main query (or anywhere else, for that matter), you can put comments there. For example:
          ORDER BY T0.CARRIER_SHORT_NAME)
         select *
           from carriers c;Now that line isn't just whitespace; it has the comment sign, and that's enough for SQL*Plus.
    You can allow completely blank lines with the SQL*Plus command:
    SET   SQLBLANKLINES  ON

  • Create procedure statement Hangs in 11g database, doesn't hang in 10.2

    I have installed 11g on a windows workstation and created a new database. I then attempted to import a schema from a tried and tested 10.2 database, this hung.
    I pinpointed the cause of the hang to a create procedure sstatement within the import file.
    I removed the procedure from the 10.2 database, re-exported and imported sucessfully in to the 11g database minus the rogue prrocedure.
    I now have a create statement for the procedure thats causing the hangs, and this hangs when I try and run it - it runs fine against my 10.2 database?
    I can comment large chunks of the create procedure statment out so I get an anonymous block that runs, and pinpoint the hang down to the inclusion of the the line marked below
    (starting FOR UPDATE OF...........).
    I cant work out whats going on, I'm no programmer by the way!
    Any pointers would be greatly appreciated.
    Nick
    declare
    job_rec job_table%ROWTYPE;
    err_msg varchar2(2000);
    abort_msg varchar2(2000);
    l_ok boolean := TRUE;
    l_bat_job varchar2(14) := 's2_novate_RIC';
    LINES DELETED FOR PURPOSE OF POSTING CURSOR c_sah IS
         SELECT
              sah_next,
              sah_table_key,
              sah_old_status,
              sah_new_status,
              sah_processed_ind,
              sah_processed_date,
              sah_processed_time
         FROM senatordba.sah_status_audit_history
         JOIN (SELECT distinct to_char(spd_next) spd_next
              FROM senatordba.spd_std_risk_dets
              JOIN senatordba.rso_risk_system_options
              ON rso_spd_next = spd_next
              AND spd_ric_code = l_ric_code
              AND coalesce(l_uw_year, spd_yr) = spd_yr
              AND coalesce(l_risk_ref, spd_ref) = spd_ref
         ON spd_next = sah_table_key
         AND sah_table_code = 'SPD'
         AND sah_status_table_code = 'NOV'
         AND sah_processed_ind = 'N';
    FOR UPDATE OF sah_processed_ind, sah_processed_date, sah_processed_time;               <---------if this line is commented out runs OK, if left in, it hangs??
    r_sah c_sah%ROWTYPE;
    begin
    open c_sah;
    close c_sah;
    end;

    Hi Nick, no one else has answered so I thought I'd answer my own question, it appears that I was hitting Oracle bug 9294110. had to uninstall 11.2 and install 11.0.7 instead. very annoyed that I wasted ages diagnosing this known problem. The following test should replicate the hang
    connect / as sysdba
    create user test identified by test default tablespace users temporary tablespace temp;
    grant connect, resource to test;
    connect test/test
    create table a_tab
    ( col001 number, col002 number, col003 number, col004 number);
    create table b_tab( col001 number);
    -- the next statement hangs forever
    select
    a.col002,
    a.col003,
    a.col004
    from
    a_tab a
    left outer join b_tab
    on a.col001 = b_tab.col001
    for update of a.col002,
    a.col003,
    a.col004;

  • Error Creating View on External Table

    I create my oracle directory connected as SYS as SYSDBA and grant read,write to public:
    CREATE OR REPLACE DIRECTORY ER_ADMIN_DIR AS 'C:\win32app\ingr\ER\ER_Init\scripts';
    grant read,write on directory ER_ADMIN_DIR to public;
    I creat my external table from SYS to reside in another schema called DRTEST:
    CREATE TABLE DRTEST.SPEC_REQUIRED (TABLE_NAME VARCHAR2(100), COLUMN_NAME VARCHAR2(100))
    ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ER_ADMIN_DIR
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    LOCATION ('atts_in_red.tx')
    REJECT LIMIT UNLIMITED ;
    I can select from the table and all is good at this point.
    However, I get an error when I try to create a view (in DRTEST from SYS) based on the external table.
    CREATE VIEW DRTEST.MYVIEW1 AS SELECT * FROM DRTEST.SPEC_REQUIRED;
    CREATE VIEW DRTEST.MYVIEW1 AS SELECT * FROM DRTEST.SPEC_REQUIRED
    ERROR at line 1:
    ORA-06564: object ER_ADMIN_DIR does not exist
    (note I'm still connected as SYS as SYSDBA here)
    I can create the view if I connect to DRTEST and run the exact same create view statement there. Is there something in Oracle that prevents me from doing this from the SYS account? I usually think of SYS as having the "Power of God to do all things".
    I have to create the external table and view on several schema's and I don't want the user to have to connect to each schema separately.
    Tina

    Tina,
    I think you are facing bug 2948123 (CREATE VIEW ON EXTERNAL TABLE ORA-6564). The workaround is to connect (in your case) as user DRTEST and then perform the CREATE VIEW statement (you tested this already). Or (according to the bug description) create the view under the SYS schema itself.

  • Doubt in Create View Syntax

    Hi All,
    I want to know the logic behind the following create view statement. Primarily I want to know about the significance of "with" statement in the following command.
    CREATE OR REPLACE FORCE VIEW ODS_DEV.RPT_BU_GEN_REV_V_2
    (HRCHY_ID, FRE_ID, S_BU_ID, BU_ID, EFF_FROM_DT,
    EFF_TO_DT, ACTIVE_FLG, HRCHY_NM_LONG, HRCHY_LVL_NB, S_LVL1,
    LVL1, NM_LONG_1, LOB_CD_1, LVL_NB_1, LVL_NM_1,
    S_LVL2, LVL2, NM_LONG_2, LOB_CD_2, LVL_NB_2,
    LVL_NM_2, S_LVL3, LVL3, NM_LONG_3, LOB_CD_3,
    LVL_NB_3, LVL_NM_3, S_LVL4, LVL4, NM_LONG_4,
    LOB_CD_4, LVL_NB_4, LVL_NM_4, S_LVL5, LVL5,
    NM_LONG_5, LOB_CD_5, LVL_NB_5, LVL_NM_5, S_LVL6,
    LVL6, NM_LONG_6, LOB_CD_6, LVL_NB_6, LVL_NM_6,
    S_LVL7, LVL7, NM_LONG_7, LOB_CD_7, LVL_NB_7,
    LVL_NM_7, S_LVL8, LVL8, NM_LONG_8, LOB_CD_8,
    LVL_NB_8, LVL_NM_8, S_LVL9, LVL9, NM_LONG_9,
    LOB_CD_9, LVL_NB_9, LVL_NM_9, S_LVL10, LVL10,
    NM_LONG_10, LOB_CD_10, LVL_NB_10, LVL_NM_10, S_LVL11,
    LVL11, NM_LONG_11, LOB_CD_11, LVL_NB_11, LVL_NM_11,
    S_LVL12, LVL12, NM_LONG_12, LOB_CD_12, LVL_NB_12,
    LVL_NM_12, S_LVL13, LVL13, NM_LONG_13, LOB_CD_13,
    LVL_NB_13, LVL_NM_13, S_LVL14, LVL14, NM_LONG_14,
    LOB_CD_14, LVL_NB_14, LVL_NM_14, S_LVL15, LVL15,
    NM_LONG_15, LOB_CD_15, LVL_NB_15, LVL_NM_15, S_LVL16,
    LVL16, NM_LONG_16, LOB_CD_16, LVL_NB_16, LVL_NM_16,
    S_LVL17, LVL17, NM_LONG_17, LOB_CD_17, LVL_NB_17,
    LVL_NM_17, S_LVL18, LVL18, NM_LONG_18, LOB_CD_18,
    LVL_NB_18, LVL_NM_18, S_LVL19, LVL19, NM_LONG_19,
    LOB_CD_19, LVL_NB_19, LVL_NM_19, S_LVL20, LVL20,
    NM_LONG_20, LOB_CD_20, LVL_NB_20, LVL_NM_20, S_LVL21,
    LVL21, NM_LONG_21, LOB_CD_21, LVL_NB_21, LVL_NM_21,
    S_LVL22, LVL22, NM_LONG_22, LOB_CD_22, LVL_NB_22,
    LVL_NM_22, S_LVL23, LVL23, NM_LONG_23, LOB_CD_23,
    LVL_NB_23, LVL_NM_23, S_LVL24, LVL24, NM_LONG_24,
    LOB_CD_24, LVL_NB_24, LVL_NM_24, S_LVL25, LVL25,
    NM_LONG_25, LOB_CD_25, LVL_NB_25, LVL_NM_25, S_LVL26,
    LVL26, NM_LONG_26, LOB_CD_26, LVL_NB_26, LVL_NM_26,
    S_LVL27, LVL27, NM_LONG_27, LOB_CD_27, LVL_NB_27,
    LVL_NM_27, S_LVL28, LVL28, NM_LONG_28, LOB_CD_28,
    LVL_NB_28, LVL_NM_28, S_LVL29, LVL29, NM_LONG_29,
    LOB_CD_29, LVL_NB_29, LVL_NM_29, S_LVL30, LVL30,
    NM_LONG_30, LOB_CD_30, LVL_NB_30, LVL_NM_30)
    AS
    WITH parse1 AS
    (SELECT hrchy_id, fre_id, bu_node_id s_node_id, eff_from_dt, eff_to_dt, active_flg, hrchy_nm_long,
         substr(path, instr(path, '/', 1, 1) +1, instr(path, '/', 1, 2) - instr(path, '/', 1, 1) -1) gen_prnt1,
         substr(path, instr(path, '/', 1, 2) +1, instr(path, '/', 1, 3) - instr(path, '/', 1, 2) -1) gen_prnt2,
         substr(path, instr(path, '/', 1, 3) +1, instr(path, '/', 1, 4) - instr(path, '/', 1, 3) -1) gen_prnt3,
         substr(path, instr(path, '/', 1, 4) +1, instr(path, '/', 1, 5) - instr(path, '/', 1, 4) -1) gen_prnt4,
         substr(path, instr(path, '/', 1, 5) +1, instr(path, '/', 1, 6) - instr(path, '/', 1, 5) -1) gen_prnt5,
         substr(path, instr(path, '/', 1, 6) +1, instr(path, '/', 1, 7) - instr(path, '/', 1, 6) -1) gen_prnt6,
         substr(path, instr(path, '/', 1, 7) +1, instr(path, '/', 1, 8) - instr(path, '/', 1, 7) -1) gen_prnt7,
         substr(path, instr(path, '/', 1, 8) +1, instr(path, '/', 1, 9) - instr(path, '/', 1, 8) -1) gen_prnt8,
         substr(path, instr(path, '/', 1, 9) +1, instr(path, '/', 1, 10) - instr(path, '/', 1, 9) -1) gen_prnt9,
         substr(path, instr(path, '/', 1, 10) +1, instr(path, '/', 1, 11) - instr(path, '/', 1, 10) -1) gen_prnt10,
         substr(path, instr(path, '/', 1, 11) +1, instr(path, '/', 1, 12) - instr(path, '/', 1, 11) -1) gen_prnt11,
         substr(path, instr(path, '/', 1, 12) +1, instr(path, '/', 1, 13) - instr(path, '/', 1, 12) -1) gen_prnt12,
         substr(path, instr(path, '/', 1, 13) +1, instr(path, '/', 1, 14) - instr(path, '/', 1, 13) -1) gen_prnt13,
         substr(path, instr(path, '/', 1, 14) +1, instr(path, '/', 1, 15) - instr(path, '/', 1, 14) -1) gen_prnt14,
         substr(path, instr(path, '/', 1, 15) +1, instr(path, '/', 1, 16) - instr(path, '/', 1, 15) -1) gen_prnt15,
         substr(path, instr(path, '/', 1, 16) +1, instr(path, '/', 1, 17) - instr(path, '/', 1, 16) -1) gen_prnt16,
         substr(path, instr(path, '/', 1, 17) +1, instr(path, '/', 1, 18) - instr(path, '/', 1, 17) -1) gen_prnt17,
         substr(path, instr(path, '/', 1, 18) +1, instr(path, '/', 1, 19) - instr(path, '/', 1, 18) -1) gen_prnt18,
         substr(path, instr(path, '/', 1, 19) +1, instr(path, '/', 1, 20) - instr(path, '/', 1, 19) -1) gen_prnt19,
         substr(path, instr(path, '/', 1, 20) +1, instr(path, '/', 1, 21) - instr(path, '/', 1, 20) -1) gen_prnt20,
         substr(path, instr(path, '/', 1, 21) +1, instr(path, '/', 1, 22) - instr(path, '/', 1, 21) -1) gen_prnt21,
         substr(path, instr(path, '/', 1, 22) +1, instr(path, '/', 1, 23) - instr(path, '/', 1, 22) -1) gen_prnt22,
         substr(path, instr(path, '/', 1, 23) +1, instr(path, '/', 1, 24) - instr(path, '/', 1, 23) -1) gen_prnt23,
         substr(path, instr(path, '/', 1, 24) +1, instr(path, '/', 1, 25) - instr(path, '/', 1, 24) -1) gen_prnt24,
         substr(path, instr(path, '/', 1, 25) +1, instr(path, '/', 1, 26) - instr(path, '/', 1, 25) -1) gen_prnt25,
         substr(path, instr(path, '/', 1, 26) +1, instr(path, '/', 1, 27) - instr(path, '/', 1, 26) -1) gen_prnt26,
         substr(path, instr(path, '/', 1, 27) +1, instr(path, '/', 1, 28) - instr(path, '/', 1, 27) -1) gen_prnt27,
         substr(path, instr(path, '/', 1, 28) +1, instr(path, '/', 1, 29) - instr(path, '/', 1, 28) -1) gen_prnt28,
         substr(path, instr(path, '/', 1, 29) +1, instr(path, '/', 1, 30) - instr(path, '/', 1, 29) -1) gen_prnt29,
         substr(path, instr(path, '/', 1, 30) +1, instr(path, '/', 1, 31) - instr(path, '/', 1, 30) -1) gen_prnt30,
    hrchy_lvl_nb
    FROM rpt_bu_gen_rev_v),
    parse2 AS
    (SELECT a.hrchy_id, a.fre_id, a.s_node_id s_bu_id, LTRIM(a.s_node_id,'S') bu_id, a.eff_from_dt, a.eff_to_dt,
    a.active_flg, a.hrchy_nm_long,
    a.hrchy_lvl_nb, a.gen_prnt1 s_lvl1,
    LTRIM (a.gen_prnt1, 'S') lvl1, a.gen_prnt2 s_lvl2,
    LTRIM (a.gen_prnt2, 'S') lvl2, a.gen_prnt3 s_lvl3,
    LTRIM (a.gen_prnt3, 'S') lvl3, a.gen_prnt4 s_lvl4,
    LTRIM (a.gen_prnt4, 'S') lvl4, a.gen_prnt5 s_lvl5,
    LTRIM (a.gen_prnt5, 'S') lvl5, a.gen_prnt6 s_lvl6,
    LTRIM (a.gen_prnt6, 'S') lvl6, a.gen_prnt7 s_lvl7,
    LTRIM (a.gen_prnt7, 'S') lvl7, a.gen_prnt8 s_lvl8,
    LTRIM (a.gen_prnt8, 'S') lvl8, a.gen_prnt9 s_lvl9,
    LTRIM (a.gen_prnt9, 'S') lvl9, a.gen_prnt10 s_lvl0,
    LTRIM (a.gen_prnt10, 'S') lvl10, a.gen_prnt11 s_lvl11,
    LTRIM (a.gen_prnt11, 'S') lvl11, a.gen_prnt12 s_lvl12,
    LTRIM (a.gen_prnt12, 'S') lvl12, a.gen_prnt13 s_lvl13,
    LTRIM (a.gen_prnt13, 'S') lvl13, a.gen_prnt14 s_lvl14,
    LTRIM (a.gen_prnt14, 'S') lvl14, a.gen_prnt15 s_lvl15,
    LTRIM (a.gen_prnt15, 'S') lvl15, a.gen_prnt16 s_lvl16,
    LTRIM (a.gen_prnt16, 'S') lvl16, a.gen_prnt17 s_lvl17,
    LTRIM (a.gen_prnt17, 'S') lvl17, a.gen_prnt18 s_lvl18,
    LTRIM (a.gen_prnt18, 'S') lvl18, a.gen_prnt19 s_lvl19,
    LTRIM (a.gen_prnt19, 'S') lvl19, a.gen_prnt20 s_lvl20,
    LTRIM (a.gen_prnt20, 'S') lvl20, a.gen_prnt21 s_lvl21,
    LTRIM (a.gen_prnt21, 'S') lvl21, a.gen_prnt22 s_lvl22,
    LTRIM (a.gen_prnt22, 'S') lvl22, a.gen_prnt23 s_lvl23,
    LTRIM (a.gen_prnt23, 'S') lvl23, a.gen_prnt24 s_lvl24,
    LTRIM (a.gen_prnt24, 'S') lvl24, a.gen_prnt25 s_lvl25,
    LTRIM (a.gen_prnt25, 'S') lvl25, a.gen_prnt26 s_lvl26,
    LTRIM (a.gen_prnt26, 'S') lvl26, a.gen_prnt27 s_lvl27,
    LTRIM (a.gen_prnt27, 'S') lvl27, a.gen_prnt28 s_lvl28,
    LTRIM (a.gen_prnt28, 'S') lvl28, a.gen_prnt29 s_lvl29,
    LTRIM (a.gen_prnt29, 'S') lvl29, a.gen_prnt30 s_lvl30,
    LTRIM (a.gen_prnt30, 'S') lvl30
    FROM parse1 a)
    SELECT b.hrchy_id, b.fre_id, b.s_bu_id, b.bu_id, b.eff_from_dt, b.eff_to_dt, b.active_flg, b.hrchy_nm_long, b.hrchy_lvl_nb,
    CAST(b.s_lvl1 AS VARCHAR2(13)) s_lvl1,
    CAST(b.lvl1 AS VARCHAR2(13)) lvl1,
    (CASE WHEN b.lvl1 is not null then (select x.nm_long from bu x where x.fre_id=b.fre_id and x.bu_id=b.lvl1)END) nm_long_1,
    (CASE WHEN b.lvl2 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl2)END) lob_cd_1,
    '' lvl_nb_1,
    '' lvl_nm_1,
    CAST(b.s_lvl2 AS VARCHAR2(13)) s_lvl2,
    CAST(b.lvl2 AS VARCHAR2(13)) lvl2,
    (CASE WHEN b.lvl2 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl2)END) nm_long_2,
    (CASE WHEN b.lvl2 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl2)END) lob_cd_2,
    '' lvl_nb_2,
    '' lvl_nm_2,
    CAST(b.s_lvl3 AS VARCHAR2(13)) s_lvl3,
    CAST(b.lvl3 AS VARCHAR2(13)) lvl,
    (CASE WHEN b.lvl3 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl3)END) nm_long_3,
    (CASE WHEN b.lvl3 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl3)END) lob_cd_3,
    '' lvl_nb_3,
    '' lvl_nm_3,
    CAST(b.s_lvl4 AS VARCHAR2(13)) s_lvl4,
    CAST(b.lvl4 AS VARCHAR2(13)) lvl4,
    (CASE WHEN b.lvl4 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl4)END) nm_long_4,
    (CASE WHEN b.lvl4 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl4)END) lob_cd_4,
    '' lvl_nb_4,
    '' lvl_nm_4,
    CAST(b.s_lvl5 AS VARCHAR2(13)) s_lvl5,
    CAST(b.lvl5 AS VARCHAR2(13)) lvl5,
    (CASE WHEN b.lvl5 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl5)END) nm_long_5,
    (CASE WHEN b.lvl5 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl5)END) lob_cd_5,
    '' lvl_nb_5,
    '' lvl_nm_5,
    CAST(b.s_lvl6 AS VARCHAR2(13)) s_lvl6,
    CAST(b.lvl6 AS VARCHAR2(13)) lvl6,
    (CASE WHEN b.lvl6 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl6)END) nm_long_6,
    (CASE WHEN b.lvl6 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl6)END) lob_cd_6,
    '' lvl_nb_6,
    '' lvl_nm_6,
    CAST(b.s_lvl7 AS VARCHAR2(13)) s_lvl7,
    CAST(b.lvl7 AS VARCHAR2(13)) lvl7,
    (CASE WHEN b.lvl7 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl7)END) nm_long_7,
    (CASE WHEN b.lvl7 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl7)END) lob_cd_7,
    '' lvl_nb_7,
    '' lvl_nm_7,
    CAST(b.s_lvl8 AS VARCHAR2(13)) s_lvl8,
    CAST(b.lvl8 AS VARCHAR2(13)) lvl8,
    (CASE WHEN b.lvl8 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl8)END) nm_long_8,
    (CASE WHEN b.lvl8 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl8)END) lob_cd_8,
    '' lvl_nb_8,
    '' lvl_nm_8,
    CAST(b.s_lvl9 AS VARCHAR2(13)) s_lvl9,
    CAST(b.lvl9 AS VARCHAR2(13)) lvl9,
    (CASE WHEN b.lvl9 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl9)END) nm_long_9,
    (CASE WHEN b.lvl9 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl9)END) lob_cd_9,
    '' lvl_nb_9,
    '' lvl_nm_9,
    CAST(b.s_lvl0 AS VARCHAR2(13)) s_lvl10,
    CAST(b.lvl10 AS VARCHAR2(13)) lvl10,
    (CASE WHEN b.lvl10 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl10)END) nm_long_10,
    (CASE WHEN b.lvl10 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl10)END) lob_cd_10,
    '' lvl_nb_10,
    '' lvl_nm_10,
    CAST(b.s_lvl11 AS VARCHAR2(13)) s_lvl11,
    CAST(b.lvl11 AS VARCHAR2(13)) lvl11,
    (CASE WHEN b.lvl11 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl11)END) nm_long_11,
    (CASE WHEN b.lvl11 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl11)END) lob_cd_11,
    '' lvl_nb_11,
    '' lvl_nm_11,
    CAST(b.s_lvl12 AS VARCHAR2(13)) s_lvl12,
    CAST(b.lvl12 AS VARCHAR2(13)) lvl12,
    (CASE WHEN b.lvl12 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl12)END) nm_long_12,
    (CASE WHEN b.lvl12 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl12)END) lob_cd_12,
    '' lvl_nb_12,
    '' lvl_nm_12,
    CAST(b.s_lvl13 AS VARCHAR2(13)) s_lvl13,
    CAST(b.lvl13 AS VARCHAR2(13)) lvl13,
    (CASE WHEN b.lvl13 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl13)END) nm_long_13,
    (CASE WHEN b.lvl13 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl13)END) lob_cd_13,
    '' lvl_nb_13,
    '' lvl_nm_13,
    CAST(b.s_lvl14 AS VARCHAR2(13)) s_lvl14,
    CAST(b.lvl14 AS VARCHAR2(13)) lvl14,
    (CASE WHEN b.lvl14 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl14)END) nm_long_14,
    (CASE WHEN b.lvl14 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl14)END) lob_cd_14,
    '' lvl_nb_14,
    '' lvl_nm_14,
    CAST(b.s_lvl15 AS VARCHAR2(13)) s_lvl15,
    CAST(b.lvl15 AS VARCHAR2(13)) lvl15,
    (CASE WHEN b.lvl15 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl15)END) nm_long_15,
    (CASE WHEN b.lvl15 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl15)END) lob_cd_15,
    '' lvl_nb_15,
    '' lvl_nm_15,
    CAST(b.s_lvl16 AS VARCHAR2(13)) s_lvl16,
    CAST(b.lvl16 AS VARCHAR2(13)) lvl16,
    (CASE WHEN b.lvl16 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl16)END) nm_long_16,
    (CASE WHEN b.lvl16 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl16)END) lob_cd_16,
    '' lvl_nb_16,
    '' lvl_nm_16,
    CAST(b.s_lvl17 AS VARCHAR2(13)) s_lvl17,
    CAST(b.lvl17 AS VARCHAR2(13)) lvl17,
    (CASE WHEN b.lvl17 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl17)END) nm_long_17,
    (CASE WHEN b.lvl17 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl17)END) lob_cd_17,
    '' lvl_nb_17,
    '' lvl_nm_17,
    CAST(b.s_lvl18 AS VARCHAR2(13)) s_lvl18,
    CAST(b.lvl18 AS VARCHAR2(13)) lvl18,
    (CASE WHEN b.lvl18 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl8)END) nm_long_18,
    (CASE WHEN b.lvl18 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl18)END) lob_cd_18,
    '' lvl_nb_18,
    '' lvl_nm_18,
    CAST(b.s_lvl19 AS VARCHAR2(13)) s_lvl19,
    CAST(b.lvl19 AS VARCHAR2(13)) lvl19,
    (CASE WHEN b.lvl19 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl19)END) nm_long_19,
    (CASE WHEN b.lvl19 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl19)END) lob_cd_19,
    '' lvl_nb_19,
    '' lvl_nm_19,
    CAST(b.s_lvl20 AS VARCHAR2(13)) s_lvl20,
    CAST(b.lvl20 AS VARCHAR2(13)) lvl20,
    (CASE WHEN b.lvl20 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl20)END) nm_long_20,
    (CASE WHEN b.lvl20 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl20)END) lob_cd_20,
    '' lvl_nb_20,
    '' lvl_nm_20,
    CAST(b.s_lvl21 AS VARCHAR2(13)) s_lvl21,
    CAST(b.lvl21 AS VARCHAR2(13)) lvl21,
    (CASE WHEN b.lvl21 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl21)END) nm_long_21,
    (CASE WHEN b.lvl21 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl21)END) lob_cd_21,
    '' lvl_nb_21,
    '' lvl_nm_21,
    CAST(b.s_lvl22 AS VARCHAR2(13)) s_lvl22,
    CAST(b.lvl22 AS VARCHAR2(13)) lvl22,
    (CASE WHEN b.lvl22 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl22)END) nm_long_22,
    (CASE WHEN b.lvl22 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl22)END) lob_cd_22,
    '' lvl_nb_22,
    '' lvl_nm_22,
    CAST(b.s_lvl23 AS VARCHAR2(13)) s_lvl23,
    CAST(b.lvl23 AS VARCHAR2(13)) lvl23,
    (CASE WHEN b.lvl23 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl23)END) nm_long_23,
    (CASE WHEN b.lvl23 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl23)END) lob_cd_23,
    '' lvl_nb_23,
    '' lvl_nm_23,
    CAST(b.s_lvl24 AS VARCHAR2(13)) s_lvl24,
    CAST(b.lvl24 AS VARCHAR2(13)) lvl24,
    (CASE WHEN b.lvl24 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl24)END) nm_long_24,
    (CASE WHEN b.lvl24 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl24)END) lob_cd_24,
    '' lvl_nb_24,
    '' lvl_nm_24,
    CAST(b.s_lvl25 AS VARCHAR2(13)) s_lvl25,
    CAST(b.lvl25 AS VARCHAR2(13)) lvl25,
    (CASE WHEN b.lvl25 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl25)END) nm_long_25,
    (CASE WHEN b.lvl25 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl25)END) lob_cd_25,
    '' lvl_nb_25,
    '' lvl_nm_25,
    CAST(b.s_lvl26 AS VARCHAR2(13)) s_lvl26,
    CAST(b.lvl26 AS VARCHAR2(13)) lvl26,
    (CASE WHEN b.lvl26 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl26)END) nm_long_26,
    (CASE WHEN b.lvl26 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl26)END) lob_cd_26,
    '' lvl_nb_26,
    '' lvl_nm_26,
    CAST(b.s_lvl27 AS VARCHAR2(13)) s_lvl27,
    CAST(b.lvl27 AS VARCHAR2(13)) lvl27,
    (CASE WHEN b.lvl27 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl27)END) nm_long_27,
    (CASE WHEN b.lvl27 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl27)END) lob_cd_27,
    '' lvl_nb_27,
    '' lvl_nm_27,
    CAST(b.s_lvl28 AS VARCHAR2(13)) s_lvl28,
    CAST(b.lvl28 AS VARCHAR2(13)) lvl28,
    (CASE WHEN b.lvl28 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl28)END) nm_long_28,
    (CASE WHEN b.lvl28 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl28)END) lob_cd_28,
    '' lvl_nb_28,
    '' lvl_nm_28,
    CAST(b.s_lvl29 AS VARCHAR2(13)) s_lvl29,
    CAST(b.lvl29 AS VARCHAR2(13)) lvl29,
    (CASE WHEN b.lvl29 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl29)END) nm_long_29,
    (CASE WHEN b.lvl29 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl29)END) lob_cd_29,
    '' lvl_nb_29,
    '' lvl_nm_29,
    CAST(b.s_lvl30 AS VARCHAR2(13)) s_lvl30,
    CAST(b.lvl30 AS VARCHAR2(13)) lvl30,
    (CASE WHEN b.lvl30 is not null then (select x.nm_long from bu_node x where x.bu_node_id=b.lvl30)END) nm_long_30,
    (CASE WHEN b.lvl30 is not null then (select x.lob_cd from bu_node x where x.bu_node_id=b.lvl30)END) lob_cd_30,
    '' lvl_nb_30,
    '' lvl_nm_30
    FROM parse2 b;
    Thanks & Regards,
    Subbu S

    create or replace view tv as
    with t as
    (select 1 id, to_date('01/02/1994','MM/DD/YYYY') dte
    from dual
    union
    select 2 id, to_date('02/02/2000','MM/DD/YYYY') dte
    from dual
    union
    select 3 id, to_date('01/05/1988','MM/DD/YYYY') dte
    from dual
    union
    select 4 id, to_date('06/05/2006','MM/DD/YYYY') dte
    from dual)
    select * from t where dte > (select dte from t where id = 4);
    -- eliminate the necessity of writing the same query more than once.
    WITH Clause will add readability of code.
    If the scenario is such that you need to write the same query inline multiple times, you can name it using WITH clause and then use it.
    In some cases it improves the performance as well. Some times it creates global temp table for the query specified in WITH clause. It can improve performance drastically, if the query is complex.
    The life time of the temp table is only till that query executes.....

  • CREATE VIEW with PreparedStatement

    Hi guys,
    I'm trying to run a CREATE VIEW statement, which I have been doing up till now just using a regular Statement, and using the executeUpdate() method. It's been working fine for a while, and now i've hit a bit of a problem.
    I can't include a WHERE clause in a Statement, as it doesn't like the single quotations (') and wildcards. After searching this forum, I saw that I should be using a PreparedStatement, and using the setString() method to put in the ' and %'s.
    Now when I try to run the PreparedStatement using the executeUpdate() method, I get the "Incorrect syntax near the keyword 'VIEW'" error. Can anyone tell me if i'm using the right method for executing the PreparedStatement, or what i'm doing wrong?
    Regards,
    Jack Smith

    SQL statements are often broken up into two classes, DML (data manipulation language) and DDL (data definition language). DML contains the normal CRUD statements, INSERT, SELECT, UPDATE, DELETE and anything else that modifes the data but not the data structure. DDL is the set of statements that manipulates the data structure, things like CREATE, ALTER, DROP.
    As a general rule of thumb, you shouldn't do DDL in a PreparedStatement.
    PreparedStatements exist primarily to allow late-binding of data-value objects into the internal datastructure within the database that represents a parsed SQL statement's execution plan. It is NOT a mechanism for doing string substitution (though I understand who it can look that way to beginners).
    Another way of saying this is that PreparedStatement is based on the distinction between data and code; in a DDL statement, the entire statement is code.
    There are a few drivers/databases where this might happen to work, because they aren't really seriously implementing PreparedStatement but merely doing string replacement to fake it. I very much doubt SQL server is going to be one of these.

  • Feature Request: "View States" (layer visibility state)

    Hi all,
    I've been using Illustrator now for many years.  A large majority of the graphics I create are used in Flash for many of the games I develop.  Some of the graphics are exported from Illustrator as vector art, some are output as raster.
    There is a game that we've been working on recently that demonstrated a large need for a feature I came up with known as "View States."
    Why this is important to me:
    When you have an Illustrator file that contains many graphical elements, no matter how they are arranged in Illustrator using multiple layers or not, it is very, VERY challenging to be able to remember which layers and/or graphical elements should be kept visible, and which shouldn't be kept visible when you are outputing graphics in various ways.
    Going back to the game that my co-worker and I were working on, we have an Illustrator file that has 4 layers at the root level, in those layers, many more graphical elements and sub-layers each containing many, MANY more elements and sub-layers.  The game we are working is designed such that the background of the game is raster art; however, other foreground elements are output as vector art.  Anytime a change needs to be made to the artwork, I have to remember which layers I should hide and which should be kept visible in order to output the necessary graphics in whatever format I need to.
    The first question you may ask is, "Why not simply create a layer structure that allows you to simply hide the foreground or background elements so that you can output exactly what you need?"  That is a very good approach at producing the artwork.  And I'm completely open to changing the way I work being that is the only way I've been able to grow as a digital artist. However, I feel that this feature has merit in providing a simpler way for designers to work if they are unwilling or don't care to change the way they work.  In addition, some of the graphics we developed are grouped in such a way that splitting them could make it more challenging to find pieces of art in a file that has many many layers.
    How this feature may work:
    Basically a new panel titled "View States" would be in the interface.  This panel would allow you to create "view state" instances.  In each instance you provide a name for it to make it easier for you to remember what it is for.
    Each view state, when selected, would hide or show the layers you've set to be visible or not visible for that particular view state, thereby making it easier for the designer to know which graphics need to be output for a particular element of their artwork.  If you want to change the visible properties of a layer for a particular view state, simply select the view state and then alter the visibility property of that layer and it will remember that information for that particular view state.
    There are many other options that could be added for this feature, but I just wanted to get the feature information out there to see what you guys think.

    Hello Sly,
    I did exactly thuch beast for freehand some years ago. It's called Layersets. Perhaps we can discuss this off list first.
    My Email is [email protected]
    regards
    Michael

  • Create view on type??

    Hi all,
    Yesterday, I hit the bug:
    DataPump Export (expdp) Returns ORA-1427 When Partitioned IOT With Same Name Exists in More Than One Schema [ID 1064840.1]
    One of the resolutions for this is to re-create ku$_iotpart_data_view view with the following code:
    create or replace force view ku$_iotpart_data_view of ku$_table_data_t with object OID(obj_num) as
    select '1','2',
           ip.obj#,
           (select o1.obj#
            from   obj$ o1
            where  o1.name=bo.name
                   and o1.subname=o.subname
                   and o1.owner#=o.owner_num),
           o.subname,
           NULL,
           po.parttype,
           t.property,
           t.trigflag,
           dbms_metadata_util.get_xmltype_fmts(t.obj#),
           decode ((select 1
                    from   dual
                    where  (exists (select q.obj#
                                    from   sys.opqtype$ q
                                    where  q.obj#=t.obj#
                                           and q.type=1 /* xmltype col */
                                           and bitand(q.flags,2+64)!=0))), /* CSX or SB */
                    1,'Y','N'),
           decode ((select count(*) /* outofline xml table */
                    from   sys.opqtype$ q
                    where  q.obj# = t.obj# and
                           bitand(q.flags, 32) = 32 ),
                    1,'Y','N'),
           'N', /* partitioned table cannot have column with LONG datatype */
           decode ((select count(*)
                    from   sys.type$ ty, sys.coltype$ ct
                    where  ty.toid=ct.toid and ty.version#=ct.version#
                           and ct.obj#=t.obj#
                           /* 0x00008000 = 32768 = contains varray attribute */
                           /* 0x00100000 = 1048576 = has embedded non final type */
                           and bitand(ty.properties,1081344)=1081344),
                    0,'N','Y'),
           decode ((select count(*)
                    from   sys.refcon$ rf, sys.col$ c
                    where  c.obj#=rf.obj# and c.intcol#=rf.intcol#
                           and c.obj#=t.obj#
                           and bitand(rf.reftyp,1)=0), /* ref is non-scoped */
                    0,'N','Y'),
           'N', /* default 'has_tstz_cols' to 'N' */
           value(o),
           ts.name, ts.blocksize, b.bytes_alloc,
           value(bo),
           -- if this is a secondary table, get domidx obj and ancestor obj
           decode (bitand (bo.flags, 16), 16,
                   (select value(oo)
                    from   ku$_schemaobj_view oo, secobj$ s
                    where  bo.obj_num=s.secobj#
                           and oo.obj_num=s.obj#
                           and rownum < 2),
                   null),
           decode (bitand (bo.flags, 16), 16,
                   (select value(oo)
                    from   ku$_schemaobj_view oo, ind$ i, secobj$ s
                    where  bo.obj_num=s.secobj#
                           and i.obj#=s.obj#
                           and oo.obj_num=i.bo#
                           and rownum < 2),
                   null),
           um.unload_method,
           um.et_parallel,
           (select count(*)
            from   rls$ r
            where  r.obj#=t.obj# and r.enable_flag=1 and bitand(r.stmt_type,1)=1),
            0 -- note: piot cannot be ref partitioned
    from   ku$_iotpart_bytes_alloc_view b,
           ku$_schemaobj_view o, ku$_schemaobjnum_view bo,
           ku$_unload_method_view um, tab$ t,
           ind$ i, indpart$ ip, ts$ ts, partobj$ po
    where  ip.obj# = o.obj_num
           AND o.type_num = 20 -- index partition
           AND bo.obj_num = po.obj#
           AND ip.bo#=i.obj#
           AND i.type#=4 -- iot index
           AND i.bo#=t.obj#
           AND t.obj# = um.obj_num
           AND ip.ts# = ts.ts#
           AND b.obj_num=ip.obj#
           AND bo.obj_num=i.bo#
           AND (bitand (bo.flags,16)!=16
                OR sys.dbms_metadata.oktoexp_2ndary_table(bo.obj_num)=1)
           AND (SYS_CONTEXT ('USERENV','CURRENT_USERID') IN (o.owner_num, 0) OR
                EXISTS (SELECT *
                        FROM   sys.session_roles
                        WHERE  role='SELECT_CATALOG_ROLE'))
    /I did that as sys and created in INVALID state. When i do show errors, I get "table or view does not exist".. and indeed, if i search the object on what this view is being created, i get the following:
    sys@devbase> select object_name, object_type, status
    2 from dba_objects where object_name like '%TABLE_DATA_T%';
    OBJECT_NAME OBJECT_TYPE STATUS
    KU$_TABLE_DATA_T TYPE VALID
    This is an Oracle Type. I am not sure if we can create views on types... And even if can, why am I getting ORA-00942 if i am connected as sys???
    Did anybody hit this problem? Can you please help to compile this thing?
    Thanks a lot in advance!!!
    M
    Edited by: MarGur on Feb 11, 2011 10:10 AM
    Edited by: MarGur on Feb 11, 2011 10:14 AM

    Thanks for formatting the original post. It now makes a lot more sense.
    Still worth opening a SR even though it's non-critical. Nothing wrong with asking both places - especially since you know that it'll take days before they get to it, so why wait those days AFTER you give up here <g>
    As to your question whether views can be created on types, reference the SQL Language Reference manual at http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_8004.htm#i2065510 where it states
    Use the CREATE VIEW statement to define a view, which is a logical table based on one or more tables or views. A view contains no data itself. The tables upon which a view is based are called base tables.
    You can also create an object view or a relational view that supports LOBs, object types, REF data types, nested table, or varray types on top of the existing view mechanism. An object view is a view of a user-defined type, where each row contains objects, each object with a unique object identifier.
    I would encourage you to post the actual error message from the compile.

  • Unable to create view

    I want to create a view with the code you may see below. Then, I get error "ORA-00942 table or view does not exist
    " when issuing a CREATE VIEW statement. However, I get no error when executing the query. All tables and views exist. What could be wrong? Thanks.
    Select grupo_costos,
    Sum(Enero)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '1', '2004','EDI','USD', '1') as Enero,
    Sum(Febrero)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '2', '2004','EDI','USD', '1') as Febrero,
    Sum(Marzo)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '3', '2004','EDI','USD', '1') as Marzo,
    Sum(Abril)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '4', '2004','EDI','USD', '1') as Abril,
    Sum(Mayo)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '5', '2004','EDI','USD', '1') as Mayo,
    Sum(Junio)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '6', '2004','EDI','USD', '1') as Junio,
    Sum(Julio)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '7', '2004','EDI','USD', '1') as Julio,
    Sum(Agosto)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '8', '2004','EDI','USD', '1') as Agosto,
    Sum(Septiembre)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '9', '2004','EDI','USD', '1') as Septiembre,
    Sum(Octubre)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '10', '2004','EDI','USD', '1') as Octubre,
    Sum(Noviembre)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '11', '2004','EDI','USD', '1') as Noviembre,
    Sum(Diciembre)/parts_cost_evol_api.Monthly_Avg_Curr_Rate__ ( '12', '2004','EDI','USD', '1') as Diciembre
    from
    ((select costs.part_group_desc as grupo_costos,
         decode(extract(month from trans.date_applied), 1, sum(acc.curr_amount),0) as Enero,
         decode(extract(month from trans.date_applied), 2, sum(acc.curr_amount), 0) as Febrero,
         decode(extract(month from trans.date_applied), 3, sum(acc.curr_amount), 0) as Marzo,
         decode(extract(month from trans.date_applied), 4, sum(acc.curr_amount), 0) as Abril,
         decode(extract(month from trans.date_applied), 5, sum(acc.curr_amount), 0) as Mayo,
         decode(extract(month from trans.date_applied), 6, sum(acc.curr_amount), 0) as Junio,
         decode(extract(month from trans.date_applied), 7, sum(acc.curr_amount), 0) as Julio,
         decode(extract(month from trans.date_applied), 8, sum(acc.curr_amount), 0) as Agosto,
         decode(extract(month from trans.date_applied), 9, sum(acc.curr_amount), 0) as Septiembre,
         decode(extract(month from trans.date_applied), 10, sum(acc.curr_amount), 0) as Octubre,
         decode(extract(month from trans.date_applied), 11, sum(acc.curr_amount), 0) as Noviembre,
         decode(extract(month from trans.date_applied), 12, sum(acc.curr_amount), 0) as Diciembre                    
    from ifsapp.inventory_transaction_hist2 trans, ifsapp.mpccom_accounting acc, ifsapp.part_catalog part, part_costs_evol_tab costs
    where trans.transaction_id = acc.accounting_id
         and trans.part_no = part.part_no
         and trans.part_no = costs.part_no
         and extract(year from trans.date_applied) = '2004'
         and ((upper(trans.transaction_code) IN ('INTSHIP', 'INTUNISS') and acc.str_code = 'M53') or
              (upper(trans.transaction_code) = 'NISS' and acc.str_code = 'M2') or
              (upper(trans.transaction_code) IN ('WOISS', 'WOUNISS') and acc.str_code = 'M50'))
    group by costs.part_group_desc, extract(month from trans.date_applied))
    UNION
    (select distinct costs.part_group_desc as grupo_costos, 0,0,0,0,0,0,0,0,0,0,0,0                
    from part_costs_evol_tab costs))
    group by grupo_costos

    We cannot build stored procedures or views using privileges granted to us through roles. That is just the way the Oracle security model works. Sometimes I understand it, sometimes I think it's weird - it depends whether there's an R in the month. I certainly find it annoying when I'm am trying to develop some code and a lazy DBA has only granted me CONNECT and RESOURCE instead of the precise privileges I actually need.
    Privileges granted through roles always work in SQL*Plus.
    Cheers, APC

  • Creating view containing case statements received error ORA-22992

    We have a create view referencing table through dblink. The select statement in the create view has case statements, when running the Select statement alone, results are return. However, when executing the create view, it returns:
    SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
    22992. 00000 - "cannot use LOB locators selected from remote tables"
    *Cause:    A remote LOB column cannot be referenced.
    *Action:   Remove references to LOBs in remote tables.
    One of the source table has LOB column but not in the select statement. The strange thing is when removing the case statement from the select, create view works fine. Can anybody tell me what caused the error and how to fix it?
    Create View Snippet:
    CREATE OR REPLACE VIEW "ABC"."XYZ" (....
    AS SELECT
    CASE
    WHEN A.OUTAGE =1
    THEN 'Y'
    ELSE 'N'
    END AS OUTAGE,
    FROM
    TABLEA@XXXX A
    LEFT JOIN TABLEB@XXXX B
    ON
    A.LOC =B.LO
    AND A.SITE =B.SITE
    WHERE
    A.CLASS ='CUSTOMER'
    AND A.PLUSSISGIS =1;

    What is your 4 digit Oracle version?
    Try rewriting the query to not use ANSI SQL92 joins. I found a link where this solved a problem similar to yours.
    DBLink problem ORA-22992
    >
    But, look at this curious thing: I re-write the query as follows:
    SELECT A.ID, A.ID_REF, A.EVENDATE, B.DESCRIPTION
    FROM A@ORCL A, B@ORCL B
    WHERE A.ID_REF = B.ID_REF;
    and it works fine... It seems like Oracle don't like the ANSI SQL92...
    >
    Several similar links by googling: 'SQL Error: ORA-22992'
    http://www.dbuggr.com/smallwei/solution-error-ora-22992-lob-locators-selected-remote-tabl/
    >
    Fixing ORA-22992 “cannot use LOB locators selected from remote tables” error
    You have migrated your Oracle 9i database to 10g and a distributed statement which worked fine in 9i now is getting error ORA-22992 “cannot use LOB locators selected from remote tables”. Even though the related remote table(s) does not contain any LOB column datatype.
    FIX:
    There is a bug on 9i,10g, and 11g that is related to this error. It is being fixed in 11.2. It can also be backported for previous 9i, 10g and 11g releases under the latest patchsets.
    You may also do a workaround as follow:
    Modify the affected SQL by adding the TO_CHAR function. For example:
    -- Original SQL:
    SELECT NVL2('a', 'b','c' ) FROM dual@remote_db;
    -- Modified SQL:
    SELECT TO_CHAR(NVL2('a','b','c')) FROM dual@remote_db;
    >
    See if that helps.

  • How to create view that has an update statement

    Tools: MS Management Studio SQL 2008 R2
    Code:
    Create View as Mocha
    UPDATE dbo.Cola
    SET Login_ID = Replace(PE15,RTRIM(Cast(Login_ID),'')
    UPDATE dbo.cola
    SET P4 = NullIf(P4,'')
    I would like to create a database object "View" to hand it over to a user and run the script. How I would create a a view that would accept an update statement. Are any work around to accomplish this goal

    Not quite sure what you want to achieve.
    However, if your view displays rows from a single table and each row relates to exactly one row in the source table (no aggregates, no join, no transformation) then you can update it.  The update will be executed on the table it refers to.
    If you view is more complex, contains joins, aggregates and such, you can create a trigger on it to update the base table(s).
    The conditions for a view to be updatable are a little more complex then what I wrote but you can find it here under "updatable view":
    http://msdn.microsoft.com/en-CA/library/ms187956.aspx
    In the end, you would have a view which displays rows and can be updated.
    If all you want is to modify rows without viewing them then HuaMin Chen's solution is the one for you, create a stored procedure instead.

  • How to create static list type view state?

    Hi!
    i want to create a static List type view state in asp.net c# for below type of list?
    static List<KeyValuePair<string, int>> istrStartDate = new List<KeyValuePair<string, int>>();

    Please  post it in the dedicated ASP.Net Forum
    http://forums.asp.net  for more efficient responses.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Create view and alter Session gets 0RA-01031

    I can't create a view after using ALTER SESSION set current_schema without using an explicit schema. I get ORA-01031. Is this a known bug? Here are the details:
    1. Log on as SYSTEM
    2. ALTER SESSION set current_schema=FRED;
    3. CREATE VIEW vFoo as select * from Foo;     -- ORA-01031: insufficient privileges
    4. CREATE VIEW FRED.vFoo as select * from Foo;     -- this works!
    I've read where some privileges need to be granted directly. In fact, if Fred grants select privilege on Foo to SYSTEM, the statement in #3 above works. However, something doesn't seem right because why does #4 succeed without the GRANT?
    In case you're wondering why I don't just use #4 above, which does work, it's because I've got a script that will be run by customers to create tables, views, etc. in an arbitrary schema and the schema is associated with a user with limited permissions. Hence, the use of the ALTER SESSION.

    See, You looged as SYSTEM (Scheme = SYSTEM)
    Now you alter your session to another schema FRED.
    Now if you want to access SCHEMA of FRED, You need to connect first.
    SQL > connect user/password@host
    Then
    SQL > CREATE VIEW vFoo as select * from Foo;
    View created.

  • How to CREATE VIEW to merge two tables each of which has CLOB-typed column

    I failed in creating a view to merge two tables that have CLOB-type column each.
    The details are:
    Database: Oracle 9i (9.2.0)
    Two tables "test" and "test_bak", each of which has the following structure:
    ID Number(10, 0)
    DUMMY VARCHAR2(20)
    DUMMYCLOB CLOB
    The following operation fails:
    create view dummyview (id, dummy, dummyclob) as
    select id, dummy, dummyclob from test
    union
    select id, dummy, dummyclob from test_bak;
    I was announced:
    select test.id, test.dummy, test.dummyclob
    ERROR in line 2:
    ORA-00932: inconsistent data type: required - , but CLOB presented.
    But if creating views from only ONE table with CLOB-type columns, or from two tables WITHOUT CLOB-typed columns, the creation will succeed. The following 1) and 2) will succeed, both:
    1) one table, with CLOB-typed column
    create view dummyview (id, dummy, dummyclob) as
    select id, dummy, dummyclob from test;
    2) two tables, without CLOB-typed columns
    create view dummyview (id, dummy) as
    select id, dummy from test
    union
    select id, dummy from test_bak;
    I want to merge the two tables all, with complete columns, how to write the CREATE VIEW SQL statement?
    many thanks in advance

    Dong Wenyu,
    No.
    But you could do this:
    SELECT source.*, nvl (tab1.clob_column, tab2.clob_column)
    FROM your_table1 tab1, your_table2 tab2, (
    SELECT primary_key, ...
    FROM your_table1
    UNION
    SELECT primary_key, ...
    FROM your_table2
    ) source
    WHERE source.primary_key = tab1.id (+)
    AND source.primary_key = tab2.id (+)
    In other words, do the set operation (UNION (ALL)/INTERSECT/MINUS) on just the PK columns before pulling in the LOB columns.
    d.

  • Non-sense error message trying to create view

    Greetings All,
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production on Windows 2008R2
    I am getting an error while trying to create a view. The error makes no sense in that no attempt to change a user name or password as the error message being produced suggests.
    I can execute the entire select statement fine, I get results back.
    If I comment out the line indicated as being in error, the problem moves to the line prior to the one commented out. The 4 lines prior to the line indicated by the error message are similar. The error is occurring on the last of the 5 similar lines of code.
    If I move all 5 lines further up in the code the error moves accordingly.
    The function validate_number (near where the error is identified) under certain conditions will issue a execute immediate 'alter session set nls_numeric_characters = ''.,''';
    The column number identified in the error message is 2 spaces prior to the validate_number function call.
    Below is the syntax for the creation of the view, the error message is at the bottom.
    The numbers to the far left indicate the line number. I put 2 blank lines before and after the line of code identified by the error message.
    The error points to the 2-spaces in front of the VALIDATE_NUMBER function call on line 350. just before the sql code ==> validate_number(Spend_Qty,'')),0) <==
    Thanks for your time,
    Bob
    CREATE OR REPLACE VIEW REPORT_STAGING_V AS
    -  SELECT
    -    SPEND_STAGING.INPUT_FILE_ID,
    -    SPEND_STAGING.SPEND_ID,
    -    SPEND_STAGING.SPEND_DOC_NUM,
    -    SPEND_STAGING.SPEND_DOC_ITM_NUM,
    -    SPEND_STAGING.SPEND_DOC_YR_NUM,
    -    SPEND_STAGING.ACCT_PYBL_INV_DOC_NUM,
    -    SPEND_STAGING.ACCT_PYBL_INV_FSCL_YR_NUM,
    -    SPEND_STAGING.COMPANY_CODE,
    -    SPEND_STAGING.ACCT_PYBL_INV_LN_ITM_NUM,
    -    SPEND_STAGING.SPEND_DOC_TYPE_CD,
    -    SPEND_STAGING.SPEND_MTHD_TXT,
    -    NVL(SPEND_STAGING.SRC_SYS_CD, '<BLANK>') SRS_SYS_CD,
    -    SPEND_STAGING.SPEND_SAVING_DT,
    -    SPEND_STAGING.SPEND_SAVING_FSCL_WK_NUM,
    -    SPEND_STAGING.SPEND_SAVING_FSCL_MTH_NUM,
    -    SPEND_STAGING.SPEND_SAVING_FSCL_QTR_NUM,
    -    SPEND_STAGING.SPEND_SAVING_FSCL_YR_NUM,
    -    SPEND_STAGING.MTRL_GRP_CD,
    -    SPEND_STAGING.MTRL_GRP_DESC_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_1_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_2_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_3_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_4_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_5_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_6_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_7_TXT,
    -    SPEND_STAGING.MTRL_GRP_LVL_8_TXT,
    -    SPEND_STAGING.GL_ACCT_NUM,
    -    SPEND_STAGING.GL_ACCT_DESC,
    -    SPEND_STAGING.COST_CENTR_CD,
    -    SPEND_STAGING.PRFT_CENTR_CD,
    -    SPEND_STAGING.FUNCNL_AREA_CD,
    -    SPEND_STAGING.PURCH_GRP_CD,
    -    SPEND_STAGING.PURCH_GRP_NAM,
    -    SPEND_STAGING.PURCH_ORG_CD,
    -    SPEND_STAGING.PURCH_ORG_NAM,
    -    SPEND_STAGING.REGION_CODE,
    -    SPEND_STAGING.VNDR_ACCT_ROOT_NUM,
    -    SPEND_STAGING.VNDR_CORP_NAM,
    -    SPEND_STAGING.VNDR_CORP_TICKER_SYMBL_CD,
    -    SPEND_STAGING.BUYPOINT_VNDR_ACCT_NUM,
    -    SPEND_STAGING.BUYPOINT_VNDR_FIRST_NAM,
    -    SPEND_STAGING.PAYPOINT_VNDR_ACCT_NUM,
    -    SPEND_STAGING.PAYPOINT_VNDR_FIRST_NAM,
    -    SPEND_STAGING.SPEND_PYMNT_TERM_CD,
    -    SPEND_STAGING.SPEND_PYMNT_TERM_DESC,
    -    SPEND_STAGING.SPEND_PYMNT_BSLN_DT,
    -50  SPEND_STAGING.SPEND_PYMNT_CLRNG_DT,
    -    SPEND_STAGING.CONTRACTUAL_PYMNT_TERM_DY_CNT,
    -    SPEND_STAGING.VNDR_MTRL_NUM,
    -    SPEND_STAGING.MTRL_ID_1280,
    -    SPEND_STAGING.MTRL_DESC,
    -    SPEND_STAGING.BAT_NUM,
    -    SPEND_STAGING.SPCL_STOCK_IND,
    -    SPEND_STAGING.INVTY_MVMNT_TYPE_CD,
    -    SPEND_STAGING.GOODS_RCPNT_NAM,
    -    SPEND_STAGING.MFG_PART_NUM,
    -    SPEND_STAGING.PLANT_CD,
    -    SPEND_STAGING.PLANT_DESC,
    -    SPEND_STAGING.STORAGE_LOC_CD,
    -    SPEND_STAGING.STORAGE_LOC_DESC,
    -    SPEND_STAGING.UNLOADING_PT_DESC,
    -    SPEND_STAGING.PO_NUM,
    -    SPEND_STAGING.PO_LN_ITM_NUM,
    -    SPEND_STAGING.PO_LN_ITM_LAST_CHNG_DT,
    -    SPEND_STAGING.PO_DOC_DT,
    -    SPEND_STAGING.PO_TYPE_CD,
    -    SPEND_STAGING.PO_TYPE_DESC,
    -    SPEND_STAGING.PO_UOM_CD,
    -    SPEND_STAGING.PO_PYMNT_TERM_CD,
    -    SPEND_STAGING.ASGND_ACCT_CTGRY_TYPE_CD,
    -    SPEND_STAGING.PO_SHORT_TXT,
    -    SPEND_STAGING.GR_MTRL_DOC_TXT,
    -    SPEND_STAGING.ACCT_PYBL_INV_ITM_TXT,
    -    SPEND_STAGING.PO_RCPT_INV_HST_DOC_POST_DT,
    -    SPEND_STAGING.APPRTN_NUM,
    -    SPEND_STAGING.REQTN_TRK_NUM,
    -    SPEND_STAGING.REQTN_LN_NUM,
    -    SPEND_STAGING.REQTN_LN_ITM_NUM,
    -    SPEND_STAGING.REQTN_PERSN_ACCT_ID,
    -    SPEND_STAGING.NTWRK_NUM,
    -    SPEND_STAGING.NTWRK_CTGRY_CD,
    -    SPEND_STAGING.PROJ_NAM,
    -    SPEND_STAGING.WBS_ELMNT_NAM,
    -    SPEND_STAGING.CPTL_PO_IND,
    -    LU_GAC_STAGING.TIER_SUPPLIER,
    -    CASE
    -      WHEN SPEND_STAGING.PRCRMNT_RPTNG_LVL_3_TXT = 'GAC'
    -      AND LU_GAC_STAGING.PO_SHORT_TXT            = SPEND_STAGING.PO_SHORT_TXT
    -      AND SPEND_STAGING.SRC_SPLR_NAM            IS NULL
    -      THEN LU_GAC_STAGING.TIER_SUPPLIER
    -      ELSE SRC_SPLR_NAM
    -    END SRC_SPLR_NAM,
    -    SPEND_STAGING.TAX_CD,
    -    SPEND_STAGING.TAX_CD_DESC,
    -    SPEND_STAGING.TAX_JURISDICTION_TXT,
    -    SPEND_STAGING.MTRL_DOC_PRCS_UOM_QTY,
    -100 SPEND_STAGING.MTRL_DOC_UNIT_OF_ENTRY_QTY,
    -    SPEND_STAGING.PO_LN_ITM_QTY,
    -    SPEND_STAGING.PO_LN_ITM_NET_PRC_UNIT_QTY,
    -    SPEND_STAGING.PO_LN_ITM_NET_PRC_USD_AMT,
    -    SPEND_STAGING.PO_LN_ITM_NET_PRC_DC_AMT,
    -    SPEND_STAGING.PO_LN_ITM_NET_PRC_BDGT_USD_AMT,
    -    SPEND_STAGING.PO_LN_ITM_TOT_USD_AMT,
    -    SPEND_STAGING.SPEND_USD_AMT,
    -    SPEND_STAGING.SPEND_DOC_CURNCY_AMT,
    -    SPEND_STAGING.SPEND_LOCAL_CURNCY_AMT,
    -    SPEND_STAGING.SPEND_BDGT_USD_AMT,
    -    SPEND_STAGING.SPEND_QTY,
    -    SPEND_STAGING.SPEND_QTY_UOM_CD,
    -    SPEND_STAGING.SPEND_UNIT_OF_ENTRY_QTY,
    -    SPEND_STAGING.SPEND_UNIT_OF_ENTRY_UOM_CD,
    -    SPEND_STAGING.SPEND_DC_FX_MTH_CNVRSN_FCT_VAL,
    -    SPEND_STAGING.SPEND_DC_FX_BDG_CNVRSN_FCT_VAL,
    -    SPEND_STAGING.CMPNY_LOCAL_CURNCY_CD,
    -    SPEND_STAGING.DOC_CURNCY_CD,
    -    SPEND_STAGING.TRANSTN_TYPE_CD,
    -    SPEND_STAGING.ACCT_ASGNMT_SEQ_NUM,
    -    SPEND_STAGING.GLPCA_LN_ITM_REC_NUM,
    -    SPEND_STAGING.PCA_REF_DOC_NUM,
    -    SPEND_STAGING.CO_DOC_NUM,
    -    SPEND_STAGING.CO_FSCL_YR_NUM,
    -    SPEND_STAGING.CO_LN_ITM_NUM,
    -    SPEND_STAGING.VNDR_REF_DOC_NUM,
    -    SPEND_STAGING.SAVING_MTHD_TXT,
    -    SPEND_STAGING.SAVING_CMNT_TXT,
    -    SPEND_STAGING.SAVING_COND_NUM,
    -    SPEND_STAGING.SAVING_COND_ITM_NUM,
    -    SPEND_STAGING.SAVING_COND_TYPE_CD,
    -    SPEND_STAGING.SAVING_COND_TYPE_DESC,
    -    SPEND_STAGING.SAVING_COND_CURNCY_CD,
    -    SPEND_STAGING.SAVING_COND_PRC_UNIT_UOM_CD,
    -    SPEND_STAGING.SAVING_COND_PRC_UNIT_QTY,
    -    SPEND_STAGING.SAVING_COND_RTE_USD_AMT,
    -    SPEND_STAGING.SAVING_COND_CURNCY_CNVRSN_VAL,
    -    SPEND_STAGING.SAVING_COND_CURNCY_BDGT_CNVRSN,
    -    SPEND_STAGING.PO_TRANSTN_COND_DC_AMT,
    -    SPEND_STAGING.PO_TRANSTN_COND_USD_AMT,
    -    SPEND_STAGING.SAVING_RTE_PER_USD_AMT,
    -    SPEND_STAGING.SAVING_PER_USD_AMT,
    -    SPEND_STAGING.SAVING_PER_BDGT_USD_AMT,
    -    SPEND_STAGING.AVOIDANCE_USD_AMT,
    -    SPEND_STAGING.AVOIDANCE_BDGT_USD_AMT,
    -    SPEND_STAGING.SAVING_USD_AMT,
    -    SPEND_STAGING.SAVING_BDGT_USD_AMT,
    -    SPEND_STAGING.NO_FX_SAVING_USD_AMT,
    -    SPEND_STAGING.NO_FX_AVOIDANCE_USD_AMT,
    -150 SPEND_STAGING.TOT_REDUCTN_USD_AMT,
    -    SPEND_STAGING.TOT_REDUCTN_BDGT_USD_AMT,
    -    SPEND_STAGING.TOT_NO_FX_REDUCTN_USD_AMT,
    -    SPEND_STAGING.PAYMENTNET_TRANSTN_NUM,
    -    SPEND_STAGING.PAYMENTNET_TRANSTN_LN_ITM_NUM,
    -    SPEND_STAGING.ROW_CRTE_GMT_DTTM,
    -    SPEND_STAGING.ROW_MODIFY_GMT_DTTM,
    -    SPEND_STAGING.ROW_CRTE_MST_DTTM,
    -    SPEND_STAGING.ROW_MODIFY_MST_DTTM,
    -    SPEND_STAGING.PRCRMNT_DIRECTOR_NAM,
    -    SPEND_STAGING.PRCRMNT_PLANT_DSGNTN,
    -    SPEND_STAGING.PRCRMNT_RPTNG_LVL_1_TXT,
    -    SPEND_STAGING.PRCRMNT_RPTNG_LVL_2_TXT,
    -    SPEND_STAGING.PRCRMNT_RPTNG_LVL_3_TXT,
    -    SPEND_STAGING.SPEND_CAT_ID,
    -    SPEND_STAGING.SPEND_RULE_ID,
    -    SPEND_STAGING.TRANSACTION_DATE,
    -    SPEND_STAGING.SPEND_AMOUNT,
    -    SPEND_STAGING.ITEM_DESCRIPTION,
    -    SPEND_STAGING.SUPPLIER_ID,
    -    CASE
    -      WHEN SPEND_STAGING.SOURCE ='SPEND'
    -      THEN 'Spend and Savings'
    -      WHEN SPEND_STAGING.SOURCE ='TRAVEL'
    -      THEN 'Travel'
    -      ELSE NULL
    -    END SOURCE,
    -    SPEND_STAGING.SUPPLIER_NUMBER,
    -    SPEND_STAGING.TRAVEL_PERSNO,
    -    SPEND_STAGING.TRIP,
    -    SPEND_STAGING.TRAVEL_DOC,
    -    SPEND_STAGING.TRAVEL_EXPTY,
    -    SPEND_STAGING.TRAVEL_EXP_TYPE_DESC,
    -    SPEND_STAGING.TRAVLE_CREDIT_CARD_TRAN_DESC TRAVEL_CREDIT_CARD_TRAN_DESC,
    -    SPEND_STAGING.COUNTRY_CODE,
    -    SPEND_STAGING.TRAVEL_INFO,
    -    SPEND_STAGING.TRAVEL_ID,
    -    SPEND_STAGING.TRAVEL_DOCUMENT_NUMBER,
    -    SPEND_STAGING.TRAVEL_LAST_NAME_FIRST_NAME,
    -    SPEND_STAGING.TRAVEL_TRIP_REASON,
    -    SPEND_STAGING.TRAVEL_TRIP_STATUS,
    -    SPEND_STAGING.TRAVEL_RATE,
    -    SPEND_STAGING.FINANCE_ORG,
    -    SPEND_STAGING.ASSOCIATED_MG_CODE,
    -   SPEND_STAGING.COUNTRY_DESC,
    -   SPEND_STAGING.TRAVEL_ID_DESC_BANKCARD,
    -    SPEND_STAGING.COMPANY_CODE_DESC,
    -    SPEND_STAGING.COST_CENTER_DESC,
    -    'Q'||TO_CHAR(SPEND_STAGING.TRANSACTION_DATE,'Q') QUARTERNAME,
    -    TO_CHAR(SPEND_STAGING.TRANSACTION_DATE,'YYYY') YEARNAME,
    -200 CASE
    -      WHEN SPEND_STAGING.SRC_SYS_CD = 'P-CARD'
    -      THEN SS2.CLEANSED_PARENT_NAME
    -      ELSE SS1.CLEANSED_PARENT_NAME
    -    END CLEANSED_PARENT_NAME,
    -    CASE
    -      WHEN SPEND_STAGING.SRC_SYS_CD = 'P-CARD'
    -      THEN SS2.cleansed_name_1
    -      ELSE SS1.cleansed_name_1
    -    END CLEANSED_NAME1,
    -    CASE
    -      WHEN SPEND_STAGING.MTRL_ID_1280 IS NULL
    -       AND SPEND_STAGING.VNDR_MTRL_NUM IS NOT NULL
    -      THEN SPEND_STAGING.VNDR_MTRL_NUM
    -      WHEN SPEND_STAGING.MTRL_ID_1280 IS NULL
    -       AND SPEND_STAGING.VNDR_MTRL_NUM IS NULL
    -       AND SPEND_STAGING.MFG_PART_NUM  IS NOT NULL
    -      THEN SPEND_STAGING.MFG_PART_NUM
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -       AND SPEND_STAGING.PO_TYPE_CD         = 'ZAR'
    -       AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280||'-MIX'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -       AND SPEND_STAGING.PO_TYPE_CD          = 'ZAR'
    -       AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-MIX'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZSA'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ASMBLY'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZSA'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ASMBLY'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZST'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-TEST'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZST'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-TEST'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZBI'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -250   THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-BURN-IN'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZBI'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-BURN-IN'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZRJ'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-REJECT'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZRJ'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-REJECT'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZPR'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-PROBE'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZPR'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-PROBE'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEM'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEM'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEU'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -300   THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENGWFR'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEU'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENGWFR'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZSF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-WFR'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZSF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-WFR'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.PO_TYPE_CD          = 'ZEF'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-ENG'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EFM'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-POTypeCode'
    -      WHEN SPEND_STAGING.MTRL_GRP_LVL_4_TXT = 'EWM'
    -      AND SPEND_STAGING.MTRL_ID_1280       IS NOT NULL
    -      THEN SPEND_STAGING.MTRL_ID_1280
    -        ||'-POTypeCode'
    -      ELSE SPEND_STAGING.MTRL_ID_1280
    -    END ReportingPartNum,
    -    LU_PCARD_STAGING.COST_CENTR_CD PCARD_COST_CENTR_CD,
    -    LU_PCARD_STAGING.CTY_NAM PCARD_CTY_NAM,
    -    LU_PCARD_STAGING.DISABLE_LINE PCARD_DISABLE_LINE,
    -    LU_PCARD_STAGING.DISABLED_OWNED_BIZ_FLG PCARD_DISABLED_OWNED_BIZ_FLG,
    -    LU_PCARD_STAGING.DIVERSITY_VNDR_FLG PCARD_DIVERSITY_VNDR_FLG,
    -    LU_PCARD_STAGING.FIELD PCARD_FIELD,
    -    LU_PCARD_STAGING.GL_ACCT_NUM PCARD_GL_ACCT_NUM,
    -    LU_PCARD_STAGING.HUB_ZONE_SMALL_BIZ_CONCERN_FLG PCARD_HUB_ZONE,
    -    LU_PCARD_STAGING.MINORITY_OWNED_BIZ_FLG PCARD_MINORITY_OWNED_BIZ_FLG,
    -    NVL(validate_number(Po_Ln_Itm_Net_Prc_Usd_Amt,'')/DECODE(validate_number(Po_Ln_Itm_Net_Prc_Unit_Qty,''),0,1,validate_number(Po_Ln_Itm_Net_Prc_Unit_Qty,'')),0) po_unit_price_per_1_usd,
    -    NVL(validate_number(Po_Ln_Itm_Net_Prc_Dc_Amt,'') /DECODE(validate_number(Po_Ln_Itm_Net_Prc_Unit_Qty,''),0,1,validate_number(Po_Ln_Itm_Net_Prc_Unit_Qty,'')),0) po_unit_price_per_1_doc_cur,
    -    NVL(validate_number(Spend_Bdgt_Usd_Amt,'')       /DECODE(validate_number(Spend_Qty,''),0,1,                 validate_number(Spend_Qty,'')),0)                  spend_up_per_1_usd_budgt_rate,
    -    NVL(validate_number(Spend_Usd_Amt,'')            /DECODE(validate_number(Spend_Qty,''),0,1,                 validate_number(Spend_Qty,'')),0)                  spend_up_per_1_usd_mon_rate,
    -350 NVL(validate_number(Spend_Doc_Curncy_Amt,'')     /DECODE(validate_number(Spend_Qty,''),0,1,                 validate_number(Spend_Qty,'')),0)                  Spend_UP_per_1_Doc_Curr,
    -    TO_CHAR(TRANSACTION_DATE,'MM-YYYY') MONTH_YEAR,
    -    LU_PCARD_STAGING.MTRL_GRP_CD PCARD_MTRL_GRP_CD,
    -    LU_PCARD_STAGING.PAYMENTNET_TRANSTN_LN_ITM_NUM PCARD_PAY_TRANSTN_LN_ITM_NUM,
    -    LU_PCARD_STAGING.PAYMENTNET_TRANSTN_NUM PCARD_PAY_TRANSTN_NUM,
    -    LU_PCARD_STAGING.PAYMENTNET_TRANSTN_POST_DT PCARD_PAY_TRANSTN_POST_DT,
    -    LU_PCARD_STAGING.PCARD_INV_AMT PCARD_INV_AMT,
    -    LU_PCARD_STAGING.PCARD_INV_CURNCY_CD PCARD_INV_CURNCY_CD,
    -    LU_PCARD_STAGING.PCARD_INV_DT PCARD_INV_DT,
    -    LU_PCARD_STAGING.PCARD_INV_LN_ITM_AMT PCARD_INV_LN_ITM_AMT,
    -    LU_PCARD_STAGING.PCARD_INV_LN_ITM_TAX_AMT PCARD_INV_LN_ITM_TAX_AMT,
    -    LU_PCARD_STAGING.PCARD_INV_LN_ITM_TAX_CD PCARD_INV_LN_ITM_TAX_CD,
    -    LU_PCARD_STAGING.PCARD_INV_REF_NUM PCARD_INV_REF_NUM,
    -    LU_PCARD_STAGING.PCARD_INV_TAX_AMT PCARD_INV_TAX_AMT,
    -    LU_PCARD_STAGING.PCARD_MERCHANT_NAM PCARD_MERCHANT_NAM,
    -    LU_PCARD_STAGING.PCARD_OWNR_ID PCARD_OWNR_ID,
    -    LU_PCARD_STAGING.PCARD_SHORT_TXT PCARD_SHORT_TXT,
    -    LU_PCARD_STAGING.PCARD_SRC_FILE_NAM PCARD_SRC_FILE_NAM,
    -    LU_PCARD_STAGING.PLANT_CD PCARD_PLANT_CD,
    -    LU_PCARD_STAGING.PURCH_GRP_CD PCARD_PURCH_GRP_CD,
    -    LU_PCARD_STAGING.RCPNT_ID PCARD_RCPNT_ID,
    -    LU_PCARD_STAGING.REQTN_CRTE_BY_ID PCARD_REQTN_CRTE_BY_ID,
    -    LU_PCARD_STAGING.REQTN_LN_ITM_NUM PCARD_REQTN_LN_ITM_NUM,
    -    LU_PCARD_STAGING.REQTN_NUM PCARD_REQTN_NUM,
    -    LU_PCARD_STAGING.SERV_DISABLE_VETERAN_BIZ_FLG PCARD_SERV_DIS_VET_BIZ_FLG,
    -    LU_PCARD_STAGING.STATE_CD PCARD_STATE_CD,
    -    LU_PCARD_STAGING.STATE_CD,
    -    LU_PCARD_STAGING.VETERAN_OWNED_BIZ_FLG PCARD_VETERAN_OWNED_BIZ_FLG,
    -    LU_PCARD_STAGING.VNDR_ACCT_NUM PCARD_VNDR_ACCT_NUM,
    -    LU_PCARD_STAGING.WOMAN_OWNED_BIZ_FLG PCARD_WOMAN_OWNED_BIZ_FLG2,
    -    DENSE_RANK() OVER (ORDER BY NVL(TO_CHAR(TRANSACTION_DATE, 'YYYYMM'),'190010') DESC) AS DATE_RANK,
    -    LU_PRICE_BY_UNIT_STAGING.MTRL_GRP PBU_MTRL_GRP,
    -    LU_PRICE_BY_UNIT_STAGING.MTRL_GRP_DES PBU_MTRL_GRP_DES,
    -    LU_PRICE_BY_UNIT_STAGING.MTRL_ID PBU_MTRL_ID,
    -    LU_PRICE_BY_UNIT_STAGING.PLANT PBU_PLANT,
    -    LU_PRICE_BY_UNIT_STAGING.PLANT_DESC PBU_PLANT_DESC,
    -    LU_PRICE_BY_UNIT_STAGING.SUPPLIER PBU_SUPPLIER,
    -    LU_PRICE_BY_UNIT_STAGING.DESCRIPTION PBU_DESCRIPTION,
    -    LU_PRICE_BY_UNIT_STAGING.UOM PBU_UOM,
    -    LU_PRICE_BY_UNIT_STAGING.CONTENT_VOLUME PBU_CONTENT_VOLUME,
    -    LU_PRICE_BY_UNIT_STAGING.UOM_CONTENT_VOLUME PBU_UOM_CONTENT_VOLUME,
    -    LU_PRICE_BY_UNIT_STAGING.CONTENT_WEIGHT PBU_CONTENT_WEIGHT,
    -    LU_PRICE_BY_UNIT_STAGING.UOM_CONTENT_WT PBU_UOM_CONTENT_WT,
    -    LU_PRICE_BY_UNIT_STAGING.PRICE__PACKAGE PBU_PRICE__PACKAGE,
    -    LU_PRICE_BY_UNIT_STAGING.PRICE_PER_UOM_WT PBU_PRICE_PER_UOM_WT,
    -    LU_PRICE_BY_UNIT_STAGING.PRICE_PER_UOM_VOL PBU_PRICE_PER_UOM_VOL,
    -    LU_PRICE_BY_UNIT_STAGING.COMMON_NAME PBU_COMMON_NAME,
    -    LU_GAC_UOM_REFERENCE_STAGING.LU_GAC_UOM_REFERENCE_ID,
    -    LU_GAC_UOM_REFERENCE_STAGING.FSL_PART_NUMBER,
    -    LU_GAC_UOM_REFERENCE_STAGING.SUPPLIER LU_GAC_SUPPLIER,
    -400 LU_GAC_UOM_REFERENCE_STAGING.DESCRIPTION LU_GAC_DESCRIPTION,
    -    LU_GAC_UOM_REFERENCE_STAGING.GAC_MAT_SUBGROUP LU_GAC_MAT_SUBGROUP ,
    -    LU_GAC_UOM_REFERENCE_STAGING.ACTUAL_FILL LU_GAC_ACTUAL_FILL,
    -    LU_GAC_UOM_REFERENCE_STAGING.COMMON__UOM LU_GAC_COMMON_UOM,
    -    LU_GAC_UOM_REFERENCE_STAGING.PACKAGE LU_GAC_PACKAGE
    -  FROM
    -    SPEND_STAGING,
    -    SUPPLIER_STAGING SS1,
    -    SUPPLIER_STAGING SS2,
    -    LU_GAC_STAGING,
    -    lu_card_code_staging,
    -    LU_PCARD_STAGING,
    -    LU_PRICE_BY_UNIT_STAGING,
    -    LU_GAC_UOM_REFERENCE_STAGING
    -  WHERE SS1.SUPPLIER_ID(+)                     = SPEND_STAGING.SUPPLIER_ID
    -  AND SS2.PCARD_INV_REF_NUM(+)             = SPEND_STAGING.PCARD_INV_REF_NUM
    -  AND SS2.PAYMENTNET_TRANSTN_NUM(+)        = SPEND_STAGING.PAYMENTNET_TRANSTN_NUM
    -  AND SS2.PAYMENTNET_TRANSTN_LN_ITM_NUM(+) =
    -    SPEND_STAGING.PAYMENTNET_TRANSTN_LN_ITM_NUM
    -  AND lu_card_code_staging.card_code(+)          = spend_staging.travel_id
    -  AND lu_gac_staging.po_short_txt(+)             = spend_staging.po_short_txt
    -  AND LU_PCARD_STAGING.PCARD_INV_REF_NUM(+)      = SPEND_STAGING.PCARD_INV_REF_NUM
    -  AND LU_PCARD_STAGING.PAYMENTNET_TRANSTN_NUM(+) =
    -    SPEND_STAGING.PAYMENTNET_TRANSTN_NUM
    -  AND LU_PCARD_STAGING.PAYMENTNET_TRANSTN_LN_ITM_NUM(+) =
    -    SPEND_STAGING.PAYMENTNET_TRANSTN_LN_ITM_NUM
    -  AND LU_PRICE_BY_UNIT_STAGING.MTRL_ID(+)             = SPEND_STAGING.MTRL_ID_1280
    -  AND LU_PRICE_BY_UNIT_STAGING.PLANT(+)               = SPEND_STAGING.PLANT_CD
    -  AND lu_gac_uom_REFERENCE_STAGING.fsl_part_number(+) =
    -431 SPEND_STAGING.MTRL_ID_1280;Error at Command Line:350 Column:112
    Error report:
    SQL Error: ORA-01031: insufficient privileges
    01031. 00000 - "insufficient privileges"
    *Cause:    An attempt was made to change the current username or password
    without the appropriate privilege. This error also occurs if
    attempting to install a database without the necessary operating
    system privileges.
    When Trusted Oracle is configure in DBMS MAC, this error may occur
    if the user was granted the necessary privilege at a higher label
    than the current login.
    *Action:   Ask the database administrator to perform the operation or grant
    the required privileges.
    For Trusted Oracle users getting this error although granted the
    the appropriate privilege at a higher label, ask the database
    administrator to regrant the privilege at the appropriate label.
    Edited by: Snyds on May 24, 2012 7:46 AM

    Checking for privileges was the first thing I did.
    User has create view and create any view.
    Also has alter session privilege which is needed within the validate_number function (see below).
    I was able to create the view you suggested.
    I believe there is a privilege problem, just cant figure which.
    create or replace function validate_number(p_number      in varchar2,
                                               p_format_mask in varchar2)
    return number
    AUTHID CURRENT_USER is
      v_number number;
      v_mask   varchar2(100) := '999999999999999999999.00000000000000000000';
      cursor get_number_masks is
      select mask,upper(is_i18n) is_i18n from cm_master.format_mask
      where type = 'NUMBER' order by sequence, is_i18n; 
    begin
      if p_format_mask is not null then
        begin
          return to_number(p_number, p_format_mask);   
        exception
          when others then null;
        end;
      end if;
      for a in get_number_masks
      loop
        if a.is_i18n = 'Y' then
          -- We are applying an international number format mask
          begin
            -- Attempt #1
            -- Set the decimal to a ',' and the group separator to a '.'
            execute immediate 'alter session set nls_numeric_characters = '',.''';
            v_number := to_number(ltrim(rtrim(to_char(to_number(p_number, a.mask),v_mask))),v_mask);
            execute immediate 'alter session set nls_numeric_characters = ''.,''';
            return v_number;
          exception
            when others then
              -- First Attempt Failed - Attempt #2
              -- Set the decimal to a ',' and the group separator to a ' '
              begin
                execute immediate 'alter session set nls_numeric_characters = '', ''';
                v_number := to_number(ltrim(rtrim(to_char(to_number(p_number, a.mask),v_mask))),v_mask);
                execute immediate 'alter session set nls_numeric_characters = ''.,''';
                return v_number;
              exception
                when others then
                  -- Second Attempt Failed - Attempt #3
                  -- Set the decimal to a '.' and the group separator to a ' '
                  begin
                    execute immediate 'alter session set nls_numeric_characters = ''. ''';
                    v_number := to_number(ltrim(rtrim(to_char(to_number(p_number, a.mask),v_mask))),v_mask);
                    execute immediate 'alter session set nls_numeric_characters = ''.,''';
                    return v_number;
                  exception
                    when others then null;
                  end;
              end;
          end;
        else
          begin
            return to_number(p_number, a.mask);
          exception
            when others then null;
          end;
        end if;
      end loop;
      return null;
    exception
      when others then return null;
    end validate_number;Edited by: Snyds on May 24, 2012 7:48 AM

Maybe you are looking for

  • Get CPU Serial No. in a java class,Plz Help !

    I need a class for retrieving cpu serial No. Any resource , any guide ? Thanks.

  • Nokia 5800

    Hi! Im having problem with my Nokia 5800. I want it to ask me everytime its trying to connect to the internet. I want it to ask me if I want to connect with wlan or with 3G. I have searched the menus but without success

  • Syntax error in For Loop statement

    Hello Normally my FOR staements have not been a problem as only access one table. I the example below I am accessing three table and therefore I get a Syntax error. I only wish to select the "Product" recored but need the other table to enable the se

  • Erratic behaviour of the keyboard of a Satellite R830

    I cannot use my portatil for writting because the keyboard has an erratic behavior. When you are wrinting it jumps to different positions in the line. Probably it can be solved installing drivers again, but I not an expert, so someone can help about

  • Oracle Forms 9i / Windows 95

    Hi, I'm running an Oracle Forms 9i application via a web browser on a windows 95 machine. The Jinitiator version I'm using is 1.3.1.9. Throughout the day, I experience frequent PC freeze ups for no apparent reason, sometimes when I first log in to th