Create a view

Hi
I want to create a view with the latest start date
Thanks in advance
regards
anna
create table staff
(staff_id number
,person_name varchar2(10)
,dept_id number
,start_date date
insert into staff values (10, 'Alan', 100, '01-Dec-2000');
insert into staff values (10, 'Alan', 200, '10-Jun-2007');
insert into staff values (10, 'Alan', 300, '01-Jul-2010');

Query for view
select * from staff where ROWID
IN
select ROWID FROM
  select ROWID ,row_number()  Over (partition by STAFF_ID,PERSON_NAME order by Start_date desc) r
  from staff
  ) where rn=1
  STAFF_ID PERSON_NAM    DEPT_ID START_DAT
        10 Alan              300 01-JUL-10
        10 Scott             100 01-DEC-10

Similar Messages

  • How to  create i view  in visual composer give details screenshots

    how to  create i view  in visual composer give details screenshots

    Hi,
    Go through these threads
    VisualComposer
    http://help.sap.com/bp_epv170/EP_US/HTML/Executive_Cockpit.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1752b737-0401-0010-0ba3-87c3eda8c6ce
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e019d290-0201-0010-f186-8630a949800a
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30987099-a74c-2a10-70b5-a2751ce79359
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/4a7e40417c6d1de10000000a1550b0/content.htm
    Tarak
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00b9ba6d-1291-2a10-208d-bd27544e7939

  • Error while creating parameterise view

    I m getting below error while creating parameterise view
    CREATE OR REPLACE VIEW rdr_le_info_view (v_run_number , v_isin_cob )
    AS
    SELECT l.strategic_le
    ,cun.ucn cunucn
    ,cun.date
    ,cccs.ucn ucn
    ,cccs.agr_num
    FROM strat_le l
    ,ucn_name cun
    ,customer_setup cccs
    WHERE l.gfa_until_dt = '31-dec-9999'
    AND l.glas_until_dt = '31-dec-9999'
    AND l.int_until_dt = '31-dec-9999'
    AND cccs.run_num = v_run_num
    AND cccs.ucn_lead_office = cun.ucn
    AND cun.OID = l.client_oid;
    AND cccs.run_num = v_run_num
    ERROR at line 13:
    ORA-00904: "V_RUN_NUM": invalid identifier
    Plese help me in above.

    Try
    CREATE OR REPLACE VIEW rdr_le_info_view
    AS
    SELECT l.strategic_le
    ,cun.ucn cunucn
    ,cun.date
    ,cccs.ucn ucn
    ,cccs.agr_num
    FROM strat_le l
    ,ucn_name cun
    ,customer_setup cccs
    ,cccs.run_num run_num
    WHERE l.gfa_until_dt = '31-dec-9999'
    AND l.glas_until_dt = '31-dec-9999'
    AND l.int_until_dt = '31-dec-9999'
    AND cccs.ucn_lead_office = cun.ucn
    AND cun.OID = l.client_oid;Then call it like:
    select *
    from rdr_le_info_view
    where run_num = v_run_num;

  • Error: while creating a view - Help needed

    When i am trying to create the view i am getting the error msg as:
    ==>ORA-02070: database does not support operator NLS_CHARSET_DECL_LEN in this context<==
    Please advise in this regard to overcome this issue.
    the view is nothing but
    ================
    create or replace view f_test as
    WITH metadata1 as
    (SELECT DISTINCT * FROM
    (SELECT fre_id, bu_id, eff_from_dt, rec_eff_from_dt,
    rec_eff_to_dt, rec_type, eff_to_dt,
    active_flg, nm_long, nm_short,
    rplcmnt_bu_id, pc_cc_cd, tax_cd, bu_type_cd,
    ledger_cd, internal_id, create_dt,
    last_upd_dt, last_upd_id,
    DENSE_RANK () OVER (PARTITION BY fre_id, bu_id, eff_from_dt
    ORDER BY fre_id, bu_id, eff_from_dt, rec_eff_from_dt) RANK
    FROM AUD_TEST)
    aud1 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD'
    AND rank = '1')      ,
    aud2 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '2'),
    aud3 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '3'),
    aud4 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '4'),
    aud5 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '5'),
    aud6 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '6'),
    aud7 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '7'),
    aud8 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '8'),
    aud9 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '9'),
    aud10 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '10'),
    metadata2 as
    (select aud1.column_name,
    aud1.col_val_new,
    '' col_val_old,
    aud1.fre_id,
    aud1.bu_id,
    aud1.eff_from_dt,
    aud1.rec_eff_from_dt,
    aud1.rec_type,
    aud1.rank
    from aud1
    union all
    select aud2.column_name, DECODE(aud2.rec_type,'D','',aud2.col_val_new) col_val_new, aud1.col_val_new col_val_old, aud2.fre_id, aud2.bu_id,
    aud2.eff_from_dt, aud2.rec_eff_from_dt, aud2.rec_type, aud2.rank
    from aud1, aud2
    where (aud1.fre_id = aud2.fre_id and aud1.bu_id = aud2.bu_id and aud1.eff_from_dt = aud2.eff_from_dt
    and aud1.column_name = aud2.column_name
    and ( (aud2.rec_type = 'C' and nvl(aud1.col_val_new,'^') <> nvl(aud2.col_val_new,'~') ) or
    (aud2.rec_type <> 'C' or (nvl(aud1.col_val_new,'^') <> nvl(aud2.col_val_new,'~'))))
    union all
    select aud3.column_name, DECODE(aud3.rec_type,'D','',aud3.col_val_new) col_val_new, aud2.col_val_new col_val_old, aud3.fre_id, aud3.bu_id,
    aud3.eff_from_dt, aud3.rec_eff_from_dt, aud3.rec_type, aud3.rank
    from aud2, aud3
    where (aud2.fre_id = aud3.fre_id and aud2.bu_id = aud3.bu_id and aud2.eff_from_dt = aud3.eff_from_dt
    and aud2.column_name = aud3.column_name
    and ( (aud3.rec_type = 'C' and nvl(aud2.col_val_new,'^') <> nvl(aud3.col_val_new,'~') ) or
    (aud3.rec_type <> 'C' or (nvl(aud2.col_val_new,'^') <> nvl(aud3.col_val_new,'~'))))
    union all
    select aud4.column_name, DECODE(aud4.rec_type,'D','',aud4.col_val_new) col_val_new, aud3.col_val_new col_val_old, aud4.fre_id, aud4.bu_id,
    aud4.eff_from_dt, aud4.rec_eff_from_dt, aud4.rec_type, aud4.rank
    from aud3, aud4
    where (aud3.fre_id = aud4.fre_id and aud3.bu_id = aud4.bu_id and aud3.eff_from_dt = aud4.eff_from_dt
    and aud3.column_name = aud4.column_name
    and ( (aud4.rec_type = 'C' and nvl(aud3.col_val_new,'^') <> nvl(aud4.col_val_new,'~') ) or
    (aud4.rec_type <> 'C' or (nvl(aud3.col_val_new,'^') <> nvl(aud4.col_val_new,'~'))))
    union all
    select aud5.column_name, DECODE(aud5.rec_type,'D','',aud5.col_val_new) col_val_new, aud4.col_val_new col_val_old, aud5.fre_id, aud5.bu_id,
    aud5.eff_from_dt, aud5.rec_eff_from_dt, aud5.rec_type, aud5.rank
    from aud4, aud5
    where (aud4.fre_id = aud5.fre_id and aud4.bu_id = aud5.bu_id and aud4.eff_from_dt = aud5.eff_from_dt
    and aud4.column_name = aud5.column_name
    and ( (aud5.rec_type = 'C' and nvl(aud4.col_val_new,'^') <> nvl(aud5.col_val_new,'~') ) or
    (aud5.rec_type <> 'C' or (nvl(aud4.col_val_new,'^') <> nvl(aud5.col_val_new,'~'))))
    union all
    select aud6.column_name, DECODE(aud6.rec_type,'D','',aud6.col_val_new) col_val_new, aud5.col_val_new col_val_old, aud6.fre_id, aud6.bu_id,
    aud6.eff_from_dt, aud6.rec_eff_from_dt, aud6.rec_type, aud6.rank
    from aud5, aud6
    where (aud5.fre_id = aud6.fre_id and aud5.bu_id = aud6.bu_id and aud5.eff_from_dt = aud6.eff_from_dt
    and aud5.column_name = aud6.column_name
    and ( (aud6.rec_type = 'C' and nvl(aud5.col_val_new,'^') <> nvl(aud6.col_val_new,'~') ) or
    (aud6.rec_type <> 'C' or (nvl(aud5.col_val_new,'^') <> nvl(aud6.col_val_new,'~'))))
    union all
    select aud7.column_name, DECODE(aud7.rec_type,'D','',aud7.col_val_new) col_val_new, aud6.col_val_new col_val_old, aud7.fre_id, aud7.bu_id,
    aud7.eff_from_dt, aud7.rec_eff_from_dt, aud7.rec_type, aud7.rank
    from aud6, aud7
    where (aud6.fre_id = aud7.fre_id and aud6.bu_id = aud7.bu_id and aud6.eff_from_dt = aud7.eff_from_dt
    and aud6.column_name = aud7.column_name
    and ( (aud7.rec_type = 'C' and nvl(aud6.col_val_new,'^') <> nvl(aud7.col_val_new,'~') ) or
    (aud7.rec_type <> 'C' or (nvl(aud6.col_val_new,'^') <> nvl(aud7.col_val_new,'~'))))
    union all
    select aud8.column_name, DECODE(aud8.rec_type,'D','',aud8.col_val_new) col_val_new, aud7.col_val_new col_val_old, aud8.fre_id, aud8.bu_id,
    aud8.eff_from_dt, aud8.rec_eff_from_dt, aud8.rec_type, aud8.rank
    from aud7, aud8
    where (aud7.fre_id = aud8.fre_id and aud7.bu_id = aud8.bu_id and aud7.eff_from_dt = aud8.eff_from_dt
    and aud7.column_name = aud8.column_name
    and ( (aud8.rec_type = 'C' and nvl(aud7.col_val_new,'^') <> nvl(aud8.col_val_new,'~') ) or
    (aud8.rec_type <>'C' or (nvl(aud7.col_val_new,'^') <> nvl(aud8.col_val_new,'~'))))
    union all
    select aud9.column_name, DECODE(aud9.rec_type,'D','',aud9.col_val_new) col_val_new, aud8.col_val_new col_val_old, aud9.fre_id, aud9.bu_id,
    aud9.eff_from_dt, aud9.rec_eff_from_dt, aud9.rec_type, aud9.rank
    from aud8, aud9
    where (aud8.fre_id = aud9.fre_id and aud8.bu_id = aud9.bu_id and aud8.eff_from_dt = aud9.eff_from_dt
    and aud8.column_name = aud9.column_name
    and ( (aud9.rec_type = 'C' and nvl(aud8.col_val_new,'^') <> nvl(aud9.col_val_new,'~') ) or
    (aud9.rec_type <> 'C' or (nvl(aud8.col_val_new,'^') <> nvl(aud9.col_val_new,'~'))))
    union all
    select aud10.column_name, DECODE(aud10.rec_type,'D','',aud10.col_val_new) col_val_new, aud9.col_val_new col_val_old, aud10.fre_id, aud10.bu_id,
    aud10.eff_from_dt, aud10.rec_eff_from_dt, aud10.rec_type, aud10.rank
    from aud9, aud10
    where (aud9.fre_id = aud10.fre_id and aud9.bu_id = aud10.bu_id and aud9.eff_from_dt = aud10.eff_from_dt
    and aud9.column_name = aud10.column_name
    and ((aud10.rec_type = 'C' and nvl(aud9.col_val_new,'^') <> nvl(aud10.col_val_new,'~') )
    or (aud10.rec_type <> 'C' or (nvl(aud9.col_val_new,'^') <> nvl(aud10.col_val_new,'~'))))
    select * from metadata2
    where (rec_type = 'C' and (col_val_new is not null or col_val_old is not null))
    or (rec_type <> 'C');

    create or replace view frd_bu_test as
    WITH metadata1 as
    (SELECT DISTINCT * FROM
    (SELECT fre_id, bu_id, eff_from_dt, rec_eff_from_dt,
    rec_eff_to_dt, rec_type, eff_to_dt,
    active_flg, nm_long, nm_short,
    rplcmnt_bu_id, pc_cc_cd, tax_cd, bu_type_cd,
    ledger_cd, internal_id, create_dt,
    last_upd_dt, last_upd_id,
    DENSE_RANK () OVER (PARTITION BY fre_id, bu_id, eff_from_dt
    ORDER BY fre_id, bu_id, eff_from_dt, rec_eff_from_dt) RANK
    FROM AUD_TEST)
    aud1 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD'
    AND rank = '1')      ,
    aud2 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '2'),
    aud3 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '3'),
    aud4 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '4'),
    aud5 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '5'),
    aud6 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '6'),
    aud7 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '7'),
    aud8 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '8'),
    aud9 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '9'),
    aud10 AS
    (SELECT column_name,
    DECODE (column_id,
    7, TO_CHAR (eff_to_dt, 'MMDDRRRR'),
    8, active_flg,
    9, nm_long,
    10, nm_short,
    11, rplcmnt_bu_id,
    12, pc_cc_cd,
    13, tax_cd,
    14, bu_type_cd,
    15, ledger_cd) col_val_new,
    '' col_val_old, fre_id, bu_id, eff_from_dt, rec_eff_from_dt, rec_type, rank
    FROM metadata1 m, all_tab_columns u
    WHERE table_name = 'AUD_TEST'
    AND column_name IN
    ('EFF_TO_DT',
    'ACTIVE_FLG',
    'NM_LONG',
    'NM_SHORT',
    'RPLCMNT_BU_ID',
    'PC_CC_CD',
    'TAX_CD',
    'BU_TYPE_CD',
    'LEDGER_CD')
    AND rank = '10'),
    metadata2 as
    (select aud1.column_name,
    aud1.col_val_new,
    '' col_val_old,
    aud1.fre_id,
    aud1.bu_id,
    aud1.eff_from_dt,
    aud1.rec_eff_from_dt,
    aud1.rec_type,
    aud1.rank
    from aud1
    union all
    select aud2.column_name, DECODE(aud2.rec_type,'D','',aud2.col_val_new) col_val_new, aud1.col_val_new col_val_old, aud2.fre_id, aud2.bu_id,
    aud2.eff_from_dt, aud2.rec_eff_from_dt, aud2.rec_type, aud2.rank
    from aud1, aud2
    where (aud1.fre_id = aud2.fre_id and aud1.bu_id = aud2.bu_id and aud1.eff_from_dt = aud2.eff_from_dt
    and aud1.column_name = aud2.column_name
    and ( (aud2.rec_type = 'C' and nvl(aud1.col_val_new,'^') <> nvl(aud2.col_val_new,'~') ) or
    (aud2.rec_type <> 'C' or (nvl(aud1.col_val_new,'^') <> nvl(aud2.col_val_new,'~'))))
    union all
    select aud3.column_name, DECODE(aud3.rec_type,'D','',aud3.col_val_new) col_val_new, aud2.col_val_new col_val_old, aud3.fre_id, aud3.bu_id,
    aud3.eff_from_dt, aud3.rec_eff_from_dt, aud3.rec_type, aud3.rank
    from aud2, aud3
    where (aud2.fre_id = aud3.fre_id and aud2.bu_id = aud3.bu_id and aud2.eff_from_dt = aud3.eff_from_dt
    and aud2.column_name = aud3.column_name
    and ( (aud3.rec_type = 'C' and nvl(aud2.col_val_new,'^') <> nvl(aud3.col_val_new,'~') ) or
    (aud3.rec_type <> 'C' or (nvl(aud2.col_val_new,'^') <> nvl(aud3.col_val_new,'~'))))
    union all
    select aud4.column_name, DECODE(aud4.rec_type,'D','',aud4.col_val_new) col_val_new, aud3.col_val_new col_val_old, aud4.fre_id, aud4.bu_id,
    aud4.eff_from_dt, aud4.rec_eff_from_dt, aud4.rec_type, aud4.rank
    from aud3, aud4
    where (aud3.fre_id = aud4.fre_id and aud3.bu_id = aud4.bu_id and aud3.eff_from_dt = aud4.eff_from_dt
    and aud3.column_name = aud4.column_name
    and ( (aud4.rec_type = 'C' and nvl(aud3.col_val_new,'^') <> nvl(aud4.col_val_new,'~') ) or
    (aud4.rec_type <> 'C' or (nvl(aud3.col_val_new,'^') <> nvl(aud4.col_val_new,'~'))))
    union all
    select aud5.column_name, DECODE(aud5.rec_type,'D','',aud5.col_val_new) col_val_new, aud4.col_val_new col_val_old, aud5.fre_id, aud5.bu_id,
    aud5.eff_from_dt, aud5.rec_eff_from_dt, aud5.rec_type, aud5.rank
    from aud4, aud5
    where (aud4.fre_id = aud5.fre_id and aud4.bu_id = aud5.bu_id and aud4.eff_from_dt = aud5.eff_from_dt
    and aud4.column_name = aud5.column_name
    and ( (aud5.rec_type = 'C' and nvl(aud4.col_val_new,'^') <> nvl(aud5.col_val_new,'~') ) or
    (aud5.rec_type <> 'C' or (nvl(aud4.col_val_new,'^') <> nvl(aud5.col_val_new,'~'))))
    union all
    select aud6.column_name, DECODE(aud6.rec_type,'D','',aud6.col_val_new) col_val_new, aud5.col_val_new col_val_old, aud6.fre_id, aud6.bu_id,
    aud6.eff_from_dt, aud6.rec_eff_from_dt, aud6.rec_type, aud6.rank
    from aud5, aud6
    where (aud5.fre_id = aud6.fre_id and aud5.bu_id = aud6.bu_id and aud5.eff_from_dt = aud6.eff_from_dt
    and aud5.column_name = aud6.column_name
    and ( (aud6.rec_type = 'C' and nvl(aud5.col_val_new,'^') <> nvl(aud6.col_val_new,'~') ) or
    (aud6.rec_type <> 'C' or (nvl(aud5.col_val_new,'^') <> nvl(aud6.col_val_new,'~'))))
    union all
    select aud7.column_name, DECODE(aud7.rec_type,'D','',aud7.col_val_new) col_val_new, aud6.col_val_new col_val_old, aud7.fre_id, aud7.bu_id,
    aud7.eff_from_dt, aud7.rec_eff_from_dt, aud7.rec_type, aud7.rank
    from aud6, aud7
    where (aud6.fre_id = aud7.fre_id and aud6.bu_id = aud7.bu_id and aud6.eff_from_dt = aud7.eff_from_dt
    and aud6.column_name = aud7.column_name
    and ( (aud7.rec_type = 'C' and nvl(aud6.col_val_new,'^') <> nvl(aud7.col_val_new,'~') ) or
    (aud7.rec_type <> 'C' or (nvl(aud6.col_val_new,'^') <> nvl(aud7.col_val_new,'~'))))
    union all
    select aud8.column_name, DECODE(aud8.rec_type,'D','',aud8.col_val_new) col_val_new, aud7.col_val_new col_val_old, aud8.fre_id, aud8.bu_id,
    aud8.eff_from_dt, aud8.rec_eff_from_dt, aud8.rec_type, aud8.rank
    from aud7, aud8
    where (aud7.fre_id = aud8.fre_id and aud7.bu_id = aud8.bu_id and aud7.eff_from_dt = aud8.eff_from_dt
    and aud7.column_name = aud8.column_name
    and ( (aud8.rec_type = 'C' and nvl(aud7.col_val_new,'^') <> nvl(aud8.col_val_new,'~') ) or
    (aud8.rec_type <>'C' or (nvl(aud7.col_val_new,'^') <> nvl(aud8.col_val_new,'~'))))
    union all
    select aud9.column_name, DECODE(aud9.rec_type,'D','',aud9.col_val_new) col_val_new, aud8.col_val_new col_val_old, aud9.fre_id, aud9.bu_id,
    aud9.eff_from_dt, aud9.rec_eff_from_dt, aud9.rec_type, aud9.rank
    from aud8, aud9
    where (aud8.fre_id = aud9.fre_id and aud8.bu_id = aud9.bu_id and aud8.eff_from_dt = aud9.eff_from_dt
    and aud8.column_name = aud9.column_name
    and ( (aud9.rec_type = 'C' and nvl(aud8.col_val_new,'^') <> nvl(aud9.col_val_new,'~') ) or
    (aud9.rec_type <> 'C' or (nvl(aud8.col_val_new,'^') <> nvl(aud9.col_val_new,'~'))))
    union all
    select aud10.column_name, DECODE(aud10.rec_type,'D','',aud10.col_val_new) col_val_new, aud9.col_val_new col_val_old, aud10.fre_id, aud10.bu_id,
    aud10.eff_from_dt, aud10.rec_eff_from_dt, aud10.rec_type, aud10.rank
    from aud9, aud10
    where (aud9.fre_id = aud10.fre_id and aud9.bu_id = aud10.bu_id and aud9.eff_from_dt = aud10.eff_from_dt
    and aud9.column_name = aud10.column_name
    and ((aud10.rec_type = 'C' and nvl(aud9.col_val_new,'^') <> nvl(aud10.col_val_new,'~') )
    or (aud10.rec_type <> 'C' or (nvl(aud9.col_val_new,'^') <> nvl(aud10.col_val_new,'~'))))
    select * from metadata2
    where (rec_type = 'C' and (col_val_new is not null or col_val_old is not null))
    or (rec_type <> 'C');

  • Error while creating a View Cluster

    Hello Gurus,
         I have created two maintenance views ZVIEW1 & ZVIEW2  with table maintenance generator.Know I am trying
         to create a view cluster using these views.
         I have Proceeded with the following steps to create the View Cluster:
         1. Tcode : SE54 --> GIven the name ZVIEWCLUSTER as View Cluster name & pressed ENTER.
         2. Filled the description of the View cluster.
         3.Selected the tab OBJECT STRUCTURE  and filled it with ZVIEW1 & ZVIEW2.
         4.Selected view ZVIEW1 and clicked on button "FIELD-DEPENDENCE" ,System throws a message
             "Field-dependence generated succesfully"
         5. Selected view ZVIEW2 and clicked on button "FIELD-DEPENDENCE" ,System throws an error message
             "No log generated".
          Am stuck up at point 5 in the above mentioned steps.
          Please guide me in coming out of this error message.
    Regards,
    Najam

    Hi Najam,
    I don't think you need to define field dependencies for both tables, you only define the relationship from the second table to the first.
    Double-click on the Field dependencies folder and check the link between the two tables is correctly defined, if so you don't need to generate the field dependency twice.
    Regards,
    Nick

  • How to create a view consisting of data from tables in2 different databases

    Using Oracle 10.2g
    I have 2 databases Gus and haggis on Comqdhb schema.
    glink indicates a databse link between Haggis and Gus
    In Gus there are tables student,subject,grade,school containing columns like upn...
    STUDENT
    upn
    academicYear
    SUBJECT
    subject
    GRADE
    examlevel
    grade
    SCHOOL
    sn
    In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
    STUDENT
    upn
    GRADE
    grade
    upn
    academicyear
    level
    Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    so I need to create a view which gets the data from both the tables in both the databases.
    create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
    But i am not getting how to select a column from 2 tables in different databases
    I mean if i said
    select upn from comqdhb.student@glink,comqdhb.student;
    select upn from comqdhb.student@glink,comqdhb.student
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    help me out,Thank you.

    Thank you for the reply will follow up the code format
    Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    I understand that there wont be duplication when we use conditions
    If i query
    select count(upn)
    from   comqdhb.student@glink I get 9000
    but after the union
    create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
    as
    select distinct s.upn as upn
    ,                  g.subject as subject
    ,                  g."LEVEL" as examlevel
    ,                  g.grade as grades
    ,                  '9364097'
    ,                  to_number(g.academicyear) as academicyear
    from             comqdhb.student s
    ,                   comqdhb.grade g
    where           s.upn=g.upn
    union
    select            s.upn
    ,                   sb.subject
    ,                   g.elevel
    ,                   g.grade
    ,                   s.acyr
    ,                   sc.sn
    from              comqdhb.subject@glink sb
    ,                   comqdhb.student@glink s
    ,                    comqdhb.gradevalues@glink g
    ,                    comqdhb.school@glink sc,
    ,                    comqdhb.studentingroup@glink sg
    ,                    comqdhb.teachinggroup@glink tg
    where            sb.sid=tg.sid
    and                tg.gid=sg.gid
    and                sg.upn=s.upn
    and                g."LEVEL"=tg.elevel
    and                s.school=sc.id
    and                sc.id=tg.id; returns
    count(upn) from exam gradeIt gets stuck actually sometimes it returns
    932002 some results.
    2:
    Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
    Information:
    =======
    All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
    They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
    For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
    In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
    Grade Numerical score
    A* 8
    A 7
    B 6
    C 5
    D 4
    E 3
    F 2
    G 1
    U 0
    X 0
    Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
    In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
    add them all up and div by the total no of grades to get the avg.
    desc comqdhb.STUDENT@glink;
    STUDENT
    =======
    UPN
    FNAME
    CNAME
    DOB
    GENDER
    PREVIOUSSCHOOL
    XGCSE
    SCHOOL
    ACYR
    STUDENTINGROUP
    =============
    UPN
    GID
    STARTDATE
    ENDDATE
    GRADE
    GRADEVALUES
    ===========
    GRADE
    LEVEL
    VALUE
    I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
    select *
    from comqdhb.student@glink
    where xgcse<6.5; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
    select *
    from comqdhb.student@glink
    where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
    my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1011;
    Result:
    GRADE
    =====
    D
    F
    B
    E
    C
    E
    E
    B
    8 rows selected. Mapping each grade to the corresponding value and calculating we get
    32/8=4 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386;
    Result:
    GRADE
    ======
    A*
    A*
    A*
    A*
    B
    A*
    A*
    A
    B
    B
    B
    11 rows selected. grade to the corresponding value and calculating we get
    79/11=7.12 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
    But another problem
    when i say
    select   g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ===========
      100 B
      100 B
       80 C
       60 D
       40 E
       40 E
       40 E
       20 F
        6 B
        6 B
        5 C
    VALUE GRADE
    =============
        4 D
        3 E
        3 E
        3 E
        2 F
    16 rows selected.
    select   distinct g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ============
         2 F
       100 B
         6 B
         3 E
        60 D
         5 C
         4 D
        80 C
        40 E
        20 F
    10 rows selected. I am getting only 8 for the query
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
    select distinct *
    from   comqdhb.gradevalues@glink;
    GRADEVALUES
    ===========
    LEVEL      GRADE           VALUE
    ================================
    a          A                 120
    a          B                 100
    a          C                  80
    a          D                  60
    a          E                  40
    a          F                  20
    a          U                   0
    a          X                   0
    g          A                   7
    g          A*                  8
    g          B                   6
    LEVEL      GRADE           VALUE
    ================================
    g          C                   5
    g          D                   4
    g          E                   3
    g          F                   2
    g          G                   1
    g          U                   0
    g          X                   0
    18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
    select  sum(g.value)/count(g.grade) as avggrade
    from    comqdhb.gradevalues@glink g
    ,         comqdhb.studentingroup@glink sg
    where  g.grade=sg.grade
    and     sg.upn=1386;
    avggrade
    ========
    37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
    kindly help.
    Edited by: Trooper on Dec 15, 2008 4:49 AM

  • Creating Materialized View in Toad

    As with every new endeavor - come new questions.
    I am trying to create a materialized view via toad (first time doing this). Now - toad is great, since it provides a kind-of wizard interface. Hence, one doesn't have to completely code in the create statement, with all of the options, etc.
    Instead, in toad, one can (via the schema browser), go into the Materialized Views tab and click on create new. This opens a window with 6 tabs: Basic Info, Refresh Info, Physical Attributes, Query, Partitions & Subpartition Template.
    In the Basic Info, one can put a check mark next to some of the following options:
    -Build Deffered
    -Parallel
    -Cache
    -Logging
    -Using index
    -Allow updates
    etc.
    I have read that build deferred refers to whether or not you would like the view to be created automatically or to be deferred.
    Anyways, I tried to find Toad documentation to explain each of the options in-detail. No success. Hence, am researching each part piece by piece.
    But - here is my question:
    In the Query tab, we are asked to specify a query. I am assuming that the query does not have to be a full query, beginning with CREATE MATERIALIZED VIEW mv_table1 REFRESH FAST etc...
    Since in this 'wizard', we are providing the MV name at the top of the dialog box, we are checking the 'options' in the other tabs, etc.
    And so, I assumed that the query should merely be a select query in the window mentioned above.
    So I entered the following:
    select * from table1@remote_db;
    When I go to verify the syntax, I get the error message: ORA_00911: invalid character. It seems to be pointing to my db_link (remote_db). I have been using this link throughout many places, w/o any problems.
    Has anyone created a MV in toad before? Any links to good toad documentation would be helpful as well.
    Thanks.

    (This is fun... ;))
    For anyone endeavoring this in the future, below I have attached the prerequisites required in order to create a materialized view (can also be found @ http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm):
    Prerequisites
    The privileges required to create a materialized view should be granted directly rather than through a role.
    To create a materialized view in your own schema:
    You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
    You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a materialized view in another user's schema:
    You must have the CREATE ANY MATERIALIZED VIEW system privilege.
    The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.
    To create the materialized view with query rewrite enabled, in addition to the preceding privileges:
    If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
    If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.
    The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.
    When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

  • [ADF Help] How to create a view for multiple tables

    Hi,
    I am using Jdeveloper 11G and ADF framework, and trying to create a view to update multiple tables.
    ex:
    Table A has these fields: ID, Name
    Table B has these fields: ID, Address
    A.ID and B.ID are primary keys.
    B.ID has FK relationship with A.ID
    (basically, these tables have one-to-one relation)
    I want to create a view object, which contains these fields: B.ID (or A.ID), A.Name, B.Address.
    So I can execute C,R,U,D for both tables.
    I create these tables in DB, and create entity objects for these tables.
    So there are 2 entity objects and 1 association.
    Then I create a view object based on B and add fields of A into the view:
    If the association is not a "Composition Association",
    when I run the model ("Oracle Business Component Browser") and try to insert new data, fields of A can't edit.
    If the association is a "Composition Association", and click the insert button, I will get
    "oracle.jbo.InvalidOwnerException: JBO-25030: Failed to find or invalidate owning entity"
    If I create a view object based on A and add filed of B into the view:
    When I run the model and try to insert new data, fields of B can't edit, no matter the association is or is not a composition association.
    So... how can I create a view for multiple tables correctly?
    Thanks for any advices!
    Here are some pictures about my problem, if there is any unclear point, please let me know.
    http://leonjava.blogspot.com/2009_10_01_archive.html
    (A is Prod, B is CpuSocket)
    Edited by: user8093176 on Oct 25, 2009 12:29 AM

    Hi Branislav,
    Thanks, but the result is same ....
    In the step 2 of creating view object, I can select entity objects to be added in to the view.
    If I select A first, and then select B (the "Source Usage" of B is A), then finishing the wizards.
    When I try to create a new record in the view, I can't edit any properties of B (those files are disabled).
    If I select B first, and then select A in crating view object, the result is similar ...
    Thanks for any further suggestion.
    Leon

  • How to create a view for all Service Requests that are not approved by reviewer

    Hallo,
    I want to create a view in the Service Requests library that shows all SRs that are not approved. How to configure condition that says: if a SR has related Review Activity which is In Progress, show that SRs?
    I couldn't find this when creating the view. Thank you.

    So here's the first problem with that: Which review activity? a SR can contain multiple RAs, so how do we decide if an arbitrary SR is approved or not? 
    As to the specific language you use (Any child RA is In Progress) you might want to look at the criteria from the default Change approval view, which does something similar: 
    <QueryCriteria Adapter="omsdk://Adapters/Criteria" xmlns="http://tempuri.org/Criteria.xsd">
    <Criteria>
    <FreeformCriteria>
    <Freeform>
    <Criteria xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">
    <Expression>
    <And>
    <Expression>
    <SimpleExpression>
    <ValueExpressionLeft>
    <Property>$Context/Path[Relationship='CoreActivity!System.WorkItemContainsActivity' TypeConstraint='CoreActivity!System.WorkItem.Activity.ReviewActivity']/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$</Property>
    </ValueExpressionLeft>
    <Operator>Equal</Operator>
    <ValueExpressionRight>
    <Value>$MPElement[Name="CoreActivity!ActivityStatusEnum.Active"]$</Value>
    </ValueExpressionRight>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpressionLeft>
    <Property>$Context/Property[Type='CoreChange!System.WorkItem.ChangeRequest']/Status$</Property>
    </ValueExpressionLeft>
    <Operator>Equal</Operator>
    <ValueExpressionRight>
    <Value>$MPElement[Name="CoreChange!ChangeStatusEnum.InProgress"]$</Value>
    </ValueExpressionRight>
    </SimpleExpression>
    </Expression>
    </And>
    </Expression>
    </Criteria>
    </Freeform>
    </FreeformCriteria>
    </Criteria>
    </QueryCriteria>
    This is a simple AND criteria with two componets. one looking for a Review Activity (TypeConstraint='CoreActivity!System.WorkItem.Activity.ReviewActivity') which is related to the targetting CR by Contains Activity ($Context/Path[Relationship='CoreActivity!System.WorkItemContainsActivity';
    Context in this... context means the CR targeted by the view) where it's status (/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$) is In Progress ($MPElement[Name="CoreActivity!ActivityStatusEnum.Active"]$). The other is filtering
    for the target change request's status ( $Context/Property[Type='CoreChange!System.WorkItem.ChangeRequest']/Status$) is In Progress ($MPElement[Name="CoreChange!ChangeStatusEnum.InProgress"]$). 
    You could convert the second criteria to point to SRs and SR status values, and then use the similar text for the first criteria. i'd recommend
    Anton's Advanced View Editor (or
    the free version) to do the criteria adjustment. 

  • Do I need to create a view for this?

    Hi Ihave got 2 tables emp and project
    In emp tabe:
    emp_no
    family name
    given name
    In porgect table:
    emp_no
    status(assigned,unassigned)
    start_date
    end_date
    emp_no Family_name given_name
    1 Smith John
    In project table same employee can have many assigement eg
    emp_no status start_date end_date
    1 assigned 01-may-08 01-july-08
    1 assigned 01-sep-08 01-july-09
    1 unassigned 01-july-09 01-oct-09
    In the form:
    there are 2 querable fields "project ends between field1(date) and field2(date)" which is used to
    retrive records which have end date between field1 and field2.
    The following fields are needed to get from database:
    emp.family_name emp.given_name project.start_date project.end_date No.of time assigned
    Requirements:
    1. project.start_date and project.end_date must be the latest project_end_date for the same emp
    so in the above sample date
    2. No. of time assigned is a count of total of number records which have status='assign'
    So for the given sample data the record expected after query would be(field1=01-jun-08 field2=02-july-09)
    emp.family_name emp.given_name project.start_date project.end_date No.of time assigned
    Smith John 01-sep-08 01-july-09 2
    What is the best approach to get:
    1 The lastest project(latest end_date) for the emp
    2. get No.of time assigned.
    Do I need to create a view for this? If yes, any sample sql code this this?
    Thanks for your help

    Hi W1zard,
    Thanks for your reply. Could you clarify the following points for me:
    1.) you could create a master block basing on your emp table and a detail block basing on your project table with the relation over emp_no. set the default_where clause of your detail block programmatically using
    set_block_property('project', default_where, 'status = ''assigned'' and <your_date_criteria>');
    Q1: where I pit this code? in pre-query trigger in detail block?
    2.) Of course you could create a view to join both of your tables if you don't want to use master detail blocks; Also do the join over emp_no
    create or replace force view v_emp as
    select emp.family_name, emp.given_name, project.start_date, project.end_date
    from emp, project
    where emp.emp_no = project.emp_no
    Q2 As I mentioned before, there are multipal entries for the same emp in project table and we only need the maching record from project table which has latest end_date. So I think I need something like
    max(project.end_date) somewhere in create view to make sure only one record for one employee.
    Also is there possible to include the no. of assigned field(select count(*) from project where status='assigned' and emp=emp_no) into the view as well?
    Q3 All the fields mentioned above are diaplay-only. So Can I create a control block which has all the fields from emp and project. Then populate them with my sql. The question is
    where I put this customerised sql so when user click excute query. My sql will run and display one the form?
    REally appreciated your help!
    Michael

  • Problem creating a view in Administrator: 942: table or view does not exist

    Hi and thank you for reading,
    I am working with the Administration tool and would like to create a view in the physical layer. However I am getting the following error messages when I try to view the Date in the view:
    [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occured.
    [nQSError: 43093] An error occured while processing the EXECUTE PHYSICAL satement.
    *[nQSError: 17001] Oracle Error code: 942, message: ORA-00942: table or view does not exist at OCI call OCIStmtExecute.*
    [nQSError: 17010] SQL statement preparation failed.
    [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occured.
    [nQSError: 43093] An error occured while processing the EXECUTE PHYSICAL satement.
    *[nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute.*
    [nQSError: 17010] SQL statement preparation failed.
    I proceed as following:
    Right click on a physical schema (this schema is already created and works in Answers) -> new Physical Schema ->Table Type: Select -> Select * from Table_A where name='name' (Table_A is in the physical schema) -> OK -> Save -> Deploy -> Update Row count (works) -> View Data -> Error
    Any Idea what I am doing wrong. I have started with an easy select statement to test how to create a view in Oracle Administrator.
    Thanks a lot for any help
    Evgeny

    Do you see Table_A, and in which database schema?
    Try to put alias (database user) before table name.
    Select * from user.Table_A where name='name'
    Where user is database user.
    If you have Table_A in another user and connection pool is set to different user, then grant select from Table_A owner to connection pool user (make synonym for Table_A):
    Example (I'm using connection pool from userB and have tables from userA and userB).
    create or replace public synonym xx for userA.xx
    and
    grant select on xx to userB
    Hope this helps.
    Regards,
    Goran
    http://108obiee.blogspot.com

  • How to create a view based on Lookup Column?

    Hi All,
    I am working as a SharePoint developer 2013.
    When i tried to create a view based on look up column it is not showing lookup column.
    How to fix this problem?
    Please help me out here.
    Thanks & Regards,
    Santhoshi

    can you elaborate the issue? Do you mean you cannot view the column name in the filter section when creating a new view for the list or the column is not getting displayed in the view created?
    --Cheers

  • Create a view to shows data from multiple rows in a single column

    Hi all - this is probably posted in the wrong forum but I couldn't find which was the correct one.
    I am almost a complete novice at sql but I have a need to create a view which can be developed at 10g (which runs efficiently as the volumes are likely to be high) which will do the following.
    Original table with columns Parent_code, Child_code
    Parent_Code Child_Code
    1000 2000
    1000 3000
    1000 4000
    2000 3000
    2000 5000
    (note Parents can have multiple children and a child can have multiple parents!)
    What I need to end up with in my view is the following
    Child_Code Parent_List
    2000 '1000 (3)'
    3000 '1000 (3), 2000 (2)'
    4000 '1000 (3)'
    5000 '2000 (2)'
    Note the number in parantheses is the number of children that the parent has - ie in the original table parent 1000 has 3 rows (one for each child)
    This view is then to be used as a look up (on child code) for a business objects report.
    Is there anyone who could PLEASE, PLEASE help me fairly quickly on this as I have very little time to find a solution?

    Hi,
    You can test these ones :
    select child_code
         , ltrim(sys_connect_by_path(parent_info,', '), ', ') as parent_list
    from (
      select child_code
           , to_char(parent_code) ||
             ' (' ||
             count(*) over(partition by parent_code) ||
             ')' as parent_info
           , row_number() over(partition by child_code order by parent_code) rn
      from your_table
    where connect_by_isleaf = 1
    connect by prior rn = rn-1
           and prior child_code = child_code
    start with rn = 1
    select child_code,
           rtrim(
             extract(
               xmlagg(xmlelement("e",parent_info||', ') order by parent_info)
             , '//text()'
           ) as parent_list
    from (
      select child_code,
             to_char(parent_code) ||
             ' (' ||
             count(*) over(partition by parent_code) ||
             ')' as parent_info
      from your_table
    group by child_code
    ;What you need is called "string aggregation".
    See here for various techniques, including the two above : http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

  • How to update multiple records in a table created in view (web dynpro)

    Here is my coding......
    *coding to get the district value
    DATA lo_nd_district TYPE REF TO if_wd_context_node.
        DATA lo_el_district TYPE REF TO if_wd_context_element.
        DATA ls_district TYPE wd_this->element_district.
        DATA lv_district_txt LIKE ls_district-district_txt.
      navigate from <CONTEXT> to <DISTRICT> via lead selection
        lo_nd_district = wd_context->get_child_node( name = wd_this->wdctx_district ).
      get element via lead selection
        lo_el_district = lo_nd_district->get_element(  ).
      get single attribute
        lo_el_district->get_attribute(
          EXPORTING
            name =  `DISTRICT_TXT`
          IMPORTING
            value = lv_district_txt ).
    *coding to diplay records when clicking a button(Submit)
    DATA lo_nd_table TYPE REF TO if_wd_context_node.
    DATA lo_el_table TYPE REF TO if_wd_context_element.
    DATA ls_table TYPE wd_this->element_table.
      DATA lv_district LIKE ls_table-district.
    navigate from <CONTEXT> to <TABLE> via lead selection
      lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
    get element via lead selection
      lo_el_table = lo_nd_table->get_element(  ).
    get single attribute
      lo_el_table->set_attribute(
        EXPORTING
          name =  `DISTRICT`
       " IMPORTING
          value = lv_district_txt ).
    The above coding updates only one record to that
    table created in view.
    If i enter 2nd district value means then the first record
    in the table is overwritten.
    So my need is the record should not be overwritten.
    it(2nd record ) should be displayed after the 1st record.
    Any one can help me and send the coding plz....

    instead of using set attribute you should use bind table method to display/update the records in table view.
    step1 ) collect all the data in a local table
    step2 ) and the bind that lacal table with your node
    search1 = wd_context->get_child_node( name = `TABLE1` ).
    search1->bind_table( lt_detail)
    here lt_detail is your local table and TABLE1 is node which is bound with table ui element.

  • Creating a view on two ODS using the most actual value of Timestamp

    Hi All,
    I am creating a view on two ODS. I have made an internal join of the field timestamp from both the tables. But the timestamp in bot ODS do not match, which is why there is no data visible in the view.
    There is a requirement that the value of timestamp to be used has to be the most actual value of timestamp from the two ODS.
    I would be grateful if some pointers regarding the same could be provided.
    Thanks and regards,
    Shruti Kulkarni

    Hi Shruti,
    ODS should not be linked on Timestamp basis, there must be some other alternatives like document number, date etc etc...
    In other case if its possible to include addtional key figure in to ODS then
    create a dummy key figure , in the aggregation tab page Select Exception aggregate as "Last Value" and in the "agg.ref char" Select time stamp as info object. This setting will make sure that in the ODS you have only last updated data.
    Hope that helps.
    Regards
    Mr Kapadia
    Assigning points is the way to say thanks in SDN.

  • MVC: Create a view which populates two (or more) joined tables in a single view table

    I am beginner in MVC and I would like to create a view which populates two (or more) joined tables in a single view table as described below.
    I have two tables:
    1 - Bloggers: - bloggerID (int);
                        - bloggerName (string)
    2 - Blogs: - blogID (int);
    bloggerID (int);
                    - blogTitle (string);
                    - blogImage (string)
    A blogger can have one or more blogs while one blog must be related to only one blogger.
    I would like to have a view table on my webpage as the following:
    Blogger Name
    Blog Title
    Blog Image
    Noris Gang
    Virus
    virus.jpg
    Noris Gang
    Desktops
    desktop.jpg
    Gauthier
    Books
    books.png
    John Leon
    NNNMHJhjdhj
    Nmbj.jpg
    I'm using MVC 4 (or at least 3).
    Thanks for your help.

    Hello,
    From your description, it is not very clear that what you mean about the View, if it means the View concept in database as SQL Server, your required view should be as below:
    Create view
    as
    Select Bloggers.bloggerName, Bloggers.blogTitle, Bloggers.blogImage
    From Bloggers join Blogs on Bloggers.bloggerID = Blogs. bloggerID
    If it means the UI view in MVC concept, I suggest you could ask it on the MVC forum:
    http://forums.asp.net/1146.aspx
    Regards.
    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.

Maybe you are looking for

  • Importing CD to Artist folder\Album folder\file with track number and name:

    I have a problem then importing my cd's to my harddisk using iTunes. On my previous pc I got what I want, Artist folder, Album folder and file with track number and name: e.g. D:\My Music\B.B. King\Blues On The Bayou\01 Blues Boys Tune.mp3 D:\My Musi

  • Brand new Extreme base not being recognized by the utility

    Part# ME918LL/A Serial #C86LN2P7FJ1R Model # A1521 Utility is not recognizing the base. Tried the different troubleshooting including resetting the base. Please advise.

  • Integration Builder under Linux

    Hi all, during preparation for a migration project to Linux we‘re experimenting using the SAP Integration Builder Repository and Directory of a XI 2.0 on a Linux client. We got it start proper but the context menu is not working. So we are not able t

  • Oracle Report Printing

    Hi, there, I'm having a problem printing Reports: Click print button on previewer, get error "Oracle Printing/Can't open AFM file(s): myungjo." Click OK on error popup and report gets printed. How do I get rid off that error message? Thanks! WL

  • 27" iMac (refurb, June 2011) not working as an external display for my MacBook Pro.

    I just got a 27" iMac (refurb, June 2011) and it's not working as an external display for my MacBook Pro (not Thunderbolt).  Any idea why?  Command+F2 does nothing.  I am connecting via Belkin Minidisplay Port-to-Minidisplay Port adapter. Any help is