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.

Similar Messages

  • Calculate percentage column based on 2 other columns

    I have 2 fact colums. Those two columns are column_a=count distinct of all records and
    column_b = count distinct of subset of records based on specific condition.
    I am trying to get column_3 as = (column_b/column_a )* 100
    These 2 columns comes from same physical tables but two different logical tables (I have different where condition for each)
    Result is correct (100) when column_a = column_b however I am getting 0 when they are different
    col_a col_b Percent
    8 7 0 why not 87.5
    1 1 100
    27 23 0 why not 85.2

    Hello,
    Check your datatypes in your phyiscal layer, I've found if they are INT then %'s tend to get rounded to whole numbers.
    Try setting them to float and report back if it works (or not !)
    Cheers
    Alastair

  • Can not compute totals on a column based on a summary column

    Hi. I'm new in Discoverer.
    I have created a worksheet based on the following query:
    SELECT O101158.COD_HACIENDA, O101158.NOMBRE, O101266.DESC_UNIDAD, SUM(( NVL(O101501.PESO_NETO,0)/1000 ))
    FROM ASISTEN.SAT_HACIENDAS O101158, ASISTEN.SAT_UNIDADES O101266, ROMANA."BOLETO_CA#A" O101501
    WHERE ( ( O101158.COD_UNIDAD_OPER = O101266.COD_UNIDAD ) AND ( O101501.COD_HACIENDA = O101158.COD_HACIENDA ) ) AND ( O101501.ZAFRA = '2004-2005' )
    GROUP BY O101158.COD_HACIENDA, O101158.NOMBRE, O101266.DESC_UNIDAD
    ORDER BY O101266.DESC_UNIDAD ASC
    The expression SUM(( NVL(O101501.PESO_NETO,0)/1000 )) is defined in Discoverer as a calculated item.
    I have created a total on the sum expression. The idea is to have it compute at the "DESC_UNIDAD".
    The problem is that only the label "Sum" is printed at the right level. No total is calculated.
    Is this a restriction on totals based on aggregation or am i missing somthing here?
    Best regards, Luis ...!

    Hi Luis
    There have been a number of questions concerning summations of totals in recent weeks.
    Take a look at these threads:
    Cell sum not working
    Calculation shows Blank or NULL in Discoverer Viewer but not in Dis.Desktop
    Do either of these help?
    Best wishes
    Michael

  • View with columns based on function - problem with query

    Hi,
    I'm using Oracle 9i;
    I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
    The function takes ID as the first argument and name of the column to determine which value to return as the second one.
    Here is a sample of such function (simplified):
    FUNCTION my_function
    (in_id IN NUMBER, in_col_name IN VARCHAR2)
    RETURN VARCHAR2
    IS
    c_name VARCHAR2(100);
    c_last_name VARCHAR2(100);
    BEGIN
    SELECT T.NAME, T.LAST_NAME
    INTO c_name, c_last_name
    FROM TABLE_1 T, TABLE_2 Z
    WHERE T.PK = Z.FK
    AND Z.ID = in_id;
    IF in_col_name = 'NAME' THEN
    RETURN c_name;
    ELSIF in_col_name = 'LAST_NAME' THEN
    RETURN c_last_name;
    END IF;
    END;
    For simplicty I've restricted the number of columns.
    CREATE OR REPLACE VIEW my_view
    (ID, NAME, LAST_NAME)
    AS
    SELECT
    T.ID ID
    ,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
    ,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
    FROM TABLE T;
    There is no problem with query:
    SELECT * FROM my_view;
    The problem arises when I query the view (regardles of '=' or 'LIKE'):
    SELECT * FROM my_view
    WHERE name LIKE '%some_part_of_name%'
    The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
    I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
    for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
    I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
    Help needed.
    Greetings.

    The problem is more complicated than the solutions provided here.
    The reason why I'm using the function is this:
    the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
    Here are real DDLs:
    View:
    CREATE OR REPLACE VIEW V_DOK_ARCH
    (ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
    DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
    NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
    DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
    IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
    AS
    SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
    Z.ID_ZDAR ID_ZDAR
    , Z.TYP TYP
    , Z.STAN STAN
    , Z.DATE_CREATED DATE_CREATED
    , Z.CREATED_BY CREATED_BY
    , Z.DATE_MODIFIED DATE_MODIFIED
    , Z.MODIFIED_BY MODIFIED_BY
    , Z.SPRA_ID_SPRA SPRA_ID_SPRA
    , Z.PODM_ID_PODM PODM_ID_PODM
    , Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
    , Z.NR_WFS NR_WFS
    , Z.WFS_NR_INTER WFS_NR_INTER
    , Z.UWAGI_OPER UWAGI_OPER
    , Z.FUNDUSZ FUNDUSZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
    , F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
    , CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
    FROM T_ZDARZENIA Z
    WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
    and functions:
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN VARCHAR2
    IS
    c_numer           T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
    c_rodzaj           T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
    c_typ_przy           T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
    c_typ_ubez           T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
    c_nazwisko           T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
    c_imie                T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
    c_imie_ojca      T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
    c_nazwa_firmy      T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
    c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
    c_jest                VARCHAR2(1) := 'T';
    c EXCEPTION;
    BEGIN
    --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
    BEGIN
    SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
    INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
         INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
              INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                   INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                        INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                             INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                                  INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
                                       INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                            INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                                 INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
                                                           NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    --raise c;
    IF WE_KOLUMNA = 'NUMER' THEN
    RETURN c_numer;
    ELSIF WE_KOLUMNA = 'RODZAJ' THEN
    RETURN c_rodzaj;
    ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
    RETURN c_typ_przy;
    ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
    RETURN c_typ_ubez;
    ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
    RETURN c_nazwisko;
    ELSIF WE_KOLUMNA = 'IMIE' THEN
    RETURN c_imie;
    ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
    RETURN c_imie_ojca;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
    RETURN c_nazwa_firmy;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
    RETURN c_nazwa_firmy_skr;
    ELSIF WE_KOLUMNA = 'JEST' THEN
    RETURN c_jest;
    END IF;
    END;
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN DATE
    IS
    d_data DATE;
    BEGIN
    BEGIN
    SELECT p.DATA_PODPISANIA
    INTO d_data
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.DATA_PODPISANIA
         INTO d_data
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL DATA_PODPISANIA
              INTO d_data
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                   INTO d_data
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                        INTO d_data
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                             INTO d_data
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                                  INTO d_data
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                       INTO d_data
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                            INTO d_data
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL DATA_PODPISANIA
                                                 INTO d_data
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           d_data := NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
    RETURN d_data;
    END IF;
    END;

  • How to insert into date column based on other columns?

    Hi
    I have four columns in a table called game named as
    R_Day - Type - Number
    R_Month - Type - Number
    R_Year - Type - Number
    R_Date - Type - Date
    I have around 1000 records and i want to fill R_Date column based on the data in the R_Day,R_Month,R_Year.
    How to write a query to fill the R_Date column based on other three columns.
    Thanks
    srinivas

    select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    dt from (select 23 R_Day,07 R_Month,2007 R_Year from
    dual);
    Hi,
    Update <Table Name> set R_Date=select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    from <Table Name>
    Regds.
    Nirmal
    SQL>  select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007
            21         11       2007
    SQL> update test
      2  set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
      3  from test;
    set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> update test
      2  set r_date = to_date(r_day||'-'||r_month||'-'||r_year,'dd-mm-yyyy');
    2 rows updated.
    SQL> select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007 01-JAN-07
            21         11       2007 21-NOV-07
    NB:Please test before posting..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to create new calculated column based on filtered columns?

    Dear All,
    I'm using Oracle Analysis.
    I have two column, each one have different formula.
    My Formula based on filter.
    Column1
    FILTER("DW"."SUM_PLAN_MONTH_AMOUNT" USING ("DW"."PLAN_YEAR" BETWEEN YEAR(DATE'@{P_BEGIN_DATE}') and YEAR(DATE'@{P_END_DATE}')))Column2
    FILTER("PAYMENTS"."SUM_PAY_AMOUNT" / 1000 USING ("PAYMENTS"."PAY_DATE_PAID" BETWEEN DATE'@{P_BEGIN_DATE}' AND DATE'@{P_END_DATE}'))How to add new calculated column based on those two column?
    For example:
    Column1 | Column2 | NewColumn
    5 | 10 | 10 / 5 * 100
    7 | 12 | 12 / 7 * 100
    Regards,
    Eba
    Edited by: Erdenebayar on Apr 19, 2012 1:42 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:37 PM

    Hello MK,
    I have a tried following formula. It is working, but result is not filtered.
    I filtered "PAYMENTS"."SUM_PAY_AMOUNT" and "DW"."SUM_PLAN_MONTH_AMOUNT" columns.
    "PAYMENTS"."SUM_PAY_AMOUNT" / "DW"."SUM_PLAN_MONTH_AMOUNT" * 100Can you share me some tutorial?
    BR,
    Eba
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM

  • What is default size of XMLType column?

    I have a table with 1 raw type and 1 XMLType column. In the XMLType column I am inserting following XML,
    <ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus">
    <status>
    <statusCode>990</statusCode>
    <statusDateclass="sql-date">2010-01-19</statusDate>
    <userId>OcaNimsAcf</userId>
    <comment>DocumentnotinNIMS</comment>
    </status>
    <status>
    <statusCode>990</statusCode>
    <statusDateclass="sql-date">2010-01-19</statusDate>
    <userId>OcaNimsAcf</userId>
    <comment>DocumentnotinNIMS</comment>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-29</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-29</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-28</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-28</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-27</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-26</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-25</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>306</statusCode>
    <statusDateclass="sql-date">2008-04-21</statusDate>
    <userId>u0075970</userId>
    </status>
    <status>
    <statusCode>301</statusCode>
    <statusDateclass="sql-date">2008-02-05</statusDate>
    <userId>DMS_WORKFLOW</userId>
    <comment></comment>
    </status>
    <status>
    <statusCode>990</statusCode>
    <statusDateclass="sql-date">2010-01-17</statusDate>
    <userId>OcaNimsAcf</userId>
    <comment>Comparedfornimsacf</comment>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-09-16</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-29</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-29</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-28</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-28</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-27</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-26</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-25</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-22</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-21</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>501</statusCode>
    <statusDateclass="sql-date">2008-08-20</statusDate>
    <userId>oca_scheduled_job</userId>
    </status>
    <status>
    <statusCode>306</statusCode>
    <statusDateclass="sql-date">2008-04-21</statusDate>
    <userId>u0075970</userId>
    </status>
    <status>
    <statusCode>301</statusCode>
    <statusDateclass="sql-date">2008-02-05</statusDate>
    <userId>DMS_WORKFLOW</userId>
    <comment></comment>
    </status>
    </ocaStatus>
    The xml is very long. For inserting into the table I am using xmlparse() function to get XMLType.
    While doing this I am getting ORA-01704: string literal too long error. It says can accommodate at the most 4000 characters.
    I guess XMLType is stored as a CLOB by default.So it should allow more than 4000 characters.
    How can I store xml with more than 4000 characters.
    Thanks.

    XMLParse is a SQL function, so you can't use a string literal longer than 4000 chars.
    Instead, you may declare a PL/SQL VARCHAR2 variable, which can hold up to 32k characters, and then use the XMLType constructor :
    DECLARE
    xmlstr VARCHAR2(32767) := '<xml string here>';
    xmldoc xmltype;
    BEGIN
    xmldoc := xmltype(xmlstr);
    INSERT INTO your_table(xml_data) VALUES(xmldoc);
    END;For strings longer than 32k, you'll probably have to load it from a file.

  • How to migrate Sybase 12 TEXT column to Oracle XMLType column

    The Migration Workbench does not appear to support mapping a Sybase TEXT column to an Oracle XMLType column. What is the best way to workaround this limitation?
    - Ron

    CLOB?

  • Range partition by a virtual column derived from XMLTYPE

    I want to create table and partition it by interval partion (range partition) on a virtual column which is derived from XMLTYPE i get ora-14513 error.
    create table dicom_archive_virtual
    id integer not null primary key,
    parent_id integer, -- where this image is created from
    dcm_filename varchar2(60), -- DICOM image file name from import
    description varchar2(100), -- description of the image
    dicom orddicom, -- DICOM data
    image ordimage, -- DICOM data in JPEG format
    thumb ordimage, -- DICOM data in JPEG thumbnail
    metadata xmltype, -- user customized metadata
    isAnonymous integer, -- accessible flag for the research role.
    study_date date as
    (to_date(substr(extractValue(metadata,'//DATE/text()'),1,10),'yyyy-mm-dd')) virtual)
    PARTITION BY RANGE (study_date)
    INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'))
    ( PARTITION p_2005 VALUES LESS THAN (TO_DATE('1-1-2006', 'DD-MM-YYYY')),
    PARTITION p_2006 VALUES LESS THAN (TO_DATE('1-1-2007', 'DD-MM-YYYY')),
    PARTITION p_2007 VALUES LESS THAN (TO_DATE('1-1-2008', 'DD-MM-YYYY'))
    Study_date is a virtual colum which is derived from the column metadata which is of type XMLTYPE,so when i partition on this virtual column i get the follwoing error
    SQL Error: ORA-14513: partitioning column may not be of object datatype
    So i want to know whether this is not possible or there is any other alternative to achieve this.

    I want to create table and partition it by interval partion (range partition) on a virtual column which is derived from XMLTYPE Congratulations on trying to fit as many cutting edge techniques into a single line as possible.
    So i want to know whether this is not possible ...The error message is pretty unequivocal.
    ...or there is any other alternative to achieve this.What you could try is materializing the virtual column, i.e. adding an actual date column which you populate with that code in the insert and update triggers. Inelegant but then complexity often is.
    Cheers, APC
    blog : http://radiofreetooting.blogspot.com

  • Virtual column based partitioning

    Hi,
    we have a non-partitioned table in a production database and wish to partition it based on an expression. Since we are on 11.2 the first thing that comes to mind is virtual column based partitioning. The "problem" is that in order to partition by a virtual column, you have to create one, and adding a new column to a table could break any application that doesn't reference the existing columns by name, e.g. "SELECT *" or. "INSERT INTO table VALUES(....)".
    My question is: is it possible to somehow specify the expression on which to partition directly in the "partition by" clause rather than specifying it as a virtual column definition?
    Example:
    Instead of this..
    SQL> create table test (
      2    id             number not null,
      3    content        varchar2(10),
      4    record_type    varchar2(1) generated always as (case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end) virtual
      5  )
      6  partition by list(record_type)
      7  (
      8    partition partA values ('A'),
      9    partition partB values ('B')
    10  );
    Table created...I'd like to use something like this:
    SQL> create table test (
      2    id             number not null,
      3    content        varchar2(10)
      4  )
      5  partition by list((case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end))
      6  (
      7    partition partA values ('A'),
      8    partition partB values ('B')
      9  );
    partition by list((case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end))
    ERROR at line 5:
    ORA-00904: : invalid identifierThank you in advance for any answers.
    Regards,
    Jure

    adding a new column to a table could break any application that doesn't reference the existing columns by name, e.g. "SELECT *" or. "INSERT INTO table VALUES(....)". "Ok, i got it. You mean, in application you are using select * from yourtable; and those data is being used by a datagrid or any control, then where that application will show / handle the new column data right ?
    Yes, thats why DBA and developers do SDLC (Software Development Life Cycle); that our table will be looks like this, these will be columns, these will be their data types, these will be followed in naming convention, privileges, indexes, storage parameters, constraints, dependent objects etc. Now after creating the table, you found a need to add a column, it means there was some lapses happened at the design time/phase or business requirements are newly defined.
    So, as far as concerned of select * ... ; you have to change in the application by :
    select col1, col2, new_col from your table... (as per order of your datagrid control columns). There is no other solution, you have to change in application code at every place where you have used select * and if those statements are being merged / deals into a control)
    New column addition will hamper only at select * from... not with any INSERT/UPDATE/DELETE, because if they are running fine it means, they have well written column references. For DMLs you need not worry so far.
    By the way, what is your technology for application ? I have worked on couple of applications in ASP.NET with using datagrid which auto add/removes the columns in itself as per cursor result (not rememberring the exact property of it though)
    Regards
    Girish Sharma

  • How to Implement 30 days Range Partitioning with Date column. Not Interval

    Hi,
    I am using the db:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit
    Current table structure is:
    CREATE TABLE A
    a NUMBER,
    CreationDate DATE
    PARTITION BY RANGE (CreationDate)
    INTERVAL ( NUMTODSINTERVAL (30, 'DAY') )
    (PARTITION P_FIRST
    VALUES LESS THAN (TIMESTAMP ' 2001-01-01 00:00:00'))
    How can I define virtual column based partitioning with RANGE partitioning without using INTERVAL partitioning.
    And that is with Intervals of 30 days.
    For monthly I am trying as
    CREATE TABLE A
    a NUMBER,
    CreationDate DATE,
    monthly_interval date as (to_char(CreationDate,'MM-YYYY')) VIRTUAL
    PARTITION BY RANGE (monthly_interval)
    partition p_AUG12 values less than (to_date('08-2012','mm-yyyy')),
    partition p_SEP12 values less than (to_date('09-2012','mm-yyyy')),
    partition p_OCT12 values less than (to_date('10-2012','mm-yyyy'))
    Enable ROw Movement
    BUT CAN'T INSERT the data even for that:
    Insert into a (a, CreationDate)
    Values (1, '12-10-2012')
    Insert into a (a, CreationDate)
    Values (1, '12-10-2012')
    Please suggest..

    Hi rp,
    Interval Partitioned to Range. Created Daily Partitions from Monthly Part. got complicated so I am posting here.
    Basically,
    I know Interval Partitioning is a kind of Range partitioning. But explicitly for Interval Partitioned tables XML Indexes are not allowed as discussed here:
    XMLIndexes on an Interval Partitioned Table??
    I can do monthly partitions as :
    CREATE TABLE A
    a NUMBER,
    CreationDate DATE,
    monthly_interval varchar2(8) as (to_char(CreationDate,'MM-YYYY')) VIRTUAL
    PARTITION BY RANGE (monthly_interval)
    partition p_AUG12 values less than ('09-2012'),
    partition p_SEP12 values less than ('10-2012'),
    partition p_OCT12 values less than ('11-2012')
    ) Enable ROw Movement
    Insert into a (a, CreationDate)
    Values (1, '12-SEP-2012')
    Insert into a (a, CreationDate)
    Values (1, '14-SEP-2012')
    Select * from A partition (p_SEP12)
    Select * from A partition (p_AUG12)
    Select * from A partition (p_OCT12)
    Can we do it for 30 days partitions, instead of the monthly partitions. ANY suggestions..
    Thanks..

  • Partition by virtual column, select - sinlgle partition on two columns

    Pls, I have a question - we have table with COLUMNs:
    -- TIME_KEY - julian - date value (to_char(sysdate, 'J')) - we would like to have virtual date value:
    -- TIME_ID - virtual column with interval partitioning (great!)
    CREATE TABLE lsd_cntr_pokus
    ( time_key NUMBER not NULL
    , time_ID AS (to_date(time_key,'J'))
    , cntr_key NUMBER not NULL
    ---...etc
    PARTITION BY RANGE (time_ID) INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
    (PARTITION part_2007 VALUES LESS THAN
    (TO_DATE('01-JAN-2007','dd-MON-yyyy'))
    But then - is it possible to somehow define this table,
    so both selects:
    SELECT * FROM lsd_cntr_pokus
    WHERE time_key = to_char(TO_DATE('01.01.2007', 'DD.MM.YYYY'),'j') ;
    SELECT * FROM lsd_cntr_pokus
    WHERE time_id = TO_DATE('01.01.2007', 'DD.MM.YYYY') ;
    use PARTITION RANGE SINGLE?
    Thanks for any help,
    Regards
    Edited by: vrbcik on Dec 10, 2012 3:39 PM

    vrbcik wrote:
    Pls, I have a question - we have table with COLUMNs:
    -- TIME_KEY - julian - date value (to_char(sysdate, 'J')) - we would like to have virtual date value:
    -- TIME_ID - virtual column with interval partitioning (great!)
    CREATE TABLE lsd_cntr_pokus
    ( time_key NUMBER not NULL
    , time_ID AS (to_date(time_key,'J'))
    , cntr_key NUMBER not NULL
    ---...etc
    PARTITION BY RANGE (time_ID) INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
    (PARTITION part_2007 VALUES LESS THAN
    (TO_DATE('01-JAN-2007','dd-MON-yyyy'))
    But then - is it possible to somehow define this table,
    so both selects:
    SELECT * FROM lsd_cntr_pokus
    WHERE time_key = to_char(TO_DATE('01.01.2007', 'DD.MM.YYYY'),'j') ;
    SELECT * FROM lsd_cntr_pokus
    WHERE time_id = TO_DATE('01.01.2007', 'DD.MM.YYYY') ;
    use PARTITION RANGE SINGLE?
    Thanks for any help,
    Regards
    Edited by: vrbcik on Dec 10, 2012 3:39 PMHi,
    I'm afraid that, with this partition definition, partition pruning is working only when you use your virtual column time_id in your query.
    According to documentation Information That Can Be Used for Partition Pruning:
    Virtual column-based partitioned tables benefit from partition pruning for statements that use the virtual column-defining expression in the SQL statement.Maybe some tuning expert can confirm this or give another advice.
    Regards.
    Al

  • Range Partitioning on Varchar2 column???

    We hava table and it has a date column and its type is varchar2.
    This column's format is '16021013' ('ddmmyyyy').
    We want to make range partition on this column. What will be the best way?
    do you think virtal column partitioning will be efficient?

    >
    I'm not a new DBA:-) You can be sure. I asked only about range partitioning trick with varchar2 column because we did our examination about this table. We will need to archive this table quarter by quarter to the other archive database. Then, off course, nearly all queries are coming firstly by using this date column and they can have different filtering inside "where" conditions. Already, this table has index on this column but with huge number of data, index performance is not enough for us. This is a 7x24 banking system and we are lately joined to this project. Because of this, we cant change everything like changing data type of that column after this moment.
    >
    You are taking things way too personally. No one said anything about whether you were, or were not, a DBA or made any other comments about your skill or abilities.
    What we ask was for you to tell us WHAT the problem was that you were trying to solve and WHY you thought partitioning would solve it.
    And now, after several generic posts, you have finally provided that information. We can only comment based on the information that you post. We can't guess as to what types of queries you use or what kinds of predicates you use in those queries. But we need to know that information in order to provide the best advice.
    Next time you post put the important information in your original question:
    1. A table column is VARCHAR2 but contains a date value. We are unable to change the datatype of this column.
    2. We need to archive data quarterly based on this date value
    3. Nearly all queries use this date value and then also may have additional filter conditions
    4. This date column is indexed but we would like to improve the performance beyond what this index can give us.
    The above is a summary that includes all important information that is needed to know how best to help you.
    And I made a pretty good guess since two replies ago I provided you with example code that shows just how to partition the table.
    >
    Now, our only aim is how to make range partitioning this varchar2 date column.
    >
    As I showed you in my example code earlier you can add a virtual column to the table and partition on it. My example code creates a monthly partitioned table that allows you to archive by month or archive every three months to archive by quarter.
    You can modify that example to use quarterly partitions if you want but I would recommend that you use standard monthly partitions since they will satisfy the widest range of predicates.

  • Range Partitioning a table based on day of the week

    I have a logging table which i want to partition into 7 partition, each one for the day of the week, eg MON,TUE, WED. I am aware and I can do a list partition by creating a parition key which stores 'DY' of the week and this means that I need to add another column to the existing table.
    I wanted to explore the option of creating a range parition based on the timestamp column that already exists. Can anyone let me know if this option is possible?
    Example
    create table test_partition
    ( log_id number,
    log_date TIMESTAMP(6),
    log_value varchar2(100)
    PARTITION BY RANGE (log_date)
    PARTITION p1_mon VALUES LESS THAN (), ---- Not sure what can be used here to create this parition.
    PARTITION p2_tue VALUES LESS THAN (),
    PARTITION p3_wed VALUES LESS THAN (),
    PARTITION p4_thu VALUES LESS THAN (),
    PARTITION p5_fri VALUES LESS THAN (),
    PARTITION p6_sat VALUES LESS THAN (),
    PARTITION p7_sun VALUES LESS THAN ()
    Any oracle guru with some suggestion for this would be highly appreciated..
    Cheers,
    VJ

    Something like:
    PARTITION P1_MON VALUES LESS THAN (TIMESTAMP'2009-03-10 00:00:00')
    ....Bear in mind that you will have to write a procedure to drop and create your daily partitions, and run that on a daily basis. Also you would be well advised to create a catchall partition that holds anything that won't go into your latest specified partition, eg:
    PARTITION P_MAX VALUES LESS THAN (MAXVALUE)

  • Range partitioning of 3 columns

    Hello!
    I use Oracle 10g with SH schema.
    Now I want to create a new table SALES_SH that have range partition of 3 columns:
    create table SH.SALES_SH (PROD_ID NUMBER, CUST_ID NUMBER, TIME_ID DATE, CHANNEL_ID NUMBER, PROMO_ID NUMBER, QUANTITY_SOLD NUMBER(10,2), AMOUNT_SOLD NUMBER(10,2), COUNTRY_ID NUMBER, PROD_CATEGORY_ID NUMBER, FISCAL_YEAR NUMBER(4))
    PARTITION BY RANGE (FISCAL_YEAR, COUNTRY_ID, PROD_CATEGORY_ID)
    (PARTITION S_2000_GM_EL VALUES LESS THAN (2001,52789,203),
    PARTITION S_2000_GM_PA VALUES LESS THAN (2001,52789,205),
    PARTITION S_2000_GM_SO VALUES LESS THAN (2001,52789,206),
    PARTITION S_2000_UK_EL VALUES LESS THAN (2001,52790,203),
    PARTITION S_2000_UK_PA VALUES LESS THAN (2001,52790,205),
    PARTITION S_2000_UK_SO VALUES LESS THAN (2001,52790,206),
    PARTITION S_2000_US_EL VALUES LESS THAN (2001,52791,203),
    PARTITION S_2000_US_PA VALUES LESS THAN (2001,52791,205),
    PARTITION S_2000_US_SO VALUES LESS THAN (2001,52791,206),
    PARTITION S_2001_GM_EL VALUES LESS THAN (2002,52789,203),
    PARTITION S_2001_GM_PA VALUES LESS THAN (2002,52789,205),
    PARTITION S_2001_GM_SO VALUES LESS THAN (2002,52789,206),
    PARTITION S_2001_UK_EL VALUES LESS THAN (2002,52790,203),
    PARTITION S_2001_UK_PA VALUES LESS THAN (2002,52790,205),
    PARTITION S_2001_UK_SO VALUES LESS THAN (2002,52790,206),
    PARTITION S_2001_US_EL VALUES LESS THAN (2002,52791,203),
    PARTITION S_2001_US_PA VALUES LESS THAN (2002,52791,205),
    PARTITION S_2001_US_SO VALUES LESS THAN (2002,52791,206),
    PARTITION S_2002_GM_EL VALUES LESS THAN (2003,52789,203),
    PARTITION S_2002_GM_PA VALUES LESS THAN (2003,52789,205),
    PARTITION S_2002_GM_SO VALUES LESS THAN (2003,52789,206),
    PARTITION S_2002_UK_EL VALUES LESS THAN (2003,52790,203),
    PARTITION S_2002_UK_PA VALUES LESS THAN (2003,52790,205),
    PARTITION S_2002_UK_SO VALUES LESS THAN (2003,52790,206),
    PARTITION S_2002_US_EL VALUES LESS THAN (2003,52791,203),
    PARTITION S_2002_US_PA VALUES LESS THAN (2003,52791,205),
    PARTITION S_2002_US_SO VALUES LESS THAN (2003,52791,206));
    Here is the Data:
    INSERT INTO SH.SALES_SH
    SELECT SALES.PROD_ID, SALES.CUST_ID, SALES.TIME_ID, CHANNEL_ID, PROMO_ID, QUANTITY_SOLD, AMOUNT_SOLD, COUNTRY_ID, PROD_CATEGORY_ID, FISCAL_YEAR
    FROM SALES, CUSTOMERS, TIMES, PRODUCTS
    WHERE SALES.PROD_ID=PRODUCTS.PROD_ID AND SALES.CUST_ID=CUSTOMERS.CUST_ID AND SALES.TIME_ID=TIMES.TIME_ID
    AND (COUNTRY_ID=52790 OR COUNTRY_ID=52789 OR COUNTRY_ID=52776)
    AND (PROD_CATEGORY_ID=201 OR PROD_CATEGORY_ID=203 OR PROD_CATEGORY_ID=205)
    AND (FISCAL_YEAR=2000 OR FISCAL_YEAR=2001 OR FISCAL_YEAR=2002)
    ORDER BY FISCAL_YEAR, COUNTRY_ID, PROD_CATEGORY_ID;
    Note that, in Create table script, I use some "virtual value" (2003,52791,206) instead of MAXVALUE (because it get error)
    It run. But the partitions with "virtual value" have no data, and the others data is wrong!
    Please, help me! Thanks
    TRAN MAI

    OK. Here is the real data:
    SELECT distinct fiscal_year, country_id, prod_category_id from sales_sh partition(s_2000_gm_el) order by fiscal_year, country_id, prod_category_id;
    FISCAL_YEAR COUNTRY_ID PROD_CATEGORY_ID
    2000 52776 201
    2000 52776 203
    2000 52776 205
    2000 52789 201
    2000 52789 203
    2000 52789 205
    2000 52790 201
    2000 52790 203
    2000 52790 205
    2001 52776 201
    2001 52776 203
    FISCAL_YEAR COUNTRY_ID PROD_CATEGORY_ID
    2001 52776 205
    2001 52789 201
    13 rows selected.
    That mean, the PARTITION S_2000_GM_EL VALUES LESS THAN (2001,52789,203) get nearly all data.
    That mean, VALUES LESS THAN (2001,52789,203) <=> Fiscal_year<2001 OR Country_id<52789 OR Prod_category_id<203 (the "OR" condition), while I want the "AND" condition.
    Please, give me an advise! Thanks!
    TRAN MAI

Maybe you are looking for

  • Every time I create a button it moves to the centre of the page when outputing to pdf

    every time I create a button it moves to the centre of the page when outputting to pdf I have done a load of tests and it does it every time I imported a jpg image as my button. Converted it to a button by Interactive/convert button. Even before I se

  • Upgrading jvm to 1.4.2_04 of application server 7 update 1

    my application server 7update 1, comes with jvm build 1.4.1_01-b01, and i now i am planning upgrading the jvm to last sun solaris sparc version 1.4.2_04 . Anyone have experience on this? is this change certified? thanks in advance miguel ares

  • Problem in intermedia Please help me!

    I am University student in South Korea. I'm major in Computer Engineering. I'm using Oracle 9i. And then I'm using 'intermedia' package. I'm interesting in Content-based retrieval. Among them, I'm interesting in Image retrieval. But problem is happen

  • Why won't Firefox for Android on my Kindle Fire HD play YouTube videos?

    The default browser (Silk) on the Kindle Fire HD plays YouTube videos. Both Firefox for Android and Silk obviously use the same operating system and hardware. What needs to be done to/with the Firefox for Android browser so that it will play YouTube

  • Process order movement

    Dear All, I want to see goods movement in process COR2gotolist -document godds movement got the below message There is no data for the selection Message no. COIS024 Diagnosis Either no data was selected or you are not authorized to display the data.