ORA-54002 on creating virtual column

I wonder on what follows.

I'm in the middle of a migration project.

I load the data received from the source database into the staging tables.

The data in these tables must remain absolutely intact to be able to check where things have gone wrong if something is not the way we expected after migration.

Obviously, the data includes dates. Those who are in the DATE data type columns.

However, the values represent the date and time UTC.

The values are NOT timestamps with time zone, but simply date that contains the date time and something that has passed, but expressed in the date and time utc.

Now, the database target also expects that DATEs, so I seem to be home free.

However, the target database expect the passage of time to express the time zones (Europe/Amsterdam).

No problem I know how to do this.

And because I want to do a million times in the transformation before insertion in the target code (and almost certainly forget a few times) I thought: I'll add virtual columns for the staging tables that allow to calculate the local time of the date and time utc.

This way the data is intact, but the transformation code can simply use the column (virtual) replacement and does not bother with the calculations of time.

Great, I thought.

Until I tried to create the table.

CREATE TABLE utc_test

(createddate_utc DATE

createddate GENERATED DATE ALWAYS

AS (CAST (FROM_TZ (CAST (createddate_utc AS TIMESTAMP)

, "UTC".

)

At the time of the ZONE "Europe/Amsterdam".

AS DATE

)

)

VIRTUAL

);

And Oracle says:

At the time of the ZONE "Europe/Amsterdam".

*

ERROR on line 7:

ORA-54002: only pure functions can be specified in a virtual column expression

Excuse me?

Not deterministic?

Oracle is probably right, and even if it isn't yet I have to live with that.

But no matter how hard I try I can't understand why this code would not deterministic.

IMHO any form of date I put in createddate_utc, if I put the same date in here a million times I'll get the same answer a million times.

I know, FROM_TZ to the ZONE SCHEDULE will give different answers for different time zones.

But not for a same time zone.

And is this not the essence of deterministic: always the same result, given the same input?

Anyone who can teach me Oracle ;-)

My question (I may not was clear on that) was: why Oracle claims that the function is not deterministic?

Because this is not the case.

Zone information (and therefore the conversion between TZs) are governed by the zone files, see: Datetime and time zones Support Data Types.

Since these data may vary, it is not deterministic.

To solve this 'problem', you can always create a standalone function transformation of packaging and declare it deterministic, even if it is not in the strict sense.

Tags: Database

Similar Questions

  • Unable to create a table with virtual columns... Get the error ORA-12899... Suggestions please.

    Hi all

    Here is the create table script, which does not work, error ORA-12899 keep expressing. Please suggest...,.,.

    CREATE TABLE FX_TRANS
    (
    SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),
    UPSTREAM_EXECUTION_TS TIMESTAMP (9).
    LOCAL_TZ VARCHAR2 (20 BYTE),
    GMT_CONV_ENTERED_DT_TS TIMESTAMP (9) ALWAYS GENERATED IN THE FORM ("SONARDBO". "FN_CONVERT_TIMEZONE"("LOCAL_TZ","ENTERED_DT_TS")), "
    GMT_CONV_EXECUTION_DT_TS TIMESTAMP (9) ALWAYS GENERATED IN THE FORM ("SONARDBO". "FN_CONVERT_TIMEZONE"("LOCAL_TZ","UPSTREAM_EXECUTION_TS")), "
    );

    [Error] Running (5:3): ORA-12899: value too large for column 'GMT_CONV_EXECUTION_DT_TS' (actual: 11, maximum: 20)

    [Error] Performance (6:3): ORA-12899: value too large for column 'GMT_CONV_EXECUTION_DT_TS' (actual: 11, maximum: 20)


    Used fucntion Script that I use as a VIRTUAL column expression:

    CREATE OR REPLACE FUNCTION SONARDBO. FN_CONVERT_TIMEZONE
    (
    PI_LOCAL_TZ IN VARCHAR2,
    PI_DT IN TIMESTAMP
    )
    RETURNS THE TIMESTAMP
    DETERMINISTIC
    IS
    LV_TIMESTAMP TIMESTAMP;
    BEGIN
    LV_TIMESTAMP: = CASE WHEN PI_LOCAL_TZ = 'SERGEANT' THEN
    TO_TIMESTAMP (TO_CHAR)
    ((FROM_TZ)
    PI_DT,
    "Asia/Singapore")
    IN THE ZONE IS "GMT"),.
    'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
    WHEN PI_LOCAL_TZ = "GMT" THEN
    TO_TIMESTAMP (TO_CHAR)
    ((FROM_TZ)
    PI_DT,
    "GMT")
    IN THE ZONE IS "GMT"),.
    'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
    WHEN PI_LOCAL_TZ = "IS" THEN
    TO_TIMESTAMP (TO_CHAR)
    ((FROM_TZ)
    PI_DT,
    "America/New_York")
    IN THE ZONE IS "GMT"),.
    'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
    ANOTHER NULL
    END;


    RETURN LV_TIMESTAMP;
    EXCEPTION
    WHILE OTHERS THEN
    LIFT;
    END;
    /

    Thank you very much

    Arpit

    This one worked for me.

    -----------------

    drop table FX_TRANS;
    
    CREATE TABLE FX_TRANS (
       SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),
       UPSTREAM_EXECUTION_TS TIMESTAMP (9),
       LOCAL_TZ VARCHAR2 (20 BYTE),
       ENTERED_DT_TS TIMESTAMP (9),
       GMT_CONV_ENTERED_DT_TS timestamp(9)
             GENERATED ALWAYS AS
                (cast ("FN_CONVERT_TIMEZONE" ("LOCAL_TZ", "ENTERED_DT_TS") as timestamp(9))),
       GMT_CONV_EXECUTION_DT_TS timestamp(9)
             GENERATED ALWAYS AS
                (cast("FN_CONVERT_TIMEZONE" ("LOCAL_TZ", "UPSTREAM_EXECUTION_TS") as timestamp(9))));
    
    INSERT INTO fx_trans (SAGE_TRADE_TYPE,
                          UPSTREAM_EXECUTION_TS,
                          LOCAL_TZ,
                          ENTERED_DT_TS)
         VALUES ('A',
                 SYSTIMESTAMP,
                 'SGT',
                 SYSTIMESTAMP + 1 / 24);
    
    commit;
    

    ------------

    See you soon,.

    Manik.

  • ORA-00936: missing expression when adding virtual column

    I am having this error when you add virtual column am in database 11 g

    having error

    ORA-00936: lack of expression

    in select superior

    My sql is

    Employees ALTER TABLE ADD (user name (select upper (substr (first_name, 1, 1)) | initcap (last_name) user name of employees));

    http://docs.Oracle.com/CD/E11882_01/server.112/e41084/statements_3001.htm#sthref3374

    Adding a column of Table virtual: example, the following statement adds a copy of the hr.employees table a column named income , which is a combination of salary more commission. Wages and the commission are NUMBER columns, so the database creates the virtual column as a NUMBER same column if the data type is not specified in the statement:

    CREATE TABLE emp2 AS SELECT * FROM employees; ALTER TABLE emp2 ADD (income AS (salary + (salary*commission_pct)));
    

    ALTER TABLE ADD employees (AS username (upper (substr (first_name, 1, 1)) | initcap (last_name)));

    Concerning

    Etbin

  • Addition of virtual column: ORA-12899: value too large for column

    I am using Oracle 11g, OS Win7, SQL Developer

    I'm trying to add the virtual column to my test table, but get ORA-12899: value too large for column error. Here 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, I get the correct results:
    SELECT col1, (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_'))
    FROM test_reg_exp;
    Thank you.

    Yes, RP, it works if you give col2 size > = 400.

    @Northwest - could you please test the same w/o having a clause of regex in col2?
    I have a doubt about using a REGULAR expression in this case Dynamics col.

    Refer to this (might help) - http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
    Below excerpt from above link... see if that helps...
    >
    Notes and restrictions on the virtual columns include:

    The indexes defined on the virtual columns are equivalent to a function-based index.
    Virtual columns can be referenced in the updates and deletions WHERE clause, but they cannot be manipulated by DML.
    The tables containing virtual columns may still be eligible for result caching.
    Functions in expressions must be deterministic when the table is created, but can then be recompiled and non-deterministic without for as much invalidate 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.
    On the virtual column indexes must be rebuilt.
    Materialized views that access the virtual column must be fully refreshed.
    The result cache must be flushed if the virtual column acceded to the request (s).
    Statistical table must be regathered.
    The virtual columns are not supported for the organized and external object in index, 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 refer to the 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 result of the expression must be a scalar value. It cannot return that an Oracle supplied the data type, a type defined by the user, LOB or LONG RAW.
    >

    Published by: Vanessa B on October 16, 2012 23:48

    Published by: Vanessa B on October 16, 2012 23:54

  • ORA-54017: excluded from the regime of virtual columns UPDATE Operation

    Referenced to

    ORA-54017: excluded from the regime of virtual columns UPDATE Operation

    There are problems with v4.0_4.121.1.0 knew?

    Thank you

    Sorry, but after setting StoreGeneratedPattern to Computed in the EF model I have the same problem.

    Thank you

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

    Does anyone know why I get 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
    AMT for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production



    -no error without the WITH CHECK option

    SQL > INSERT INTO
    2 (SELECT
    3 location_id,
    4 city
    5 l.country_id
    6 OF country c, localities, regions r l
    7 where l.country_id = c.country_id
    8 and c.region_id = r.region_id
    9 and r.region_name = 'Asia')
    10 VALUES (5500, 'Common Wansdworth', 'UK');

    1 line of creation.

    SQL > rollback;

    Complete restoration.


    -error with WITH CHECK OPTION


    SQL > INSERT INTO
    2 (SELECT
    3 location_id,
    4 city
    5 l.country_id
    6 OF country c, localities, regions r l
    7 where l.country_id = c.country_id
    8 and c.region_id = r.region_id
    9 and r.region_name = 'Asia' WITH CHECK OPTION)
    10 VALUES (5500, 'Common Wansdworth', 'UK');
    INSERT INTO
    *
    ERROR on line 1:
    ORA-01733: virtual column not allowed here




    I was expecting

    ORA-01402: discovers the violation of where WITH CHECK OPTION clause

    for the second. Am I missing here?

    Coskan wrote:
    Randolf

    Thanks a lot for the update of this old question
    After reading the link, I think I should ignore this error and accept him as ORA-01402

    The information that you have asked me to check me do not have an understanding of the different error types.

    Coskan,

    I didn't know this is an old thread that somehow got updated by someone else.

    Regarding your question: you're right that the output of the script is not really that useful.

    I have just run on 10.2.0.4 and in general, it seems that the output of USER_UPDATABLE_COLUMNS is incorrect regarding the views of join using the WITH CHECK OPTION.

    For example although the location_id from the TEST_V_2 column appears as non-editable (probably because of the rule that "the columns used in the join expression" cannot be modified in a join view when you use the WITH CHECK OPTION) I can run successfully your insert if statement I choose a location_id less than 2000.

    It seems that summed up the difference if you join more than two tables, you'll always get the error "ORA-01733" when you try to insert in the join with the enabled OPTION CHECK view. For example to add a third table TEST_V_2 which does not change the original view, but simply joined meaning for example COUNTRIES to LOCATIONS, will show the same behavior to throw an ORA-01733, however it works fine when the omission of the WITH CHECK OPTION.

    So overall, I tend to say it is really a limitation of the implementation and it is not actually an ORA-01402 but looks like Oracle is simply trying to tell you: Amendment No. INSERT in this possible view. Updates however seem to work, at least I can find some examples of work.

    There seems to be other restrictions of implementation with the WITH CHECK OPTION in place even when the only membership as two tables, for example when trying to join the COUNTRIES and PLACES but by selecting only in PLACES and by using a filter on the COUNTRY_ID predicate fails with ORA-01733 when this predicate is applied to the COUNTRY. COUNTRY_ID but it works if this predicate is applied to PLACES. COUNTRY_ID.

    I could imagine that Oracle has quietly added some of these restrictions with each patch set due to the angle of the case/adverse reactions encountered. I saw this for other features, too.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • ORA-01733: virtual column not allowed here

    UPDATE (
    SELECT callingnumber, calledcallzone, b.callzone callzone, b.ndc
              FROM (SELECT DISTINCT SUBSTR (connectedcallingnumber, 3, 3) callingnumber,
                             calledcallzone,rownum 
                        FROM rating_temp
                       WHERE calltype = 0) a,
                   (SELECT *
                      FROM callzone cc
                     WHERE LENGTH (ndc) = 3) b
             WHERE callingnumber = ndc
             )
       SET calledcallzone = callzone-----VIRTUAL COLUMN NOT ALLOWED HERE
    Published by: user8731258 on November 29, 2010 12:45 AM

    Its simple you used SEPARATE in your first view inline. And so you cannot use columns for UPDATE.

  • Adding a virtual column derived from sdo_geometry?

    Hi guys - maybe just a quick: do I do specifically to add a virtual as column the based on a geometry object?

    SQL> select *
      2    from v$version;
    
    
    BANNER
    --------------------------------------------------------------------------------
    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 Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    
    5 rows selected.
    
    
    SQL> create table foo (id number
      2                   ,locn mdsys.sdo_geometry);
    
    
    Table created.
    
    
    SQL>
    SQL> alter table foo add (x number as (locn.sdo_point.x));
    alter table foo add (x number as (locn.sdo_point.x))
                                      *
    ERROR at line 1:
    ORA-54016: Invalid column expression was specified
    
    

    I know that in a query, the table must be qualified with an alias as below:

    don't know how to apply this to a virtual column.


    SQL> insert into foo values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL));
    
    
    1 row created.
    
    
    SQL> select *
      2    from
      3
    SQL>
    SQL>
    SQL> select f.locn.sdo_point.x
      2    from foo f;
    
    
    LOCN.SDO_POINT.X
    ----------------
          151.213376
    
    
    1 row selected.
    
    
    SQL>
    
    


    Edit: what should we do to make the display in a fixed rate code in shape with a police?

    For me it works with a user defined function:

    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0    Production
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production    
    
    SQL> create table foo (id number
      2                      ,locn mdsys.sdo_geometry);
    
    Table created.
    
    SQL> insert into foo (id, locn) values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL));
    
    1 row created.
    
    SQL> create or replace function get_geometry_x (g mdsys.sdo_geometry) return number deterministic as
      2  begin
      3  return g.sdo_point.x;
      4  end;
      5  /
    
    Function created.
    
    SQL> alter table foo add (x number as (get_geometry_x(locn)));
    
    Table altered.
    
    SQL> select x from foo;
    
             X
    ----------
    151,213376
    

    Message geändert durch hm

  • Computed in a Create table columns

    It's my create table statement:

    CREATE TABLE DTPartInv
    (partinv_partnbr VARCHAR2 (10) NOT NULL,)
    partinv_prodname VARCHAR2 (25).
    partinv_desc VARCHAR2 (25).
    partinv_manufact VARCHAR2 (25).
    partinv_instock INTEGER NOT NULL,
    partinv_category VARCHAR2 (20).
    partinv_purchdate DATE,
    partinv_loc VARCHAR2 (15).
    partinv_price NUMBER (6.2),
    partinv_vendor VARCHAR2 (20).
    partinv_reorder INTEGER NOT NULL,
    partinv_serial VARCHAR2 (20).
    partinv_flag as (case when partinv_instock < partinv_reorder then 'X' else 'o' end), calculated column
    CONSTRAINT DTPartInv_partinv_partnbr_pk
    PRIMARY KEY (partinv_partnbr)
    );

    and here's my Insert into table instructions:
    INSERT INTO DTPartInv VALUES ('XT40010E', 'TMC Inc', 2, Null, 'Exhaust' 'pipes', TO_DATE (11 April 10 ',' DD-MON-RR'), Null, 45.95, 'Oracle Auto Parts', 1, Null);
    INSERT INTO DTPartInv VALUES ('CH9260', Null, 'oil filter', 'Mechanical parts', 5, 'Fuild filters', TO_DATE (15 January 10 ',' DD-MON-RR'), Null, 20.00, "wells auto P", 2, Null);
    INSERT INTO DTPartInv VALUES ('15W40', Null, ' oil ',' sink the oil ', 20, 'Auto Fuilds', TO_DATE (February 10, 11 ',' DD-MON-RR'), Null, 10.00, "Oracle Auto Parts", 5, Null,);
    INSERT INTO DTPartInv VALUES ('C9262', Null, 'fuel filter', 'Mechanical parts', 2, 'Fuild filters', TO_DATE (October 20, 10 ',' DD-MON-RR'), Null, 35.95, 'sink Auto Parts', 1, Null);
    INSERT INTO DTPartInv VALUES ('PS7716', Null, ' Fuel/water separator', 'Parts', 4, 'Fuild filters', TO_DATE (December 9, 10 ',' DD-MON-RR'), Null, 50.00, 'sink Auto Parts', 1, Null);
    INSERT INTO DTPartInv VALUES ('800142', Null, 'Valve PPI', 'Beink pipes Inc.', 10, 'Valves', TO_DATE (June 1, 11 ',' DD-MON-RR'), Null, 20.00, 'Oracle Auto Parts', 2, Null);
    INSERT INTO DTPartInv VALUES ('TTS400', 'Clip Butt', Null, 'Beink pipes Inc.', 10, 'Valves', TO_DATE (October 31, 11 ',' DD-MON-RR'), Null, 15.95, 'Oracle Auto Parts', 2, Null);
    INSERT INTO DTPartInv VALUES ('TBA400', 'Clamp Lap', Null, 'Beink pipes Inc.', 10, 'Valves', TO_DATE (November 10, 11 ',' DD-MON-RR'), Null, 30.00, 'Oracle Auto Parts', 2, Null);
    INSERT INTO DTPartInv VALUES (Null, mechanical parts "Brake pads',"Mechanical CostVB", 5,", 'SC16650', TO_DATE (May 15, 11 ',' DD-MON-RR'), Null, 60.00, 'Adosql Auto Parts', 1, Null);
    INSERT INTO DTPartInv VALUES ('OB46613', Null, 'emergency door latch", 'Mechanical CostVB', 3, 'Mechanical parts', TO_DATE ('01 - sept.-11 ',' DD-MON-RR'), Null, 45.95, 'Adosql Auto Parts', 1, Null);

    And this is a sample of the error, I can test:
    INSERT INTO DTPartInv VALUES ('XT40010E', 'TMC Inc', 2, Null, 'Exhaust' 'pipes', TO_DATE (11 April 10 ',' DD-MON-RR'), Null, 45.95, 'Oracle Auto Parts', 1, Null)
    ERROR on line 1:
    ORA-00947: not enough values

    I need to understand what it is that I'm missing here. partinv_flag is supposed to be calculated according to partinv_instock and partinv_reorder.

    Hello

    Review the syntax for virtual columns in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e26088/statements_7002.htm#sthref5146

    You want something like this (showing only the relevant columns):

    CREATE TABLE DTPartInv
    (
         partinv_instock          INTEGER          NOT NULL
    ,     partinv_reorder          INTEGER          NOT NULL
    ,     partinv_flag           VARCHAR2 (1)      AS ( CASE
                                            WHEN  partinv_instock < partinv_reorder
                                           THEN 'X'
                                              ELSE 'O'
                                        END
                                     )
    );
    
    INSERT INTO DTPartInv (partinv_instock, partinv_reorder) VALUES (100, 100);
    

    Announcing the column names until the VALUES of Word key is a good idea in any case, and it is needed when you have virtual columns.

  • Virtual column NOT NULL

    Hello dear colleagues,

    Anyone able to replicate this?
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Create a small table:
    SQL> create table t(x number not null);
    
    Table created.
    Now, add a virtual column, using decode:
    SQL> alter table t add (y varchar2(1) as (decode(x, 1, 'A', 'B')) not null);
    
    Table altered.
    'The same', using case column
    SQL> alter table t add (z varchar2(1) as (case x when 1 then 'A' else 'B' end));
    
    Table altered.
    Only it wasn't the same, I wanted to NOT NULL.
    If I do, I get:
    SQL> alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null);
    alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null)
                                                                     *
    ERROR at line 1:
    ORA-03113: EOF pÕ kommunikationskanal
    Process ID: 3400
    Session ID: 140 Serial number: 213
    This is consistent with this database on my laptop.


    Concerning
    Peter

    Looks like you have perhaps hit Bug Bug 9277263: ORA-07445 [ATBNUL () + 299] WHEN ADDING a CONSTRAINT INLINE ON a VIRTUAL COLUMN

  • Interval partitioning using the key of the virtual column

    Hi guys

    I have a series of tables that I propose to the partition.

    Each table has a year and a period (equivalent to a month) and I intend using those as my partition keys - year as the partition and the period as the subpartition.

    The distribution will be actually:

    2015

    001

    002

    ...

    012

    2016

    001

    002

    ...

    012

    etc...

    I would use range partitioning for the year, because it would make the maintenance of the partition a breeze.  Only one problem - the field is of type varchar, and is not modifiable as its legacy applications that have become bigger than Ben Hurr and more tangled than a Ben Hurr size flat spaghetti.

    It is hence the idea of virtual column between in game - I could create a virtual column in these tables to convert the field to digital and then partition on it instead.

    My question-if the year of origin varchar column is included in the where clause of a query, is the optimizer based on CSSTidy smart enough to realize that the virtual column used for the partition key is based on this column and use pruning of partition to improve performance?  Or queries must refer to the virtual column to make it work?  Also, the virtual column should be indexed to make it work?

    Thanks in advance.


    Simon

    orclz >

    orclz > create table pt (v1 varchar2 (1) c1 as (to_number (v1)), number of c2)

    2 partition by range (c1) interval (1)

    subpartition by hash (c2) subpartitions 4 3

    4 (partition p1 values less than (1))

    5.

    Table created.

    orclz > set autot on explain

    orclz > select * PT where v1 = '0';

    no selected line

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 711571056

    --------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    --------------------------------------------------------------------------------------------

    |  0 | SELECT STATEMENT |      |    82.  2296 |    29 (0) | 00:00:01 |      |      |

    |  1.  RANGE OF PARTITION ALL THE |      |    82.  2296 |    29 (0) | 00:00:01 |    1. 1048575.

    |  2.  HASH PARTITION ALL |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    |*  3 |    TABLE ACCESS FULL | PT |    82.  2296 |    29 (0) | 00:00:01 |    1. 1048575.

    --------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - filter ("V1" = '0')

    orclz > select * PT where c1 = 0;

    no selected line

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 1726115854

    -----------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    -----------------------------------------------------------------------------------------------

    |  0 | SELECT STATEMENT |      |    82.  2296 |    29 (0) | 00:00:01 |      |      |

    |  1.  RANGE OF SINGLE PARTITION |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    1.

    |  2.  HASH PARTITION ALL |      |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    |*  3 |    TABLE ACCESS FULL | PT |    82.  2296 |    29 (0) | 00:00:01 |    1.    4.

    -----------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - filter ("C1" = 0)

    --

    John Watson

    Oracle Certified Master s/n

  • ORA-02256: number of referencing columns must match the referenced column

    The following script produces

    ORA-02256: number of referencing columns must match the referenced columns, can't think of any reason, someone has an idea?

    Please help, I am stuck on an assignment...!

    Capture.PNG

    drop table qualitycheck;

    drop table distribution;

    Manager to move table;

    CREATE THE TABLE MANAGER)

    MgrID number (4),

    mfirstname varchar2 (30),

    msurname varchar2 (30),

    Primary key (mgrid)

    );

    CREATE DISTRIBUTION TABLE)

    ProdID number (4) CONSTRAINT NN_PRODUCT_prodid NOT NULL,

    MgrID number (4) CONSTRAINT NN_MANAGER_mgrid NOT NULL,

    Primary key (prodid, mgrid)

    CONSTRAINT FK_ALLOCATION_MANAGER_mgrid Foreign Key (mgrid) REFERENCE MANAGER,

    CONSTRAINT FK_ALLOCATION_PRODUCT_prodid Foreign Key (prodid) REFERENCES PRODUCED

    );

    CREATE TABLE QUALITYCHECK)

    ProdID number (4) CONSTRAINT NN_ALLOCATION_prodid NOT NULL,

    MgrID number (4) CONSTRAINT NN_ALLOCATION_mgrid NOT NULL,

    number of weekno (2),

    Partition number (1),

    Primary key (prodid, mgrid, weekno)

    CONSTRAINT FK_QUALITYCHECK_PRODUCT_prodid Foreign Key (prodid) ATTRIBUTION of REFERENCES,

    CONSTRAINT FK_QUALITYCHECK_MANAGER_mgrid Foreign Key (mgrid) ASSIGNMENT of REFERENCES

    );

    Hello

    Reason is the primary key of the table that is assigned prodid, mgrid, but you try to create the foreign key columns separately.

    Try which follows and this should work:

    CREATE TABLE QUALITYCHECK (
      prodid number (4) CONSTRAINT NN_ALLOCATION_prodid NOT NULL,
      mgrid number (4) CONSTRAINT NN_ALLOCATION_mgrid NOT NULL,
      weekno number (2),
      score number (1),
    
    Primary Key (prodid,mgrid,weekno),
    
    CONSTRAINT FK_QUALITYCHECK_PRODUCT_FK Foreign Key (prodid, mgrid) REFERENCES ALLOCATION
    );
    
  • json_list to varchar/string to use in the virtual column

    Hello Experts,

    Environment:

    Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production

    PL/SQL Release 12.1.0.2.0 - Production

    I have the following function that returns JSON_LIST.

    {code}

    CREATE OR REPLACE FUNCTION GENERATE_JSON (STRING2CONVERT IN VARCHAR2)

    RETURN JSON_LIST

    DETERMINISTIC

    IS

    RET json_list;

    V_ERROR VARCHAR2 (31000);

    BEGIN

    RET: = json_dyn.executeList (STRING2CONVERT);

    RET. Print;

    RETURN RET;

    EXCEPTION WHEN OTHERS THEN

    V_ERROR: = SQLERRM;

    RETURNS A NULL VALUE.

    END;

    -test the query see the output in the output of DBMS

    SELECT GENERATE_JSON (' select ' |) Chr (39) | ' AJ' | Chr (39) |' like c_name,' | Chr (39) | ' BOY ' | Chr (39): ' c_type, like '

    || Chr (39) | ' HUMAN '. Chr (39): ' as c_category,' | Chr (39) | ' TEST SUBJECT ' | Chr (39) | 'as c_desc from dual')

    FROM DUAL;


    {code}


    The SQL query above in the DBMS output output

    [{

    "C_NAME": "AJ."

    "C_TYPE": "BOY."

    "C_CATEGORY": "HUMAN."

    'C_DESC': 'GUINEA PIG '.

    }]


    Question: How can I have it return the same structure of String (varchar).


    Why would I want to convert JSON_LIST to string?

    So that I can use this call to service as part of a virtual column in a table to store Json and have a constraint to enforce structureof Json.


    If this is not the right way?

    Kindly share how I can take a few columns in the same table, convert to json format and store in a virtual column in the same table and enforce the Json structure?


    Thank you

    AJ



    with

    data in the form of

    (select q'~ select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as the double c_desc ~' source)

    of the double

    ),

    Converter (SRC, res, Step) as

    (select regexp_replace (ltrim (upper (substr (source, 1, instr (upper (source), "FROM") - 1)), "SELECT"), '\s+AS\s+',': ') |) ',', null, 1

    from the data

    Union of all the

    Select substr (src, instr(src,',') + 1)

    '"' || substr (substr (SRC, 1, InStr (CBC, ',') - 1), instr (substr (src, 1, instr (CBC, ',') - 1),': ') + 1) | '" : ' ||

    Replace (substr (substr (SRC, 1, InStr (CBC, ',') - 1), 1, instr (substr (src, 1, instr (CBC, ',') - 1),': ')-1), "','" ' "),

    Step + 1

    converter

    where the CBC is not null

    )

    Select the source'[{' | listagg(res,',') Group (order by step) |}] '] "converted

    data converter

    SOURCE CONVERTED
    Select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as double c_desc [{'C_NAME': 'AJ', 'C_TYPE': 'BOY', 'C_CATEGORY': 'HUMAN', 'C_DESC': 'GUINEA PIG'}]

    Concerning

    Etbin

  • ORA-01747: invalid user.table.column... on the REPLACEMENT notice

    Oracle 11g Release 2

    I run an UPDATE statement. In the 'set' I am trying to update a column by using a subquery on the right side. REPLACE the statement Gets the error ORA-01747: specification of invalid column, table.column, or user.table.column.

    create table tab1
    ( file_id   number  ,
      record_id number  ,
      part_type_id number ,
      part_number  number ,
      positon_id   number ,
      notes        varchar2(255) ,
      mapped       varchar2(1) default 'N'
    )
    /
    insert into tab1 values(1,1,123,777,1,'NEW|A/C COMPRESSOR KIT','N') ;
    insert into tab1 values(1,2,123,777,2,'REMAN|A/C LINE','N') ;
    insert into tab1 values(1,3,123,777,2,'TEST NOTE','N') ;
    commit;
    select * from tab1;
    /*
      FILE_ID  RECORD_ID PART_TYPE_ID PART_NUMBER POSITON_ID NOTES                     MAPPED
    --------- ---------- ------------ ----------- ---------- ------------------------- ------
            1          1          123         777          1 NEW|A/C COMPRESSOR KIT         N
            1          2          123         777          2 REMAN|A/C LINE                 N
            1          3          123         777          1 TEST NOTE                      N
    */
    
    
    DECLARE
       v_note2 varchar2(255) := 'NEW' ;
    BEGIN
    UPDATE tab1 t 
             SET 
              , t.notes =  (select REPLACE(t.notes,v_note2,null) 
                            from dual )
          WHERE t.file_id = 1         -- value comes from another source
          AND   t.part_type_id = 123  -- value comes from another source
          AND   t.part_number = 777   -- value comes from another source
          AND   t.position_id = 1  ;  -- value comes from another source
    END ;
    /
    
    ERROR at line 3:
    ORA-01747: invalid user.table.column, table.column, or column specification
    

    Here's what the end result should be:

      FILE_ID  RECORD_ID PART_TYPE_ID PART_NUMBER POSITON_ID NOTES                     MAPPED
    --------- ---------- ------------ ----------- ---------- ------------------------- ------
            1          1          123         777          1 |A/C COMPRESSOR KIT            N
            1          2          123         777          2 REMAN|A/C LINE                 N
            1          3          123         777          1 TEST NOTE                      N
    

    Hello

    orclrunner wrote:

    Oracle 11g Release 2

    I run an UPDATE statement. In the 'set' I am trying to update a column by using a subquery on the right side. REPLACE the statement Gets the error ORA-01747: specification of invalid column, table.column, or user.table.column.

    1. create table tab1
    2. (file_id number,
    3. number of record_id,
    4. number of part_type_id
    5. number of PART_NUMBER,
    6. number of positon_id
    7. Notes VARCHAR2 (255),
    8. mapped by default varchar2 (1) ' don't
    9. )
    10. /
    11. insert into tab1 values (1,1,123,777,1,'NEW |) Kit COMPRESSOR / it, ' don't);
    12. insert into tab1 values (1,2,123,777,2,'REMAN |) A/C LINE ',' don't);
    13. insert into tab1 values (1,3,123,777,2, 'NOTE of TEST', ' don't);
    14. commit;
    15. Select * from tab1;
    16. /*
    17. FILE_ID RECORD_ID PART_TYPE_ID PART_NUMBER POSITON_ID MAPPED NOTES
    18. --------- ---------- ------------ ----------- ---------- ------------------------- ------
    19. 1 1 123 777 1 NEW | A/C COMPRESSOR KIT N
    20. 1 2 123 777 2 REMAN | A/C LINE N
    21. 1 3 123 777 1 TEST NOTES N
    22. */
    23. DECLARE
    24. VARCHAR2 (255) v_note2: = "NEW";
    25. BEGIN
    26. Tab1 t UPDATE
    27. SET
    28. t.notes = (select REPLACE(t.notes,v_note2,null)
    29. the double)
    30. WHERE t.file_id = 1 - value comes from another source
    31. AND t.part_type_id = 123 - value comes from another source
    32. AND t.part_number = 777 - value comes from another source
    33. AND t.position_id = 1;  -value comes from another source
    34. END;
    35. /
    36. ERROR at line 3:
    37. ORA-01747: invalid column, table.column, or user.table.column specification

    Here's what the end result should be:

    1. FILE_ID RECORD_ID PART_TYPE_ID PART_NUMBER POSITON_ID MAPPED NOTES
    2. --------- ---------- ------------ ----------- ---------- ------------------------- ------
    3. 1          1          123         777          1 | A/C COMPRESSOR KIT N
    4. 1 2 123 777 2 REMAN | A/C LINE N
    5. 1 3 123 777 1 TEST NOTES N

    The comma after SET is a syntax error.

    Why you use double?  Why not just

    UPDATE tab1

    SET of notes = REPLACE (notes, v_note2)

    WHERE file_id = 1

    ...

    ?

  • I want to change the table with the expression of dangerousness of the virtual columns with her, need advice

    Hi all

    Here is the structure of the table with two expression of virtual columns associated highlighted, now I want to delete these expressions with virtual columns (but must keep my VIRTUAL columns as it is).

    Is it possible the alter or I need to raise the table, make a new structure and copy content back to newly structured table... Pleae help!

    CREATE TABLE TEST_COL)

    SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),

    LOCAL_TZ VARCHAR2 (20 BYTE),

    ACE GMT_CONV_ENTERED_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, ENTERED_DT_TS)) VIRTUAL,.

    ACE GMT_CONV_EXECUTION_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, UPSTREAM_EXECUTION_TS)) VIRTUAL,.

    EOD_IND VARCHAR2 (10 BYTE)

    );

    Thank you very much

    Arpit

    Try this

    ALTER table test_col change gmt_conv_entered_dt_ts (0) virtual;

    ALTER table test_col change gmt_conv_execution_dt_ts (1) virtual;

Maybe you are looking for

  • Favorite html files seem to be missing

    I recently had a problem with my last computer where it stopped turning on. I have determined that the best course of action was to buy a new computer. My old computer was working Firefox 15.0.1 on Windows XP. My new computer has a new download of Fi

  • Can't sideload apps

    Hello. I am desperately trying to sideload app on my iPhone. But I have failed so far. It is said without found of code signing identities. I connected my Xcode. Whenever I try hurt all my phone, it comes up with this message: When I click on 'Hard p

  • Satellite A100: CD/DVD drive does not appear in the Manager of peripherals and BIOS

    The CD/DVD drive does not appear in the window manager and I can't incert CDThe BIOS displays "none" instead of "optical device". This means that the CD device is dead?

  • error-200428

    Hello I'm trying to run a program that records temperatures, but I'm having the following problem: The program as a vi works he recorded temperatures and stores all data as expected.  Also, if I run the executable on the same pc that created the exe

  • Overscan disabled when using an HDMI cable

    Then for a while now, I use my laptop computer while it is plugged into my TV. But the parts of the screen are cut (top, left, right and bottom, which makes no sense since there is no reason to cut the sides) I've seen guides tell you how to disable