Virtual column in a View contains null

Hi experts !
I have created a virtual column in one of the database tables. Now when i try to create a view that is based on a select statement with multiple joins, all columns in view are correct except virtual one. it is all null.
can anyone please help me out. i have tried removing the joins from the select statement. It works fine when there is only join. if select statement has more then one join, the virtual column becomes null in view.
Please help me out. m badly stuck

Sir William!
please alter the link. Though i have found a workaround but its not proper solution. I have created a view will all the joins, and then created another view joining that view and the virtual column. but it would be really informative to know what is causing such behavior.
Best Regards

Similar Messages

  • How to cast a column of a derived column in a view to NULL

    I have a derived column in my view and this column by default is picked up as not null.
    I want to cast it to null how can i do it ?
    Actual column
    column1 varchar(3) not null
    Expected column
    column1 varchar(3)  null
    Mudassar

    Shridar I  havent defined it but the derived column has been picked up as not null which is strange
    CREATE VIEW test
    AS
    SELECT 
    CASE
    WHEN COMPANY_SIZE IS NULL then  'a'
    ELSE 'b' 
    END AS
    column1 ----- added derived column identifier
    ,[Company_Size] AS [CompanySize]
    FROM xyz
    Mudassar

  • ORA-01733- virtual column not allowed here  - Insert using inline view

    Does anyone know why I am getting ORA-01733- virtual column not allowed here
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    ---no error without WITH CHECK option
    SQL> INSERT INTO
    2 (SELECT
    3 location_id,
    4 city,
    5 l.country_id
    6 FROM countries c, locations l,regions r
    7 where l.country_id = c.country_id
    8 and r.region_id=c.region_id
    9 and r.region_name = 'Asia')
    10 VALUES (5500, 'Wansdworth Common', 'UK');
    1 row created.
    SQL> rollback;
    Rollback complete.
    -----error with WITH CHECK OPTION
    SQL> INSERT INTO
    2 (SELECT
    3 location_id,
    4 city,
    5 l.country_id
    6 FROM countries c, locations l,regions r
    7 where l.country_id = c.country_id
    8 and r.region_id=c.region_id
    9 and r.region_name = 'Asia' WITH CHECK OPTION)
    10 VALUES (5500, 'Wansdworth Common', 'UK');
    INSERT INTO
    ERROR at line 1:
    ORA-01733: virtual column not allowed here
    I was expecting
    ORA-01402: view WITH CHECK OPTION where-clause violation
    for the second one. Is there anything I am missing here ?

    Randolf
    Thank you very much for the update to this old question
    After reading the link I think I should ignore this error and accept it as ORA-01402
    The information you asked me to check did not lead me an understanding of different error types.
    SQL> ----view for ORA-01733
    SQL> create view test_v_1
      2  as
      3  SELECT
      4  location_id,
      5  city,
      6  l.country_id
      7  FROM countries c, locations l,regions r
      8  where l.country_id = c.country_id
      9  and r.region_id=c.region_id
    10  and r.region_name = 'Asia' WITH CHECK OPTION;
    View created.
    SQL>
    SQL>
    SQL>
    SQL> select * from user_updatable_columns where table_name='TEST_V_1';
    OWNER                          TABLE_NAME                     COLUMN_NAME                    UPD INS DEL
    HR                             TEST_V_1                       CITY                           YES YES YES
    HR                             TEST_V_1                       COUNTRY_ID                     NO  NO  NO
    HR                             TEST_V_1                       LOCATION_ID                    YES YES YES
    SQL>
    SQL> ----view for ORA-01402
    SQL>
    SQL> create view test_v_2
      2  as
      3  SELECT
      4  d.department_id,
      5  d.department_name,
      6  d.location_id
      7  FROM hr.departments d,hr.locations l
      8  WHERE l.location_id=d.location_id
      9  and d.location_id < 2000
    10  WITH CHECK OPTION;
    View created.
    SQL>
    SQL> select * from user_updatable_columns where table_name='TEST_V_2';
    OWNER                          TABLE_NAME                     COLUMN_NAME                    UPD INS DEL
    HR                             TEST_V_2                       DEPARTMENT_ID                  YES YES YES
    HR                             TEST_V_2                       DEPARTMENT_NAME                YES YES YES
    HR                             TEST_V_2                       LOCATION_ID                    NO  NO  NO
    SQL>
    SQL>
    SQL> ----INSERT STILL FAILING WITH DIFFERENT ERROR DESPITE THE SAME UPDATABLE COLUMN STRUCTURE
    SQL> insert into test_v_1 values  (5500, 'Wansdworth Common', 'UK');
    insert into test_v_1 values  (5500, 'Wansdworth Common', 'UK')
    ERROR at line 1:
    ORA-01733: virtual column not allowed here
    SQL> insert into test_v_2 values  (9999, 'Entertainment', 2500);
    insert into test_v_2 values  (9999, 'Entertainment', 2500)
    ERROR at line 1:
    ORA-01402: view WITH CHECK OPTION where-clause violation
    SQL>A. Coskan GUNDOGAR
    Oracle DBA
    http://coskan.wordpress.com
    “A man's errors are his portals of discovery.”
    James Joyce

  • Virtual column not allowed while creating "simple view"

    hi,
    i have created a simple view
    systax:
    create view empvu30
    as select empno id_number,ename Name,sal*12 ANN_SALARY
    from emp where deptno=30;
    when i am going to update this view i am getting error:
    ORA-01733: virtual column not allowed here

    user10492712 wrote:
    hi,
    i have created a simple view
    systax:
    create view empvu30
    as select empno id_number,ename Name,sal*12 ANN_SALARY
    from emp where deptno=30;
    when i am going to update this view i am getting error:
    ORA-01733: virtual column not allowed hereThe error is correct as you have a transformation done on the Sal column which can't be updated. That's why the error is thrown to you.
    Please read this link,
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/views001.htm#i1006127
    >
    If the view was created by using an expression, such as DECODE(deptno, 10, "SALES", ...), then rows cannot be inserted into or updated in the base table using the view.>
    HTH
    @Pavan,
    That's different question altogether. I don't think OP question falls in that thread's context.
    Aman....

  • Column definition for a specific column in a view

    Is there a way to query the metadata to get the definition of a single column in a view? I can see the complete DDL for a view from USER_VIEWS.TEXT, and I can see the column listing in USER_TAB_COLUMNS to give the datatype etc. However, what I'm looking for is the DDL that defined a specific column.
    So, given:
    create table PERSON (
    SSN VARCHAR2(12),
    FIRST_NAME VARCHAR2(25),
    LAST_NAME VARCHAR2(25),
    STREET VARCHAR2(40),
    CITY VARCHAR2(30),
    STATE VARCHAR2(30),
    ZIP VARCHAR2(15),
    COUNTRY VARCHAR2(35))
    create view PERSON_VW as
    select SSN,
    FIRST_NAME,
    LAST_NAME,
    FIRST_NAME || ' ' || LAST_NAME FULL_NAME
    from PERSON
    I expect the query might look something like:
    select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FULL_NAME'
    and the result would be: "PERSON.FIRST_NAME || ' ' || PERSON.LAST_NAME"
    or select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FIRST_NAME'
    and the result would be: "PERSON.FIRST_NAME"
    Thanks!

    >
    Hi again Barry,
    When I queried user_tab_columns (or dba_tab_columns or all_tab_columns), I have the following list of columns:
    TABLE_NAME
    COLUMN_NAME
    DATA_TYPE
    DATA_LENGTH
    DATA_PRECISION
    DATA_SCALE
    NULLABLE
    COLUMN_ID
    DEFAULT_LENGTH
    DATA_DEFAULT
    I don't see anything resembling the DDL for the view column. Somewhere underneath some
    cover I haven't peeked under, Oracle must be keeping track of what it is supposed to be giving
    for, in my example, FULL_NAME.Unless I'm very much mistaken, these columns' data (per table) looks pretty much like DDL to me.
    Maybe what you need is just SQL Developer (great tool, if you don't have it, get it!).
    And it's free (as in beer - not as in speech! :( )
    Beside the connections tab is a "Reports" tab with various, as you might expect ;), reports.
    One of them is on the Tables - with (some) DDL. This will work as a once-off if that's what
    you need?
    Otherwise there's the SQL tab if you open a table under connections - it's very complete - sample
    at bottom of post.
    HTH,
    Paul...
    (Ultimately, I'm diagnosing problems in existing databases that have views already created so
    I don't have the option of considering virtual columns.)Quelle surprise ;(
    Paul...
    -Barry
    CREATE TABLE "HR"."COUNTRIES"
        "COUNTRY_ID"   CHAR(2 BYTE) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE,
        "COUNTRY_NAME" VARCHAR2(40 BYTE),
        "REGION_ID"    NUMBER,
        CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE,
        CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE
      ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "USERS" PCTTHRESHOLD 50;
    COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_ID"
    IS
      'Primary key of countries table.';
      COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_NAME"
    IS
      'Country name';
      COMMENT ON COLUMN "HR"."COUNTRIES"."REGION_ID"
    IS
      'Region ID for the country. Foreign key to region_id column in the departments table.';
      COMMENT ON TABLE "HR"."COUNTRIES"
    IS
      'country table. Contains 25 rows. References with locations table.';

  • Virtual column partitioning - explain plan takes lot of time.

    I have some problem with table with partitioning based on virtual column.
    Explain plan generates for some simple select 2-5 minutes,
    but the same select but without part of where clausule generate in secounds.
    In both query there is the same explain plan.
    Could someone explain why?
    Table:
    CREATE TABLE "SUBSCRIPTION"
    "CUSTOMER_ID" VARCHAR2(100 BYTE),
    "IDENT_SOURCE_ID" VARCHAR2(20 BYTE),
    "ACCOUNT_ID" VARCHAR2(100 BYTE),
    "MSISDN" VARCHAR2(500 BYTE),
    "IMSI" VARCHAR2(500 BYTE),
    "SIM" VARCHAR2(500 BYTE),
    "IMEI" VARCHAR2(500 BYTE),
    "MEID" VARCHAR2(15 BYTE),
    "EMAIL" VARCHAR2(100 BYTE),
    "TELCOOP" VARCHAR2(1000 BYTE),
    "MSISDN_TYPE" VARCHAR2(20 BYTE),
    "GSM" NUMBER(1,0),
    "CDMA" NUMBER(1,0),
    "VALID_FROM" DATE,
    "VALID_TO" DATE,
    "MSISDN_HASH" NUMBER(3,0) GENERATED ALWAYS AS (MOD(TO_NUMBER(NVL2(RTRIM(TRANSLATE(NVL(SUBSTR("MSISDN",-3),NVL("MSISDN",'err')),'123456789','000000000'),'0'),'-1',NVL(SUBSTR("MSISDN",-3),"MSISDN"))),125)) VIRTUAL VISIBLE, --generali mod from 3 last digits of msisdn
    ) PARTITION BY LIST ( "MSISDN_HASH" )
    PARTITION "PCHR" VALUES ( -1 )
    PARTITION "P000" VALUES ( 0 )
    PARTITION "P001" VALUES ( 1 )
    ... and so on till...
    PARTITION "P124" VALUES (124)
    PARALLEL 4;
    Slow select:
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from dbident2.subscription
    where MSISDN = '600489461'
    AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    Fast select:
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from dbident2.subscription
    where MSISDN = '600489461'
    AND MSISDN_HASH = 86

    --Slower select trace:
    Registered qb: SEL$1 0xf4ea2a20 (PARSER)
    QUERY BLOCK SIGNATURE
    signature (): qb_name=SEL$1 nbfros=1 flg=0
    fro(0): flg=4 objn=848731 hint_alias="SUBSCRIPTION"@"SEL$1"
    SPM: statement not found in SMB
    SPM: statement not a candidate for auto-capture
    Dynamic sampling level auto-adjusted from 6 to 6
    Automatic degree of parallelism (ADOP)
    Automatic degree of parallelism is disabled: Parameter.
    PM: Considering predicate move-around in query block SEL$1 (#0)
    Predicate Move-Around (PM)
    OPTIMIZER INFORMATION
    ----- Current SQL Statement for this session (sql_id=afjvvjmx6tqgr) -----
    explain plan for
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from subscription
    where MSISDN = '600600600' AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    Legend
    The following abbreviations are used by optimizer trace.
    CBQT - cost-based query transformation
    JPPD - join predicate push-down
    OJPPD - old-style (non-cost-based) JPPD
    FPD - filter push-down
    PM - predicate move-around
    CVM - complex view merging
    SPJ - select-project-join
    SJC - set join conversion
    SU - subquery unnesting
    OBYE - order by elimination
    OST - old style star transformation
    ST - new (cbqt) star transformation
    CNT - count(col) to count(*) transformation
    JE - Join Elimination
    JF - join factorization
    SLP - select list pruning
    DP - distinct placement
    qb - query block
    LB - leaf blocks
    DK - distinct keys
    LB/K - average number of leaf blocks per key
    DB/K - average number of data blocks per key
    CLUF - clustering factor
    NDV - number of distinct values
    Resp - response cost
    Card - cardinality
    Resc - resource cost
    NL - nested loops (join)
    SM - sort merge (join)
    HA - hash (join)
    CPUSPEED - CPU Speed
    IOTFRSPEED - I/O transfer speed
    IOSEEKTIM - I/O seek time
    SREADTIM - average single block read time
    MREADTIM - average multiblock read time
    MBRC - average multiblock read count
    MAXTHR - maximum I/O system throughput
    SLAVETHR - average slave I/O throughput
    dmeth - distribution method
    1: no partitioning required
    2: value partitioned
    4: right is random (round-robin)
    128: left is random (round-robin)
    8: broadcast right and partition left
    16: broadcast left and partition right
    32: partition left using partitioning of right
    64: partition right using partitioning of left
    256: run the join in serial
    0: invalid distribution method
    sel - selectivity
    ptn - partition
    PARAMETERS USED BY THE OPTIMIZER
    PARAMETERS WITH ALTERED VALUES
    Compilation Environment Dump
    pgamax_size = 1258280 KB
    parallel_query_default_dop = 32
    db_file_multiblock_read_count = 16
    Bug Fix Control Environment
    PARAMETERS IN OPT_PARAM HINT
    Column Usage Monitoring is ON: tracking level = 1
    Considering Query Transformations on query block SEL$1 (#0)
    Query transformations (QT)
    JF: Checking validity of join factorization for query block SEL$1 (#0)
    JF: Bypassed: not a UNION or UNION-ALL query block.
    ST: not valid since star transformation parameter is FALSE
    TE: Checking validity of table expansion for query block SEL$1 (#0)
    TE: Bypassed: No relevant table found.
    CBQT bypassed for query block SEL$1 (#0): no complex view, sub-queries or UNION (ALL) queries.
    CBQT: Validity checks failed for afjvvjmx6tqgr.
    CSE: Considering common sub-expression elimination in query block SEL$1 (#0)
    Common Subexpression elimination (CSE)
    CSE: CSE not performed on query block SEL$1 (#0).
    OBYE: Considering Order-by Elimination from view SEL$1 (#0)
    Order-by elimination (OBYE)
    OBYE: OBYE bypassed: no order by to eliminate.
    CVM: Considering view merge in query block SEL$1 (#0)
    query block SEL$1 (#0) unchanged
    Considering Query Transformations on query block SEL$1 (#0)
    Query transformations (QT)
    JF: Checking validity of join factorization for query block SEL$1 (#0)
    JF: Bypassed: not a UNION or UNION-ALL query block.
    ST: not valid since star transformation parameter is FALSE
    TE: Checking validity of table expansion for query block SEL$1 (#0)
    TE: Bypassed: No relevant table found.
    CBQT bypassed for query block SEL$1 (#0): no complex view, sub-queries or UNION (ALL) queries.
    CBQT: Validity checks failed for afjvvjmx6tqgr.
    CSE: Considering common sub-expression elimination in query block SEL$1 (#0)
    Common Subexpression elimination (CSE)
    CSE: CSE not performed on query block SEL$1 (#0).
    SU: Considering subquery unnesting in query block SEL$1 (#0)
    Subquery Unnest (SU)
    SJC: Considering set-join conversion in query block SEL$1 (#0)
    Set-Join Conversion (SJC)
    SJC: not performed
    PM: Considering predicate move-around in query block SEL$1 (#0)
    Predicate Move-Around (PM)
    PM: PM bypassed: Outer query contains no views.
    PM: PM bypassed: Outer query contains no views.
    query block SEL$1 (#0) unchanged
    FPD: Considering simple filter push in query block SEL$1 (#0)
    "SUBSCRIPTION"."MSISDN"='600600600' AND "SUBSCRIPTION"."MSISDN_HASH"=86 AND "SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
    try to generate transitive predicate from check constraints for query block SEL$1 (#0)
    finally: "SUBSCRIPTION"."MSISDN"='600600600' AND "SUBSCRIPTION"."MSISDN_HASH"=86 AND "SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
    apadrv-start sqlid=12053738773107497463
    call(in-use=8176, alloc=32712), compile(in-use=114912, alloc=116848), execution(in-use=175432, alloc=178928)
    Peeked values of the binds in SQL statement
    Final query after transformations:******* UNPARSED QUERY IS *******
    SELECT "SUBSCRIPTION"."CUSTOMER_ID" "CUSTOMER_ID","SUBSCRIPTION"."IDENT_SOURCE_ID" "IDENT_SOURCE_ID","SUBSCRIPTION"."ACCOUNT_ID" "ACCOUNT_ID","SUBSCRIPTION"."MSISDN" "MSISDN","SUBSCRIPTION"."IMSI" "IMSI","SUBSCRIPTION"."SIM" "SIM","SUBSCRIPTION"."IMEI" "IMEI","SUBSCRIPTION"."MEID" "MEID","SUBSCRIPTION"."EMAIL" "EMAIL","SUBSCRIPTION"."TELCOOP" "TELCOOP" FROM "DBIDENT2"."SUBSCRIPTION" "SUBSCRIPTION" WHERE "SUBSCRIPTION"."MSISDN"='600600600' AND "SUBSCRIPTION"."MSISDN_HASH"=86 AND "SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
    kkoqbc: optimizing query block SEL$1 (#0)
    call(in-use=8320, alloc=32712), compile(in-use=115880, alloc=116848), execution(in-use=175432, alloc=178928)
    kkoqbc-subheap (create addr=0x2b24ebece950)
    QUERY BLOCK TEXT
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from subscription
    where MSISDN = '600600600' AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    QUERY BLOCK SIGNATURE
    signature (optimizer): qb_name=SEL$1 nbfros=1 flg=0
    fro(0): flg=0 objn=848731 hint_alias="SUBSCRIPTION"@"SEL$1"
    SYSTEM STATISTICS INFORMATION
    Using NOWORKLOAD Stats
    CPUSPEEDNW: 714 millions instructions/sec (default is 100)
    IOTFRSPEED: 4096 bytes per millisecond (default is 4096)
    IOSEEKTIM: 10 milliseconds (default is 10)
    MBRC: -1 blocks (default is 16)
    BASE STATISTICAL INFORMATION
    Table Stats::
    Table: SUBSCRIPTION Alias: SUBSCRIPTION Partition [87]
    #Rows: 218104 #Blks: 11008 AvgRowLen: 129.00 ChainCnt: 0.00
    #Rows: 218104 #Blks: 11008 AvgRowLen: 129.00 ChainCnt: 0.00
    Index Stats::
    Index: SUBSCRIPTION_NDX_ACCID Col#: 3
    LVLS: 3 #LB: 121036 #DK: 9767936 LB/K: 1.00 DB/K: 1.00 CLUF: 13921256.00
    Index: SUBSCRIPTION_NDX_CUSID Col#: 1 2 18
    LVLS: 3 #LB: 142123 #DK: 24665396 LB/K: 1.00 DB/K: 1.00 CLUF: 24842146.00
    Index: SUBSCRIPTION_NDX_EMAIL Col#: 9
    LVLS: 2 #LB: 8365 #DK: 1361827 LB/K: 1.00 DB/K: 1.00 CLUF: 1361798.00
    Index: SUBSCRIPTION_NDX_EXT1 Col#: 19
    LVLS: 2 #LB: 65756 #DK: 67792 LB/K: 1.00 DB/K: 80.00 CLUF: 5446485.00
    Index: SUBSCRIPTION_NDX_IMEI Col#: 7
    LVLS: 2 #LB: 44539 #DK: 9199616 LB/K: 1.00 DB/K: 1.00 CLUF: 10413439.00
    Index: SUBSCRIPTION_NDX_IMSI Col#: 5
    LVLS: 3 #LB: 92914 #DK: 12846080 LB/K: 1.00 DB/K: 1.00 CLUF: 23472821.00
    Index: SUBSCRIPTION_NDX_MEID Col#: 8
    LVLS: 1 #LB: 132 #DK: 12585 LB/K: 1.00 DB/K: 1.00 CLUF: 18419.00
    Index: SUBSCRIPTION_NDX_MSISDN Col#: 4 PARTITION [87]
    LVLS: 2 #LB: 1092 #DK: 74848 LB/K: 1.00 DB/K: 2.00 CLUF: 191920.00
    LVLS: 2 #LB: 1092 #DK: 74848 LB/K: 1.00 DB/K: 2.00 CLUF: 191920.00
    Index: SUBSCRIPTION_NDX_SIM Col#: 6
    LVLS: 2 #LB: 88153 #DK: 13169664 LB/K: 1.00 DB/K: 1.00 CLUF: 24727298.00
    Index: SUBSCRIPTION_NDX_SRCID Col#: 2 17
    LVLS: 2 #LB: 81729 #DK: 4 LB/K: 20432.00 DB/K: 257314.00 CLUF: 1029257.00
    Access path analysis for SUBSCRIPTION
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for SUBSCRIPTION[SUBSCRIPTION]
    *** 2012-06-12 12:34:53.283
    ** Performing dynamic sampling initial checks. **
    Column (#14):
    NewDensity:0.000020, OldDensity:0.000366 BktCnt:254, PopBktCnt:22, PopValCnt:1, NDV:46252
    Column (#14):
    NewDensity:0.000163, OldDensity:0.000378 BktCnt:254, PopBktCnt:12, PopValCnt:1, NDV:5852
    Column (#14): VALID_FROM( Part#: 87
    AvgLen: 8 NDV: 5852 Nulls: 2 Density: 0.000163 Min: 2450364 Max: 2456082
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 244
    Column (#14): VALID_FROM(
    AvgLen: 8 NDV: 5852 Nulls: 2 Density: 0.000163 Min: 2450364 Max: 2456082
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 244
    Column (#4):
    NewDensity:0.000000, OldDensity:0.000000 BktCnt:254, PopBktCnt:0, PopValCnt:0, NDV:9730048
    Column (#4):
    NewDensity:0.000013, OldDensity:0.000033 BktCnt:254, PopBktCnt:0, PopValCnt:0, NDV:74848
    Column (#4): MSISDN( Part#: 87
    AvgLen: 10 NDV: 74848 Nulls: 0 Density: 0.000013
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 255
    Column (#4): MSISDN(
    AvgLen: 10 NDV: 74848 Nulls: 0 Density: 0.000013
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 255
    ** Dynamic sampling initial checks returning TRUE (level = 6).
    *** 2012-06-12 12:34:53.284
    ** Generated dynamic sampling query:
    query text :
    SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0), NVL(SUM(C2),0) FROM (SELECT /*+ IGNORE_WHERE_CLAUSE NO_PARALLEL("SUBSCRIPTION") FULL("SUBSCRIPTION") NO_PARALLEL_INDEX("SUBSCRIPTION") */ 1 AS C1, CASE WHEN "SUBSCRIPTION"."MSISDN"='600600600' AND "SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss') THEN 1 ELSE 0 END AS C2 FROM "DBIDENT2"."SUBSCRIPTION" SAMPLE BLOCK (1.153706 , 1) SEED (1) "SUBSCRIPTION" WHERE "SUBSCRIPTION"."MSISDN"='600600600' AND "SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) SAMPLESUB
    *** 2012-06-12 12:36:44.452
    ** Executed dynamic sampling query:
    level : 6
    sample pct. : 1.153706
    total partitions : 1
    partitions for sampling : 1
    actual sample size : 342182
    filtered sample card. : 0
    orig. card. : 218104
    block cnt. table stat. : 11008
    block cnt. for sampling: 11008
    max. sample block cnt. : 128
    sample block cnt. : 127
    min. sel. est. : 0.00001260
    ** Not using dynamic sampling for single table sel. or cardinality.
    DS Failed for : ----- Current SQL Statement for this session (sql_id=afjvvjmx6tqgr) -----
    explain plan for
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from subscription
    where MSISDN = '600600600' AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    Column (#21):
    NewDensity:0.002912, OldDensity:0.000000 BktCnt:14078, PopBktCnt:14078, PopValCnt:126, NDV:126
    Column (#21): MSISDN_HASH( Part#: 87
    AvgLen: 3 NDV: 1 Nulls: 0 Density: 0.000002 Min: 86 Max: 86
    Histogram: Freq #Bkts: 1 UncompBkts: 13365 EndPtVals: 1
    Column (#21): MSISDN_HASH(
    AvgLen: 3 NDV: 1 Nulls: 0 Density: 0.000002 Min: 86 Max: 86
    Histogram: Freq #Bkts: 1 UncompBkts: 13365 EndPtVals: 1
    Column (#1):
    NewDensity:0.000000, OldDensity:0.000241 BktCnt:254, PopBktCnt:31, PopValCnt:2, NDV:9768960
    Column (#1):
    NewDensity:0.000009, OldDensity:0.000250 BktCnt:254, PopBktCnt:36, PopValCnt:3, NDV:99208
    Column (#1): CUSTOMER_ID( Part#: 87
    AvgLen: 11 NDV: 99208 Nulls: 0 Density: 0.000009
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 222
    Column (#1): CUSTOMER_ID(
    AvgLen: 11 NDV: 99208 Nulls: 0 Density: 0.000009
    Histogram: HtBal #Bkts: 254 UncompBkts: 254 EndPtVals: 222
    Column (#2):
    NewDensity:0.000639, OldDensity:0.000000 BktCnt:14078, PopBktCnt:14078, PopValCnt:3, NDV:3
    Column (#2):
    NewDensity:0.000786, OldDensity:0.000002 BktCnt:13365, PopBktCnt:13365, PopValCnt:3, NDV:3
    Column (#2): IDENT_SOURCE_ID( Part#: 87
    AvgLen: 5 NDV: 3 Nulls: 0 Density: 0.000786
    Histogram: Freq #Bkts: 3 UncompBkts: 13365 EndPtVals: 3
    Column (#2): IDENT_SOURCE_ID(
    AvgLen: 5 NDV: 3 Nulls: 0 Density: 0.000786
    Histogram: Freq #Bkts: 3 UncompBkts: 13365 EndPtVals: 3
    ColGroup (#1, Index) SUBSCRIPTION_NDX_CUSID
    Col#: 1 2 18 CorStregth: -1.00
    ColGroup (#2, Index) SUBSCRIPTION_NDX_SRCID
    Col#: 2 17 CorStregth: -1.00
    ColGroup Usage:: PredCnt: 2 Matches Full: Partial:
    ***** Virtual column Adjustment ******
    Column name MSISDN_HASH
    cost_cpu 2300.00
    cost_io 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00
    ***** End virtual column Adjustment ******
    Table: SUBSCRIPTION Alias: SUBSCRIPTION
    Card: Original: 218104.000000 Rounded: 3 Computed: 2.75 Non Adjusted: 2.75
    Access Path: TableScan
    Cost: 2420.71 Resp: 672.42 Degree: 0
    Cost_io: 2409.00 Cost_cpu: 100334308
    Resp_io: 669.17 Resp_cpu: 27870641
    kkofmx: index filter:"SUBSCRIPTION"."MSISDN_HASH"=86
    ***** Virtual column Adjustment ******
    Column name MSISDN_HASH
    cost_cpu 2300.00
    cost_io 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00
    ***** End virtual column Adjustment ******
    Access Path: index (AllEqRange)
    Index: SUBSCRIPTION_NDX_MSISDN
    resc_io: 6.00 resc_cpu: 36840
    ix_sel: 0.000013 ix_sel_with_filters: 0.000013
    ***** Logdef predicate Adjustment ******
    Final IO cst 0.00 , CPU cst 2300.00
    ***** End Logdef Adjustment ******
    Cost: 6.01 Resp: 6.01 Degree: 1
    Best:: AccessPath: IndexRange
    Index: SUBSCRIPTION_NDX_MSISDN
    Cost: 6.01 Degree: 1 Resp: 6.01 Card: 2.75 Bytes: 0
    OPTIMIZER STATISTICS AND COMPUTATIONS
    GENERAL PLANS
    Considering cardinality-based initial join order.
    Permutations for Starting Table :0
    Join order[1]: SUBSCRIPTION[SUBSCRIPTION]#0
    Best so far: Table#: 0 cost: 6.0051 card: 2.7487 bytes: 291
    ****** Recost for parallel table scan *******
    Access path analysis for SUBSCRIPTION
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for SUBSCRIPTION[SUBSCRIPTION]
    *** 2012-06-12 12:36:44.454
    ** Performing dynamic sampling initial checks. **
    ** TABLE SUBSCRIPTION Alias: SUBSCRIPTION : reused cached dynamic sampling result (failure).
    ColGroup Usage:: PredCnt: 2 Matches Full: Partial:
    ***** Virtual column Adjustment ******
    Column name MSISDN_HASH
    cost_cpu 2300.00
    cost_io 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00
    ***** End virtual column Adjustment ******
    Table: SUBSCRIPTION Alias: SUBSCRIPTION
    Card: Original: 218104.000000 Rounded: 3 Computed: 2.75 Non Adjusted: 2.75
    Access Path: TableScan
    Cost: 2420.71 Resp: 672.42 Degree: 0
    Cost_io: 2409.00 Cost_cpu: 100334308
    Resp_io: 669.17 Resp_cpu: 27870641
    Best:: AccessPath: TableScan
    Cost: 672.42 Degree: 4 Resp: 672.42 Card: 2.75 Bytes: 97
    Join order[1]: SUBSCRIPTION[SUBSCRIPTION]#0
    Join order aborted: cost > best plan cost
    (newjo-stop-1) k:0, spcnt:0, perm:1, maxperm:2000
    Number of join permutations tried: 1
    Enumerating distribution method (advanced)
    Trying or-Expansion on query block SEL$1 (#0)
    Transfer Optimizer annotations for query block SEL$1 (#0)
    id=0 frofkks[i] (index start key) predicate="SUBSCRIPTION"."MSISDN"='600600600'
    id=0 frofkke[i] (index stop key) predicate="SUBSCRIPTION"."MSISDN"='600600600'
    id=0 frofand predicate="SUBSCRIPTION"."VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
    Final cost for query block SEL$1 (#0) - All Rows Plan:
    Best join order: 1
    Cost: 6.0051 Degree: 1 Card: 3.0000 Bytes: 291
    Resc: 6.0051 Resc_io: 6.0000 Resc_cpu: 43740
    Resp: 6.0051 Resp_io: 6.0000 Resc_cpu: 43740
    kkoqbc-subheap (delete addr=0x2b24ebece950, in-use=21280, alloc=32840)
    kkoqbc-end:
    call(in-use=252920, alloc=343912), compile(in-use=129048, alloc=133000), execution(in-use=192248, alloc=195240)
    kkoqbc: finish optimizing query block SEL$1 (#0)
    apadrv-end
    call(in-use=252920, alloc=343912), compile(in-use=129960, alloc=133000), execution(in-use=192248, alloc=195240)
    Starting SQL statement dump
    user_id=115 user_name=xxx module=SQL*Plus action=
    sql_id=afjvvjmx6tqgr plan_hash_value=1672204165 problem_type=3
    ----- Current SQL Statement for this session (sql_id=afjvvjmx6tqgr) -----
    explain plan for
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from subscription
    where MSISDN = '600600600' AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    sql_text_length=266
    sql=explain plan for
    select CUSTOMER_ID, IDENT_SOURCE_ID, ACCOUNT_ID, MSISDN, IMSI, SIM, IMEI, MEID, EMAIL, TELCOOP
    from subscription
    where MSISDN = '600600600' AND MSISDN_HASH = 86
    AND VALID_FROM <=TO_DATE('2012-02-10 00:00:00', 'YYYY-MM-DD HH2
    sql=4:MI:SS')
    ----- Explain Plan Dump -----
    ----- Plan Table -----
    ============
    Plan Table
    ============
    -----------------------------------------------------------------------------------------------------------------------+
    | Id | Operation | Name | Rows | Bytes | Cost | Time | Pstart| Pstop |
    -----------------------------------------------------------------------------------------------------------------------+
    | 0 | SELECT STATEMENT | | | | 6 | | | |
    | 1 | PARTITION LIST SINGLE | | 3 | 291 | 6 | 00:00:01 | 88 | 88 |
    | 2 | TABLE ACCESS BY LOCAL INDEX ROWID | SUBSCRIPTION | 3 | 291 | 6 | 00:00:01 | 88 | 88 |
    | 3 | INDEX RANGE SCAN | SUBSCRIPTION_NDX_MSISDN| 3 | | 3 | 00:00:01 | 88 | 88 |
    -----------------------------------------------------------------------------------------------------------------------+
    Predicate Information:
    2 - filter("VALID_FROM"<=TO_DATE(' 2012-02-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
    3 - access("MSISDN"='600600600')
    Content of other_xml column
    ===========================
    nodeid/pflags: 1 1 db_version : 11.2.0.2
    parse_schema : xxx
    plan_hash : 1672204165
    plan_hash_2 : 1960934971
    Outline Data:
    /*+
    BEGIN_OUTLINE_DATA
    IGNORE_OPTIM_EMBEDDED_HINTS
    OPTIMIZER_FEATURES_ENABLE('11.2.0.2')
    DB_VERSION('11.2.0.2')
    OPT_PARAM('optimizer_dynamic_sampling' 6)
    ALL_ROWS
    OUTLINE_LEAF(@"SEL$1")
    INDEX_RS_ASC(@"SEL$1" "SUBSCRIPTION"@"SEL$1" ("SUBSCRIPTION"."MSISDN"))
    END_OUTLINE_DATA
    Query Block Registry:
    SEL$1 0xf4ea2a20 (PARSER) [FINAL]
    call(in-use=259392, alloc=343912), compile(in-use=170344, alloc=270888), execution(in-use=344120, alloc=346656)
    End of Optimizer State Dump
    Dumping Hints
    =============
    ====================== END SQL Statement Dump ======================
    Edited by: user3754081 on 2012-06-12 08:07

  • Query on virtual column that is defined in XMLIndex does not use the index

    Hello,
    I am facing an issue in executing queries on a virtual column that is defined in an XMLIndex: it appears as if the index is not used.
    Database details:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    For this use case the XML documents adhere to the following XSD and are stored in an XMLType column in a table:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns="http://a_name_space/v1"
        targetNamespace="http://a_name_space/v1"
        elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
        <xsd:element name="fields">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="field" maxOccurs="unbounded">
                        <xsd:complexType>
                            <xsd:choice>
                                <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                    <xsd:complexType>
                                        <xsd:simpleContent>
                                            <xsd:extension base="notEmptyString4000Type"/>
                                        </xsd:simpleContent>
                                    </xsd:complexType>
                                </xsd:element>
                                <xsd:element name="values" minOccurs="1" maxOccurs="1">
                                    <xsd:complexType>
                                        <xsd:sequence>
                                            <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                                <xsd:complexType>
                                                    <xsd:simpleContent>
                                                        <xsd:extension base="notEmptyString4000Type">
                                                            <xsd:attribute name="startDate" type="xsd:date" use="required"/>
                                                            <xsd:attribute name="endDate" type="xsd:date" />
                                                        </xsd:extension>
                                                    </xsd:simpleContent>
                                                </xsd:complexType>
                                            </xsd:element>
                                        </xsd:sequence>
                                    </xsd:complexType>
                                </xsd:element>
                            </xsd:choice>
                            <xsd:attribute name="name" type="string30Type" use="required"/>
                            <xsd:attribute name="type" type="dataType" use="required"/>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:simpleType name="dataType">
            <xsd:annotation>
                <xsd:documentation>Char, Date, Number</xsd:documentation>
            </xsd:annotation>
            <xsd:restriction base="xsd:string">
                <xsd:enumeration value="C"/>
                <xsd:enumeration value="D"/>
                <xsd:enumeration value="N"/>
            </xsd:restriction>
        </xsd:simpleType>
        <xsd:simpleType name="string30Type">
            <xsd:restriction base="xsd:string">
                <xsd:maxLength value="30"/>
            </xsd:restriction>
        </xsd:simpleType>
        <xsd:simpleType name="notEmptyString4000Type">
            <xsd:restriction base="xsd:string">
                <xsd:maxLength value="4000"/>
                <xsd:pattern value=".+"/>
            </xsd:restriction>
        </xsd:simpleType>
    </xsd:schema>A field can have a single value as well as multiple values.
    The XMLIndex is defined as follows:
    CREATE INDEX test_xmltype_idx ON test_xmltype (additional_fields) INDEXTYPE IS XDB.XMLIndex
    PARAMETERS
    XMLTable dt_fld_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''fields/field''
    COLUMNS
    name varchar2(30 char) PATH ''@name''
    ,dataType varchar2(1 char) PATH ''@type''
    ,val varchar2(4000 char) PATH ''value/text()''
    ,vals XMLType PATH ''values/value'' VIRTUAL
    XMLTable dt_fld_multi_value_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''value'' passing vals
    COLUMNS
    val varchar2(4000) PATH ''text()''
    ,startDate varchar2(30 char) PATH ''@startDate''
    ,endDate varchar2(30 char) PATH ''@endDate''
    ');The following b-tree indexes are defined:
    create index dt_field_name_idx on dt_fld_tab (name);
    create index dt_field_value_idx on dt_fld_tab (val);
    create index dt_field_values_idx on dt_fld_multi_value_tab (val);And stats are properly computed before the queries are executed:
    call dbms_stats.gather_table_stats(user, 'test_xmltype', estimate_percent => null);Queries for single values are cost efficient and fast. With 600K rows in the table these return with 0.002 seconds.
    Queries for multi-valued fields / elements are not though, these result in a full table scan.
    Sample XML snippet:
    <fields>
      <field name="multiVal" type="C">
        <values>
          <value startDate="2013-01-01" endDate="2013-01-01">100</value>
          <value startDate="2014-01-01">120</value>
        </values>
      </field>
    </fields>Examples of costly and slow queries:
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields)
    and xmlexists('/fields/field/values/value[text()="100"]' passing additional_fields)
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01" and .="100"]' passing additional_fields);Whereas the following query on the multi valued field is fast:
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields);For the XPath /fields/field/values/value[@startDate="2013-01-01"] the index is used.
    Suspected cause: XPath issue for the value of a multi valued field, e.g. /fields/field/values/value[text()="aValue"].
    Any hints are appreciated: what am I overlooking here?
    Thanks in advance,
    -Sjoerd
    Edited by: user615230 on May 27, 2013 7:46 AM

    Hello,
    This is using binary XML. The table creation script is:
    create table test_xmltype
    (id number(14,0) not null primary key
    ,member_code varchar2(30 char) not null
    ,period_code varchar2(30 char) not null
    ,amount number(12,2) not null
    ,additional_fields xmltype
    );The schema is not registered in the database. Is that required? It is primarily used to generate Java classes that will be used in order to construct the XML documents.
    And you are right: for our initial investigation the sample XML documents are generated with a PLSQL routine and do not contain namespaces. But for the single valued fields there are also no namespaces and the queries on these are executed with very satisfactory plans.
    Thanks for the swift reply.
    -Sjoerd

  • Adding virtual column: ORA-12899: value too large for column

    I'm using Oracle 11g, Win7 OS, SQL Developer
    I'm trying to add virtual column to my test table, but getting ORA-12899: value too large for column error. Below are the details.
    Can someone help me in this?
    CREATE TABLE test_reg_exp
    (col1 VARCHAR2(100));
    INSERT INTO test_reg_exp (col1) VALUES ('ABCD_EFGH');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_ABC');
    INSERT INTO test_reg_exp (col1) VALUES ('WXYZ_ABCD');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_PQRS');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCD_WXYZ');
    ALTER TABLE test_reg_exp
    ADD (col2 VARCHAR2(100) GENERATED ALWAYS AS (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_')));
    SQL Error: ORA-12899: value too large for column "COL2" (actual: 100, maximum: 400)
    12899. 00000 -  "value too large for column %s (actual: %s, maximum: %s)"
    *Cause:    An attempt was made to insert or update a column with a value
               which is too wide for the width of the destination column.
               The name of the column is given, along with the actual width
               of the value, and the maximum allowed width of the column.
               Note that widths are reported in characters if character length
               semantics are in effect for the column, otherwise widths are
               reported in bytes.
    *Action:   Examine the SQL statement for correctness.  Check source
               and destination column data types.
               Either make the destination column wider, or use a subset
               of the source column (i.e. use substring).When I try to select, I'm getting correct results:
    SELECT col1, (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_'))
    FROM test_reg_exp;Thanks.

    Yes RP, it working if you give col2 size >=400.
    @Northwest - Could you please test the same w/o having a regex clause in col2?
    I doubt on the usage of a REGEX in this dynamic col case.
    Refer this (might help) -- http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
    Below snippet from above link.... see if this helps...
    >
    Notes and restrictions on virtual columns include:
    Indexes defined against virtual columns are equivalent to function-based indexes.
    Virtual columns can be referenced in the WHERE clause of updates and deletes, but they cannot be manipulated by DML.
    Tables containing virtual columns can still be eligible for result caching.
    Functions in expressions must be deterministic at the time of table creation, but can subsequently be recompiled and made non-deterministic without invalidating the virtual column. In such cases the following steps must be taken after the function is recompiled:
    Constraint on the virtual column must be disabled and re-enabled.
    Indexes on the virtual column must be rebuilt.
    Materialized views that access the virtual column must be fully refreshed.
    The result cache must be flushed if cached queries have accessed the virtual column.
    Table statistics must be regathered.
    Virtual columns are not supported for index-organized, external, object, cluster, or temporary tables.
    The expression used in the virtual column definition has the following restrictions:
    It cannot refer to another virtual column by name.
    It can only refer to columns defined in the same table.
    If it refers to a deterministic user-defined function, it cannot be used as a partitioning key column.
    The output of the expression must be a scalar value. It cannot return an Oracle supplied datatype, a user-defined type, or LOB or LONG RAW.
    >
    Edited by: ranit B on Oct 16, 2012 11:48 PM
    Edited by: ranit B on Oct 16, 2012 11:54 PM

  • Want to use analytical function as a Virtual column

    I am wondering if I can use an analytic function as a virtual column to a table?
    The table conatins a field named BUSINESS_RUN_DATE, which becomes the EXPIRY_DATE of the on the previous record. So we want to add this value right into the table without resorting t a view.
    This is what I tried to add the column to the table:
    alter table stg_xref_test_virtual
    ADD (expiry_date2 date generated always AS (max (business_run_date) over
    *(PARTITION BY ntrl_src_sys_key order by business_run_date*
    rows between 1 preceding and 1 following))) ;
    It give me an error that GROUP BY is not allowed.
    Can someone help out>?
    Thanks,
    Ian

    From the documentation.
    [Column Expressions|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/expressions005.htm#BABIGHHI]
    A column expression, which is designated as column_expr in subsequent syntax diagrams, is a limited form of expr. A column expression can be a simple expression, compound expression, function expression, or expression list, but it can contain only the following forms of expression:* Columns of the subject table — the table being created, altered, or indexed
    * Constants (strings or numbers)
    ** Deterministic functions — either SQL built-in functions or user-defined functions*
    No other expression forms described in this chapter are valid. In addition, compound expressions using the PRIOR keyword are not supported, nor are aggregate functions.
    You can use a column expression for these purposes:
    * To create a function-based index.
    * To explicitly or implicitly define a virtual column. When you define a virtual column, the defining column_expr must refer only to columns of the subject table that have already been defined, in the current statement or in a prior statement.
    The combined components of a column expression must be deterministic. That is, the same set of input values must return the same set of output values.

  • Navigation from a view in viewcontainer to parent view of view container?

    Hi,
    I am facing the following problem while navigating between views.
    Scenario:
    View1 contains view container element
    In the view container element view2 is embeded.
    I want to navigate from view2 to view1.I have created outboundplug for view2 and inboundplug for view1.
    In view2 , when I am firing the outbound plug I am getting the following error…..
    Error:
    Application error occurred during request processing.
    Details:       com.sap.tc.webdynpro.services.sal.core.DispatcherException: The requested deployable object 'sap.com/pb' and application 'null' are not deployed on the server. Please check the used URL for typos.
    Exception id: [00144F4148CE00610000057F0000094E000446B1C8D1816D]
    am i missing anything?
    please guide me in this issue.
    Thanks
    Madhu

    Madhu,
    Creating Plugs is simple. Go thru this document. It may help you.
    http://help.sap.com/saphelp_nw04s/helpdata/en/47/52120e27ca7e48a41201a4b08d99df/frameset.htm
    Create Outbound plug from view1, inbound plug from view2 and make a link from view1 to view2.
    from view1 call outbound plug like wdThis.wdFireXXXoutplug(). Deploy & Run your application.
    Let me know, if does not work.
    Regards,
    Sridhar

  • Null in Composite Primary Key and "Primary keys must not contain null"

    Hello all.
    I'm a newbie concerning to JPA/EJB3, but I was wondering if toplinks doesn't support composite primary keys with null in some field (something perfectly right in any RDBMS).
    I used JDeveloper (I'm using Oracle 10g database and JDeveloper 10.1.3.2.) wizards to generate JPA classes and I checked out generated files (with annotations), so they should be right (by the way, other O-R mappings for my model are working right, but this one).
    I'm getting the next error:
    Exception Description: The primary key read from the row [DatabaseRecord(
         TSUBGRUPOSLDI.CD_GRUP => 01
         TSUBGRUPOSLDI.CD_SUBGRUP => null
         TSUBGRUPOSLDI.CG_POBL => 058
         TSUBGRUPOSLDI.CG_PROV => 28
         TSUBGRUPOSLDI.DSCR => Sanidad)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Compound primary key is (CD_GRUP, CD_SUBGRUP). No foreign keys, no joins (only a NamedQuery: "select o from ..."). It's the simplest case!
    I checked out that everything runs ok if there's no "null" value in CD_SUBGRUP.
    After some research (this and other forums) I'm beginning to believe that it's not supported, but not sure.
    Am I doing sth wrong? If not, what is the reason to not support this? Will it be supported in the future?
    Thanks in advance.

    Null is a special value and in many databases is not comparable to another null value (hence the isNull operator) and may pose problems when used to uniquely identify an Entity. TopLink does not support null values within a composite PK. As the nullable column is most likely not designated as a PK within your database table (many databases do not allow this) I recommend updating the Entity PKs to match that of the database.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Toplink Essentials: how can I not to auto persist computed/virtual column

    Tags: Toplink Essentials, JPA, virtual columns
    Hi All,
    This appears to be a newbie question. But I cannot get it solved.
    First, my system is Eclipse + TOPlink essentials.
    My relational db table has a computed column. It is derived from a column of the same table.
    create table WINE(
    WINE_NAME VARCHAR2(25),
    WINE_STORAGE_DATE DATE,
    VINTAGE AS (EXTRACT(YEAR FROM WINE_STORAGE_DATE))
    In my JAVA entity, I would like to map VINTAGE into a "auto-generated" field. In this way, when I update relational db table, VINTAGE won't be in the JPA generated INSERT statement, but I can query the VINTAGE into my java entity/object.
    I tried the following JPA annotation in my java entity class.
    @Entity
    public class Wine implements Serializable {
    @GeneratedValue private Integer VINTAGE;
    I can query db table -- VINTAGE flows from db table to my java object. But when I update table ( I left VINTAGE un-specified ), I get the following error:
    Internal Exception: java.sql.SQLException: ORA-54013: INSERT operation disallowed on virtual columns
    Error Code: 54013
    Call: INSERT INTO WINE(WINE_NAME, WINE_STORAGE_DATE, VINTAGE) VALUES (?, ?, ?)
         bind => PinotNoir, 2003-01-05 00:00:00.0, null
    Any suggestions on what annotation tage I should use to tell the JPA Provider not to include VINTAGE in the auto-generated INSERT statement?
    Thank you very much.
    Jing
    Edited by: user11935396 on Sep 25, 2009 1:36 PM
    Edited by: user11935396 on Sep 25, 2009 1:37 PM

    I am not sure if your annotation @GeneratedValue is proper. According to javadoc "Provides for the specification of generation strategies for the values of primary keys. The GeneratedValue annotation may be applied to a primary key property or field of an entity or mapped superclass in conjunction with the Id annotation."
    I would rather try to annotate VINTAGE as @Column(insertable=false, updatable=false)

  • Range partitioning on virtual column based on binary xmltype column

    Alright, our DBA finally got around to upgrading to 11.2.0.2. Now I'm running into another issue:
    CREATE TABLE USER.DI_D2
        ID NUMBER(19, 0) NOT NULL ,
        XML SYS.XMLTYPE ,
        PRIMARY KEY ( ID )
      XMLTYPE XML STORE AS SECUREFILE BINARY XML
      VIRTUAL COLUMNS
        ts AS (TO_TIMESTAMP(extractvalue(xml,'/d:d/c:dHeader/c:creationTime',
            'xmlns:d="http://www.example.com/m/d/schema/di"
             xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
      PARTITION BY RANGE (ts)
        PARTITION d_p2012_07 VALUES LESS THAN (TO_DATE('1-8-2012','DD-MM-YYYY')),
        PARTITION d_px VALUES LESS THAN (MAXVALUE)
      );On our old 11.2.0.1 install this command works fine (tho due to other issues 11.2.0.1 doesn't work for our search queries)
    On our 11.2.0.2 install, I get the following error:
    Error at Command Line:10 Column:37
    Error report:
    SQL Error: ORA-14513: Partitiekolom mag niet van het gegevenstype object zijn.
    14513. 00000 -  "partitioning column may not be of object datatype"
    *Cause:    Partitioning column specified by the user was an object datatype
               (object, REF, nested table, array) which is illegal.
    *Action:   Ensure that no partitioning column is an object datatype.Anyone know what's up with that? What changed between the 2 DB versions that could cause this to fail?

    Alright, seems that's just a display issue then.
    Looking in user_lobs like suggested above gives
    TABLE_NAME COLUMN_NAME SECUREFILE
    DI_D       XMLDATA     YES        I was opening the table in SQL Developer and then looking in the tab SQL (12th tab); with a XmlType table it seems to always show Basicfile even if it's actually a Securefile.
    I'd like to use the suggested xmlcast/xmlquery solution, however it doesn't seem to play well with our custom timestamp format.
    "CREATION_TIME" AS (XMLCAST(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT) AS TIMESTAMP))
    Error at Command Line:1 Column:0
    Error report:
    SQL Error: ORA-54002: In de uitdrukking van een virtuele kolom kunnen alleen zuivere functies worden opgegeven.
    "CREATION_TIME" AS (TO_TIMESTAMP(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT),'YYYY-MM-DD"T"HH24:MI:SS'))
    Error at Command Line:9 Column:45
    Error report:
    SQL Error: ORA-00932: inconsistente gegevenstypen: - verwacht, - gekregen
    00932. 00000 -  "inconsistent datatypes: expected %s got %s"
    *Cause:   
    *Action:
    "CREATION_TIME" AS (TO_TIMESTAMP(EXTRACTVALUE("OBJECT_VALUE",'/di:d/c:dHeader/c:creationTime','xmlns:di="http://www.example.com/m/d/schema/i" xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
    table "USER"."DI_D" created.

  • Finding source database table/column name for a column in a view

    Hi i need to be able to identify the original database table/column name for a column in a view.
    e.g. say i have a view like this
    create v1 as select a.name fname, b.name bname, c.name cname,......
    from u1.names a, u2.names b. u3.names c
    where .....
    Now I want to find out that the database table/column name for the fname, bname and cname columns in the view v1, which in this instance is u1.name.name, u2.names.name, u3.names.name.
    But i need to be able to do it for any view. Short of parsing the SQL is there an easy way of doing this?
    Now obviusly I can't do this for virtual columns but I will know my column is not virtual as it has an index on it.

    But i need to be able to do it for any view. Short of
    parsing the SQL is there an easy way of doing this?No, parsing the SQL is the only way. Good luck it is not something I would want to attempt.

  • When Closing the window giving error " Virtual Column not allowed"

    Hi All,
    In my main block, i have a button, on clicking which will open a new window(block) with a free text field to enter.
    I have a Save button in a new window which will save entered text fiedl and refresh the main block to see the value entered in a new block.
    But suppose, if entered something in text field and without saving if i close the window and try to exit from the form
    It is asking me to save the form or not and if i press Yes
    Then it gives me below error
    ORA-01733: virtual column not allowed here
    FRM-40508: ORACLE error: unable to INSERT record.
    If i see from Display database error' It is trying to insert the record into the view On which my new block has based( i know it is not possible).
    Any suggestion on this please?
    Thanks,
    pavan

    Pavan,
    How are you populating your block? It sounds like you are populating the block manually (eg; Looping through a cursor and assigning values to each row of your block). If this is what you are doing, then YES you will get these kinds of errors. Ideally, you should base your data block on your data (either directly on the base table or view of if you are using a query, then a FROM Clause based block).
    I'm guessing here, so would you mind posting a description of your data block(s) is/are set up?
    Craig...

Maybe you are looking for