Create view syntax

create view [dbo].[Dim]
AS SELECT case
when [EnglishProductCategoryName] in ( 'Bikes','Components')
then 1 --project
when [EnglishProductCategoryName] not in ( 'Bikes','Components')
then 2 ---Non project
end as mike_key,
SELECT CASE
when [EnglishProductCategoryName] in ( 'Bikes','Components')
then project
when [EnglishProductCategoryName] not in ( 'Bikes','Components')
then Non project
end as mike_NAME
FROM [dbo].[DimProductCategory]
GO
PLEASE WHAT AM I TYPING WORNGLE.i WANT TO HAVWE 1 AND 2 SHOW UP ON THE MIKE_KEY, THEN PROJECT AND NON PROJECT ON MIKE_NAME.
Thanks.

Try
create view [dbo].[Dim]
AS SELECT case
when [EnglishProductCategoryName] in ( 'Bikes','Components')
then 1 --project
when [EnglishProductCategoryName] not in ( 'Bikes','Components')
then 2 ---Non project
end as mike_key,
CASE
when [EnglishProductCategoryName] in ( 'Bikes','Components')
then project
when [EnglishProductCategoryName] not in ( 'Bikes','Components')
then Non project
end as mike_NAME
FROM [dbo].[DimProductCategory]
GO
Many Thanks & Best Regards, Hua Min

Similar Messages

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

  • 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

  • Create View  with Force and No Force

    Can Anyone Tell me how to create view with force and no force i have very little idea about this

    This is the syntax.
    CREATE [OR REPLACE] FORCE VIEW view
    [(alias[, alias]...)]
    AS subquery
    [WITH CHECK OPTION [CONSTRAINT constraint]]
    [WITH READ ONLY [CONSTRAINT constraint]];You can see interesting threads about this topic here.
    Re: Creating view forcibly
    Creating View forcefully
    Cheers
    Sarma.

  • How to create view in OBIEE

    I have table 'Table 1' with columns Attr1,Attr2,Measure 1,Measure 2.I need to create view in the repository from table with Attr1,Measure1 and new Attribute 3 with values as flag 'Y' in to it.What will be the SQL for the new view.Please provide the exact Syntax for the view.
    Thanks in Advance

    Hi Hsekar,
    The view SQL Syntax is standard ANSI SQL. From what I understand, you have a table named "Table 1" which has four columns, "Attr1", "Attr2", "Measure 1", "Measure 2". You want to create a new measure named "Attribute 3" (I'd recommend not having spaces in your column and table names FYI).
    If that's correct, then try this
    1. In the physical layer, change the object type to view.
    2. Put the following SQL in the box
    Select "Table 1"."Attr 1","Table 1"."Measure 1", 'Y' "Attribute 3"
    From "Table 1"
    3. Define your columns in the object appropriately.
    That should do it for you.
    -Joe

  • Is it possible to create views with parameters ?

    Hi,
    As MS-Access, is it possible to create views with parameters ?
    Ms-Access syntax : parameters [a] text; select * from table where code = [a]
    If yes, can you give samples ?
    Regards
    Pascal

    I suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
    Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
    Look in in Oracle PL/SQL guide for the Stored Proceedure code.

  • Call procedure while creating view in hana.

    Can we call procedure while creating a attribute view like
    CREATE VIEW "PAYROLLDBTEST"."@HourTransactionView"
    "DocEntry",
    "DocNum",
    "EmpID",
    "EmpCode",
    "FullName",
    "TableName",
    "TranName",
    "U_FromDate",
    "U_ToDate",
    "NoOfDays",
    "U_FromTime",
    "U_ToTime",
    "NoOfHours",
    "OvertimeHours",
    "UnpaidDays",
    "Weekends",
    "Holidays",
    "U_Remarks",
    "U_BatchNo",
    "ProjectCode"
    ) AS SELECT
      T0."DocEntry" AS DocEntry,
        T0."DocNum" AS DocNum,
       T0."U_EmpCode" AS EmpID,
    CALL PAYROLLDBTEST.GetEmpCodeFromEmployeeID('EmpID')  ,              (getting syntax error here).
        GetEmployeeFullName("@TRANSACTION_HOURS".U_EmpCode) AS FullName,
          T0."U_TransactionType" AS TranCode,
        GetHourTableName("U_TransactionType") AS TableName,
         GetHourTransactionName("U_TransactionType") AS TranName,
        T0."U_FromDate",
        T0. "U_ToDate",
          DAYS_BETWEEN("U_FromDate", "U_ToDate") + 1 AS NoOfDays,
          T0."U_FromTime" AS U_FromTime,
           T0."U_ToTime" AS U_ToTime,
        IFNULL("U_WorkHours", 0) AS NoOfHours,
         IFNULL("U_OvertimeHours", 0) AS OvertimeHours,
        IFNULL("U_PaidDays", 0) AS PaidDays,
         IFNULL("U_UnpaidDays", 0) AS UnpaidDays,
        IFNULL("U_WeekendsCount", 0) AS Weekends,
         IFNULL("U_HolidaysCount", 0) AS Holidays,
          T0."U_Remarks",
           T0."U_BatchNo",
        T0."U_ProjectCode" AS "ProjectCode"
        FROM
        "@TRANSACTION_HOURS" T0
        INNER JOIN
        "OHEM" T1
        ON
         T1."empID" = T0."U_EmpCode";

    Hello,
    The problem could be a SAPGUI related problem... Whats the current sapgui patch level ? Does it work when you try on another wokstation with the same user ?
    Could you please use SAPGUI 720 and update your patch level to 7 ? Then check the behaviour again.
    Best regards
    Rene

  • Trouble Creating Views

    I'm not sure if this is a SQL Developer issue or a SQL issue, so if I'm in the wrong place, someone please let me know.
    Using SQL Developer 1.5.0.53, I'm trying to create a view. I've written my SQL for the view and I can run it in a SQL worksheet and it works just like I expect. So I go to my "Views" folder, right click and choose "New View" and enter the exact same SQL (without a semicolon at the end) that works in the SQL worksheet into the "SQL Query" window of the "Create View" dialog box. Then when I press the "Test Syntax" button I get the following error message
         The SQL syntax is valid, however the query is invalid or uses functionality that is not supported.
    This error sort of ticks me off, so I go to the SQL Worksheet and do a
         CREATE OR REPLACE FORCE VIEW… bla bla bla
    And it creates my view, and it seems to work just like I expect it to. Does anyone have any ideas why I can manually create this view in a SQL worksheet, but not through the "New View" dialog box?
    Below is the exact SQL I use to create my view
    SELECT
    "HS_FPR_ACCOUNT_T"."PARENT" "PARENT",
    "HS_FPR_ACCOUNT_T"."CHILD" "CHILD",
    "HS_FPR_ACCOUNT_T"."CHILD_ALIAS" "CHILD_ALIAS",
    "HS_FPR_ACCOUNT_T"."CHILD_STORAGE" "CHILD_STORAGE",
    "HS_FPR_ACCOUNT_T"."CHILD_AGG" "CHILD_AGG",
    "HS_FPR_ACCOUNT_T"."VAR_REPORTING" "VAR_REPORTING",
    "HS_FPR_ACCOUNT_T"."TIME_BALANCE" "TIME_BALANCE",
    "HS_ACCOUNT_MEMBER_V"."MEMBERFORMULA" "MEMBERFORMULA",
    level "PARENT_GEN"
    FROM
    "HS_FPR_ACCOUNT_T" "HS_FPR_ACCOUNT_T" left outer join "HS_ACCOUNT_MEMBER_V"
    on "HS_FPR_ACCOUNT_T"."CHILD" = "HS_ACCOUNT_MEMBER_V"."NAME"
    start with PARENT = 'Account'
    connect by prior CHILD= PARENT
    order by level,
    decode(CHILD, 'ZZZZZZ', '0',
    'COP', '1',
    'ZZZZ'),
    CHILD
    and it gives me this error:
    The SQL syntax is valid, however the query is invalid or uses functionality that is not supported.
    Cannot find relation "HS_ACCOUNT_MEMBER_V".
    Any insight anyone might have on this would be appreciated.
    Thanks

    I had this same problem.
    You have a corrupted file somewhere in this directory:
    C:\Documents and Settings\<your_user_name>\Application Data\SQL Developer
    Before you read further, recognize that this may be the default directory where sql developer will put your sql files, so make sure you don't harm those! Plus, you will lose your preferences and database connections, so make sure you know how to set them up again before you continue. Backups of this directory would be wise. :)
    I solved this problem (and a host of others, by the way), by deleting this directory (after backing up my sql files elsewhere) and running sql developer again.
    Of course, I lost all the preference settings, database connections, etc., so I had to type those in again.
    I believe it happened by importing a set of preferences built on another machine, but I haven't had time to go back and prove that.

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

  • How can I control creation of empty tags when using ora:view syntax?

    I'm using XMLQuery and ora:view syntax to create xml resources in the database but I'd like to be able to prevent the creation of empty tags for null values in the table.
    CREATE OR REPLACE PROCEDURE proc_ctsi_build is
    XMLdoc XMLType;
    BEGIN
    DBMS_XDB.deleteResource('/public/CTSI/ctsi_phsall_rpt1.xml',1);
    SELECT XMLQuery(
    '<Progress_Report>
    <Personnel_Roster>
    {for $c in ora:view("CTSI_INVEST_SOURCE_V")
        let $username  := $c/ROW/COMMONS_USERNAME/text(),
    $expertise  := $c/ROW/AREA_OF_EXPERTISE/text()
         return
      <Investigator>
       <Commons_Username>{$username}</Commons_Username>
    <Area_of_Expertise>{$expertise}</Area_of_Expertise>
    </Investigator>}
    </Personnel_Roster>
    </Progress_Report>'
    RETURNING CONTENT) INTO XMLdoc FROM DUAL;
    IF(DBMS_XDB.CREATERESOURCE('/public/CTSI/ctsi_phsall_rpt1.xml', XMLdoc)) THEN
    DBMS_OUTPUT.PUT_LINE('Resource is created');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Cannot create resource');
    END IF;
    COMMIT;
    END;
    In this example how can I prevent getting <Area_of_Expertise/> in my output when AREA_OF_EXPERTISE is null in the table?
    Thanks

    Hi,
    you can use if else conditions.
    {if ($expertise) then
    <Area_of_Expertise>{$expertise}</Area_of_Expertise>
    else ()}
    **not tested**
    Ants
    Message was edited by:
    Ants Hindpere

  • Problem with embeding the same view in dynamically created view container

    Hello Experts,
                  I am getiing a dump when i try to embed the same view inside the dynamically created view container of
    dynamically created tabs of a tabstrip
    The requirement go like this, i have 2 views in which i have have to embed the 2nd view to view1 where i have an empty
    tabstrip without tabs. During runtime i create tabs as well as view containers accordingly and then try to embed view2 in tabs.
    I have put the below mentioned code in HANDLEIN,
      DATA: lref_vcntlr  TYPE REF TO if_wd_view_controller,
            lref_comp    TYPE REF TO if_wd_component_usage,
            lv_embed_pos TYPE string.
      lref_vcntlr = wd_this->wd_get_api( ).
      lv_embed_pos = 'FILE_PERS_EDIT/VC_GENERAL'.
      TRY.
          CALL METHOD lref_vcntlr->do_dynamic_navigation
            EXPORTING
              source_window_name        = 'FILE_PERSISTENCE_WND'          " Window
              source_vusage_name        = 'FILE_PERS_EDIT_USAGE_1'       " Source View usage
              source_plug_name          = 'TO_EDIT_LAYOUT'                       " Outbound plug
              target_view_name          = 'PERS_EDIT_LAYOUT'                  " Second view to be embedded
              target_plug_name          = 'IN'                                                  " Second view inboun plug
              target_embedding_position = lv_embed_pos
            RECEIVING
              component_usage           = lref_comp.
        CATCH cx_wd_runtime_repository .
      ENDTRY.
      wd_this->fire_to_edit_layout_plg( ).
    This works fine for the first time.
    However onaction tab select i change the embeding position( 'FILE_PERS_EDIT/view container name of different tab') of the view2 an try to embed view2 in a different tab.
    At this point i get a dump stating View2 already present in the window 'FILE_PERSISTENCE_WND' of component.
    I think, the view2 embediing has to be removed before i add the view2 in a different tab
    Kindly let me know how to remove view2 embedding from tab1 before i add a view2 to a different tab or is there any other
    means to handle this problem?
    Thanks & Best Regards,
    Srini.

    Hello Srini,
    I found a solution to your problem, because I had a similar task.
    In WDDOINIT I changed the method do_dynamic_navigation to if_wd_navigation_services_new~prepare_dynamic_navigation:
    DATA:
        l_view_controller_api TYPE REF TO if_wd_view_controller.
      l_view_controller_api = wd_this->wd_get_api( ).
      TRY.
          CALL METHOD l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation
            EXPORTING
              source_window_name        = 'WDW_MAIN'
              source_vusage_name        = 'VW_SUB_USAGE_1'
              source_plug_name          = 'TO_VW_CONTENT'
              target_component_name     = 'ZTEST_DYNAMIC'
              target_view_name          = 'VW_CONTENT'
              target_plug_name          = 'DEFAULT'
              target_embedding_position = 'VW_MAIN/VC_TAB.VW_SUB/TAB1_VC'
            RECEIVING
              repository_handle         = wd_this->g_rep_handle.
        CATCH cx_wd_runtime_repository .
      ENDTRY.
      wd_this->fire_to_vw_content_plg( param1 = 'TAB1' ).
    In the action I first deleted the navigation targets, then navigated to the empty-view and last I called my target view:
      DATA:
        lv_position           TYPE string,
        l_view_controller_api TYPE REF TO if_wd_view_controller,
        lr_view_usage         TYPE REF TO if_wd_rr_view_usage,
        lr_view_***_t         TYPE wdrr_vca_objects,
        lr_view_***           LIKE LINE OF lr_view_***_t.
      l_view_controller_api = wd_this->wd_get_api( ).
      lr_view_usage = wd_this->g_view->get_view_usage( ).
      lr_view_usage->delete_all_navigation_targets( plug_name = 'TO_VW_CONTENT' ).
      CLEAR lv_position.
      CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' old_tab '_VC' INTO lv_position.
      TRY.
          l_view_controller_api->if_wd_navigation_services_new~do_dynamic_navigation(
          source_window_name = 'WDW_MAIN'
          source_vusage_name = 'VW_SUB_USAGE_1'
          source_plug_name   = 'TO_EMPTYVIEW'
          target_component_name = 'ZTEST_DYNAMIC'
          target_view_name   = 'EMPTYVIEW'
          target_plug_name   = 'DEFAULT'
          target_embedding_position = lv_position ).
        CATCH cx_wd_runtime_repository.
      ENDTRY.
      CLEAR lv_position.
      CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' tab '_VC' INTO lv_position.
      TRY.
          wd_this->g_rep_handle = l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation(
            source_window_name = 'WDW_MAIN'
            source_vusage_name = 'VW_SUB_USAGE_1'
            source_plug_name   = 'TO_VW_CONTENT'
            target_component_name = 'ZTEST_DYNAMIC'
            target_view_name   = 'VW_CONTENT'
            target_plug_name   = 'DEFAULT'
            target_embedding_position = lv_position ).
        CATCH cx_wd_runtime_repository.
      ENDTRY.
      wd_this->fire_to_vw_content_plg( param1 = tab ).
    Ann.: I my example, I had 3 views: VW_MAIN which embedds VW_SUB. VW_SUB has the tabs in it and VW_SUB embedds VW_CONTENT.
    BR,
    Roland

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

  • In generic extration how to create view

    HI
    In se11 i try to create view using two table vbap and vbak .
    vbak            mandt                          vbap                     mandt
    vbak             vbeln                           vbap                     vbeln        for join condion
    and also i fill view field tab but the view is no cretated. It give error field name MANDT is not unique. please anyoone clar the error.
    By
    Rajan

    Hi Rajan,
    You cannot use one field twice in a View.
    If you need the Field "MANDT" from both the tables, change the description as MANDT_VBAK & MANDT_VDAT in View Field column & select it from the respective tables in "Table column".
    Hope it helps!
    Regards,
    Pavan

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

  • Error while creating view

     Hello,
    I am trying to create view which is based on multiple source tables and I am receiving following error 
    Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.
    Can anyone know how to resolve this.
    Thanks,

    See MS Support for how to solve it:
    Error message when you run a query in SQL Server 2005: "Internal error: An expression services limit has been reached"
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

Maybe you are looking for

  • How to enter Windows 8.1 safe mode in syslinux?

    My old notebook is running very slowly as Windows 8.1 always reads/writes IDE hard disk, so I disable many windows services. And after relogin, I cannot open almost every program even the Task Manager. It has to enter the 'safe mode' to repair Window

  • Create Error log table

    I am supposed to insert the records that are not uploaded to the main table into a error log table and email the users about the error records that was not inserted into the table. How am is supposed to do it ? I have few more questions. What is the

  • How to use bugzilla to report problems with OVM

    Hello, I want to use bugzilla.oracle.com to post some problems with OVM 3.1.1. After registration process (follow the link received in the confirmed email) I try to login, but it seems that it is not possible to login. Normally the login name should

  • I've hit to download a podcast I don't want how do I cancel it?

    I've hit download to a podcast that I don't want how can I cancel it? It is paused but I don't want it, please help

  • Importing into Data modeler 3.3

    Hi, I am importing tables from a Data Dictionary into Data Modeler 3.3 Some tables import with the correct datatypes (i.e. varchar2, number etc) but others import with a datatype of unknown. any ideas? I can update the datatype in Table Properties bu