ORA_HASH

Just want to know how ORA_HASH function works internally in ORACLE database

Here's some information about oracles hash functions from Jonathan Lewis.

Similar Messages

  • [ora_hash] different value for the same input

    hi all,
    i'm using 2 different machine running the same version of oracle (11g).
    on those 2 db i have the same tables with the same datas.
    for the comparisson of the data i'm using the ora_hash function (both on numeric and string fields) and for some records i get different results.
    how is that possible?
    (by the way looking at the records that has different hashes the values calculated by the hash function are the same)
    thx

    You have posted in the wrong forum. As the forum title says this forum is for SQL Developer and not for SQL or PL/SQL questions.
    After reading the information provided at the end of this reply you should
    1. create a new thread in the SQL and PL/SQL forum
    PL/SQL
    2. Edit this current question to add a link to the new question and tell people to follow up in the other forum.
    3. Mark this current question ANSWERED so followup will be in the other forum.
    Thanks.
    When you post in the other forum provide information related to the following
    >
    for the comparisson of the data i'm using the ora_hash function (both on numeric and string fields) and for some records i get different results.
    >
    Please post your 4 digit Oracle versions - both versions (result of SELECT * FROM V$VERSION) and examples (i.e. actual code) of values that are giving different results.
    >
    (by the way looking at the records that has different hashes the values calculated by the hash function are the same)
    >
    What? there can't be 'different hashes' if the 'values calculated by the hash function' are the same. What are you saying here?
    Again - provide examples that show the differences. Should be something like
    SELECT ORA_HASH(12345) FROM DUAL;Since you say there are differences on the two machines provide the execution plan from each machine that shows what Oracle is actually doing. One machine may be applying a function to the data.

  • Problem using ora_hash in a mapping in OWB

    Hi,
    I wanted to use the function ora_hash in order to implement history preserving on a dimension table.
    If I use the ora_hash in a expression in a mapping "ORA_HASH( INGRP1.NAAM || INGRP1.PRODUCT || INGRP1.SECTION )" and I deploy this maping then I get the warning "PLS-00201: identifier 'ORA_HASH' must be declared".
    If I execute this function in SQLDeveloper or Toad it works fine and returns me a number.
    I have granted execute priviledges from within the sys schema to the user I deploy the mapping to.
    I have this problem at a customer's site on an oracle 10.2 database but I have it on my own laptop, Oracle 11G, as well.
    I don't see what I'm doing wrong but I'm overlooking something I guess.
    Thanks for you advice!

    Hi
    Configure the mapping to be Set Based only. It sounds like the row based code is executing the SQL-only function ORA_HASH in PLSQL, so you get the error.
    Set Based;
    To illustrate, the Set Based SQL will have the ORA_HASH call within the SQL statement.....
    SQL> select ora_hash('hello world') from dual;
    ORA_HASH('HELLOWORLD')
    1896528268
    Row Based;
    The row based code will make a call something like this (just to illustrate SQL vs PLSQL);
    SQL> declare v varchar2(20); begin v := ora_hash('hello world'); end;
    2 /
    declare v varchar2(20); begin v := ora_hash('hello world'); end;
    ERROR at line 1:
    ORA-06550: line 1, column 36:
    PLS-00201: identifier 'ORA_HASH' must be declared
    ORA-06550: line 1, column 31:
    PL/SQL: Statement ignored
    So configure the mapping to ONLY use Set Based on the code generation and default operating mode and you should be in business.
    Cheers
    David

  • Ora_hash - Same hash value for different inputs (Urgent)

    Hi,
    Trying to use ora_hash to join between tables but i noticed that in some cases, when working on different input value the ora_hash function generates same results.
    select ora_hash('oomeroe03|6NU3|LS006P|7884|1|17-JUL-13 13.18.22.528000|0005043|'),ora_hash('GSAHFFXTK|GCQ3|A6253S|12765|1|17-JUL-13 17.26.26.853000|0136423|')
    from dual
    Output value : 1387341941
    Oracle version is 11gR2.
    Thanks

    Why would anyone limit the hash distribution to three buckets ?
    However, one must understand that the default seed is 0.  So one input repeated gets the same hash value unless the seed is changed.
    SQL> select ora_hash(rn) , rn
      2  from
      3  (Select rownum as rn from dual connect by level < 11)
      4  order by rn;
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL> l
      1  select ora_hash(rn) , rn
      2  from
      3  (Select rownum as rn from dual connect by level < 11)
      4* order by rn
    SQL> /
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL> /
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL>
    Hemant K Chitale

  • Regd: Usage of ora_hash AND hash collision

    We need to compare two tables residing in two different database instances(both on Oracle 10g ver2).
    I have heard of the ora_hash SQL function provided as part of Oracle 10g.
    However, i need to enquire as to what is the probability for a hash collision.
    As such the max bucket size of ora_hash is equal to (2^32-1) does that imply that there will not be any hash collisions for a dataset of 2^32-1 records.
    Appreciate your thought in this regard.
    -Thanks!

    user636222 wrote:
    We need to compare two tables residing in two different database instances(both on Oracle 10g ver2).
    I have heard of the ora_hash SQL function provided as part of Oracle 10g.
    However, i need to enquire as to what is the probability for a hash collision.
    As such the max bucket size of ora_hash is equal to (2^32-1) does that imply that there will not be any hash collisions for a dataset of 2^32-1 records.
    Appreciate your thought in this regard.There is no guarantee to be free of hash collision regardless of the bucket size chosen, so if you need 100% accuracy you'll always have to check in case of equal hash values if the two rows are actually the same or not.
    So running the "minus" variant is probably more straightforward but - depending on the table sizes - might require a very large and resource/space/time consuming sort operation.
    Depending on your requirements you might be able to combine both approaches, may be you can already reduce the set to compare by eliminating all those having different hash values since these are guaranteed to be different.
    In order to lower the probability you could have a look at DBMS_CRYPTO.HASH, which offers 128-bit or 160-bit hash values or DBMS_OBFUSCATION_TOOLKIT.MD5 with 128-bit hash values.
    Regards,
    Randolf
    Oracle related stuff blog:
    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/

  • URGENT: ora_hash AND hash collision

    We need to compare two tables residing in two different database instances(both on Oracle 10g ver2).
    I have heard of the ora_hash SQL function provided as part of Oracle 10g.
    However, i need to enquire as to what is the probability for a hash collision.
    As such the max bucket size of ora_hash is equal to (2^32-1) does that imply that there will not be any hash collisions for a dataset of 2^32-1 records.
    Appreciate your thought in this regard.
    -Thanks!

    May be you want this .. But this will only tell you that the tables are identical or not .
    SQL> select * from emp;
    SQL>
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
             1 gggg
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81       1000                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    15 rows selected.
    SQL>     
    SQL> create table emp1 nologging as select * from emp where empno <> 1;
    Table created.
    SQL> SELECT * FROM EMP1;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81       1000                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL>
    SQL> create table emp2 nologging as select * from emp ;
    Table created.
    SQL> UPDATE EMP2 SET COMM = NVL(COMM,0) ;
    15 rows updated.
    SQL> COMMIT;
    SQL> SELECT * FROM EMP2;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
             1 gggg                                                          0
          7369 SMITH      CLERK           7902 17-DEC-80        800          0         20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975          0         20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850          0         30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450          0         10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000          0         20
          7839 KING       PRESIDENT            17-NOV-81       5000          0         10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7876 ADAMS      CLERK           7788 23-MAY-87       1100          0         20
          7900 JAMES      CLERK           7698 03-DEC-81       1000          0         30
          7902 FORD       ANALYST         7566 03-DEC-81       3000          0         20
          7934 MILLER     CLERK           7782 23-JAN-82       1300          0         10
    15 rows selected.
    SQL>
    SQL> create table emp3 nologging as select * from emp ;
    Table created.
    SQL> SELECT * FROM EMP3;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
             1 gggg
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81       1000                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    15 rows selected.
    SQL>
    SQL>  COLUMN HASH_CODE FORMAT 999999999999999999999999
    SQL>  select sum(ora_hash(EMPNO||ENAME||JOB||MGR||HIREDATE||SAL||COMM||DEPTNO, 4294967294)) HASH_CODE from EMP;
                    HASH_CODE
                  34307672633
    SQL>  select sum(ora_hash(EMPNO||ENAME||JOB||MGR||HIREDATE||SAL||COMM||DEPTNO, 4294967294)) HASH_CODE from EMP1;
                    HASH_CODE
                  31467742359
    SQL>  select sum(ora_hash(EMPNO||ENAME||JOB||MGR||HIREDATE||SAL||COMM||DEPTNO, 4294967294)) HASH_CODE from EMP2;
                    HASH_CODE
                  31292750688
    SQL>  select sum(ora_hash(EMPNO||ENAME||JOB||MGR||HIREDATE||SAL||COMM||DEPTNO, 4294967294)) HASH_CODE from EMP3;
                    HASH_CODE
                  34307672633
    SQL>Now observe hash code from the table emp & emp3 are same because they are identical.. in other cases hash codes are different.

  • Could you please tell me the arithmetic of ORA_HASH? Thanks.

    Hello,
    I need to use java code to implement the function of ORA_HASH(expr, max_bucket, seed_value).
    I saw the ORA_HASH(expr, max_bucket, seed_value)'s description from http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/functions097.htm.
    But I still don't know the detailed arithmetic of ORA_HASH(expr, max_bucket, seed_value).
    So could you please tell me the detailed arithmetic of ORA_HASH(expr, max_bucket, seed_value)?
    Thanks.

    Not sure Oracle will actually divulge the internal workings of their functions to you.
    However, they are standard algorithms (depending on which parameter you pass to the function) i.e. it depends on whether you are doing an SHA-1 hash or a MD5 hash etc.
    Information is available on the web...
    e.g.
    http://www.secure-hash-algorithm-md5-sha-1.co.uk/
    which describes who or where the algorithms were developed and then you can look up to see if the actual specifications for them are on the web (they'll be around somewhere) e.g.
    http://en.wikipedia.org/wiki/MD5
    http://infohost.nmt.edu/~sfs/Students/HarleyKozushko/Presentations/MD5.pdf
    http://www.uow.edu.au/~jennie/CSCI971/hash1.pdf
    etc.

  • PLS-00201 when trying to call ORA_HASH from a function

    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
    PL/SQL Release 10.2.0.2.0 - Production
    CORE 10.2.0.2.0 Production
    TNS for Solaris: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
    SQL> select ora_hash('GOOBERS') from dual;
    ORA_HASH('GOOBERS')
    1552467184
    SQL> create or replace function my_hash(x in varchar2) return number is begin return ora_hash(x); end;
    2 /
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION MY_HASH:
    LINE/COL ERROR
    1/56 PL/SQL: Statement ignored
    1/63 PLS-00201: identifier 'ORA_HASH' must be declared
    If anyone has some ideas on this it would be great to hear from you. Thanks.

    Thanks Maxim & Rakesh, that worked.
    It does look like a bug. The return on it's own works with other functions e.g. ASCII etc. but not ORA_HASH.
    The select from dual version is painfully slow (e.g. 25 x times) though so I think I'll use dbms_utility.get_hash_value instead for now. I was planning to use that version in 9i anyway as my app still needs to run on 9i - but I was trying to get the ORA_HASH working for 10g as it is incredibly fast.
    Will definitely log it though.

  • How to find out names of all stored procedures?

    Hi All,
    I need to find out the names of all stored procedures with parameters and return types. I can use DBA_SOURCE, but in this case I must parse TEXT to find out what I need. Is there any dictionary where the names, parameters and return types of stored procedures saved separately?
    Thanks,
    Andrej.

    Not much fair to bring this old post up, sorry!
    I am still looking for an answer to my post
    where are stored functions like ORA_HASH or GROUPING_ID

  • Error in PL/SQL generated package

    Hello,
    With the help of ODM (version 10,2,0,3,1 -Build 479) I created a SVM classification model, which works very fine.
    After that, I generated the PL/SQL package, which returns an ORA-06512 in the call into DBMS_DATA_MINING.CREATE_MODEL.
    I tried to rebuild the model in the ODM and all worked well.
    I am kind of stuck here and don't know what to do next.
    Thanks,
    Igor

    Hi,
    hope you had a nice vacation.
    As for the code I have a feeling I try to fill a varchar2 with text, larger than declared length. I created a standard PL/SQL package as defined in the tutorial and the error remained. I wonder how come that with the use of odminer the building process is successful while the use of PL/SQL package returns errors?
    Thanks,
    Igor
    CREATE VIEW mining_data_build_v AS
    SELECT
    a.CUST_ID,
    a.CUST_GENDER,
    2003-a.CUST_YEAR_OF_BIRTH AGE,
    a.CUST_MARITAL_STATUS,
    c.COUNTRY_NAME,
    a.CUST_INCOME_LEVEL,
    b.EDUCATION,
    b.OCCUPATION,
    b.HOUSEHOLD_SIZE,
    b.YRS_RESIDENCE,
    b.AFFINITY_CARD,
    b.BULK_PACK_DISKETTES,
    b.FLAT_PANEL_MONITOR,
    b.HOME_THEATER_PACKAGE,
    b.BOOKKEEPING_APPLICATION,
    b.PRINTER_SUPPLIES,
    b.Y_BOX_GAMES,
    b.OS_DOC_SET_KANJI
    FROM
    sh.customers a,
    sh.supplementary_demographics b,
    sh.countries c
    WHERE
    a.CUST_ID = b.CUST_ID
    AND a.country_id = c.country_id
    AND a.cust_id between 101501 and 103000;
    using the package
    CREATE PACKAGE "DATAMININGACTIVITY9" AUTHID DEFINER AS
    PROCEDURE "MINING_DATA_BUI666498540_BA"(case_table IN VARCHAR2 DEFAULT '"DMUSER"."MINING_DATA_BUILD_V"',
    additional_table_1 IN VARCHAR2 DEFAULT NULL,
    model_name IN VARCHAR2 DEFAULT 'MINING_DATA_B80870_SV',
    confusion_matrix_name IN VARCHAR2 DEFAULT '"DM4J$T504449054041_M"',
    lift_result_name IN VARCHAR2 DEFAULT '"DM4J$T504449083327_L"',
    roc_result_name IN VARCHAR2 DEFAULT '"DM4J$T504449092305_R"',
    test_metric_name IN VARCHAR2 DEFAULT '"DM4J$MINING_D51278_TM"',
    drop_output IN BOOLEAN DEFAULT FALSE);
    END;
    CREATE PACKAGE BODY "DATAMININGACTIVITY9" AS
    c_long_sql_statement_length CONSTANT INTEGER := 32767;
    SUBTYPE SQL_STATEMENT_TYPE IS VARCHAR2(32767);
    SUBTYPE LONG_SQL_STATEMENT_TYPE IS DBMS_SQL.VARCHAR2A;
    TYPE TABLE_ARRAY is TABLE OF VARCHAR2(62);
    TYPE LSTMT_REC_TYPE IS RECORD (
    lstmt dbms_sql.VARCHAR2A,
    lb BINARY_INTEGER DEFAULT 1,
    ub BINARY_INTEGER DEFAULT 0);
    TYPE LSTMT_REC_TYPE_ARRAY is TABLE OF LSTMT_REC_TYPE;
    TYPE QUERY_ARRAY is TABLE OF SQL_STATEMENT_TYPE;
    TYPE TARGET_VALUES_LIST IS TABLE OF VARCHAR2(32);
    TYPE VALUE_COUNT_LIST IS TABLE OF NUMBER;
    PROCEDURE dump_varchar2a(vc2a dbms_sql.VARCHAR2A) IS
    v_str varchar2(32767);
    BEGIN
    DBMS_OUTPUT.PUT_LINE('dump_varchar2a:');
    FOR i IN 1..vc2a.COUNT LOOP
    v_str := vc2a(i);
    DBMS_OUTPUT.PUT_LINE(v_str);
    END LOOP;
    END;
    PROCEDURE ls_append(
    r_lstmt IN OUT NOCOPY LSTMT_REC_TYPE,
    p_txt VARCHAR2)
    IS
    BEGIN
    r_lstmt.ub := r_lstmt.ub + 1;
    r_lstmt.lstmt(r_lstmt.ub) := p_txt;
    END ls_append;
    PROCEDURE ls_append(
    r_lstmt IN OUT NOCOPY LSTMT_REC_TYPE,
    p_txt LSTMT_REC_TYPE) IS
    BEGIN
    FOR i IN p_txt.lb..p_txt.ub LOOP
    r_lstmt.ub := r_lstmt.ub + 1;
    r_lstmt.lstmt(r_lstmt.ub) := p_txt.lstmt(i);
    END LOOP;
    END ls_append;
    FUNCTION query_valid(
    p_query VARCHAR2) RETURN BOOLEAN
    IS
    v_is_valid BOOLEAN;
    BEGIN
    BEGIN
    EXECUTE IMMEDIATE p_query;
    v_is_valid := TRUE;
    EXCEPTION WHEN OTHERS THEN
    v_is_valid := FALSE;
    END;
    RETURN v_is_valid;
    END query_valid;
    FUNCTION table_exist(
    p_table_name VARCHAR2) RETURN BOOLEAN IS
    BEGIN
    RETURN query_valid('SELECT * FROM ' || dbms_assert.simple_sql_name(p_table_name));
    END table_exist;
    FUNCTION model_exist(
    p_model_name VARCHAR2) RETURN BOOLEAN
    IS
    v_model_cnt NUMBER;
    v_model_exists BOOLEAN := FALSE;
    BEGIN
    SELECT COUNT(*) INTO v_model_cnt FROM DM_USER_MODELS WHERE NAME = UPPER(p_model_name);
    IF v_model_cnt > 0 THEN
    v_model_exists := TRUE;
    END IF;
    --DBMS_OUTPUT.PUT_LINE('model exist: '||v_model_exists);
    RETURN v_model_exists;
    EXCEPTION WHEN OTHERS THEN
    RETURN FALSE;
    END model_exist;
    PROCEDURE drop_table(
    p_table_name VARCHAR2)
    IS
    v_stmt SQL_STATEMENT_TYPE;
    BEGIN
    v_stmt := 'DROP TABLE '||dbms_assert.simple_sql_name(p_table_name)||' PURGE';
    EXECUTE IMMEDIATE v_stmt;
    EXCEPTION WHEN OTHERS THEN
    NULL;
    --DBMS_OUTPUT.PUT_LINE('Failed drop_table: '||p_table_name);
    END drop_table;
    PROCEDURE drop_view(
    p_view_name VARCHAR2)
    IS
    v_stmt SQL_STATEMENT_TYPE;
    BEGIN
    v_stmt := 'DROP VIEW '||dbms_assert.simple_sql_name(p_view_name);
    EXECUTE IMMEDIATE v_stmt;
    EXCEPTION WHEN OTHERS THEN
    NULL;
    --DBMS_OUTPUT.PUT_LINE('Failed drop_view: '||p_view_name);
    END drop_view;
    PROCEDURE drop_model(
    p_model_name VARCHAR2)
    IS
    BEGIN
    DBMS_DATA_MINING.DROP_MODEL(p_model_name);
    EXCEPTION WHEN OTHERS THEN
    NULL;
    --DBMS_OUTPUT.PUT_LINE('Failed drop_model: '||p_model_name);
    END drop_model;
    FUNCTION create_new_temp_table_name(prefix IN VARCHAR2, len IN NUMBER)
    RETURN VARCHAR2 IS
    v_table_name VARCHAR2(30);
    v_seed NUMBER;
    BEGIN
    dbms_random.seed(SYS_GUID());
    v_table_name := 'DM$T' || SUBSTR(prefix, 0, 4) || dbms_random.string(NULL, len-8);
    --DBMS_OUTPUT.PUT_LINE('create_new_temp_table_name: '||v_table_name);
    RETURN v_table_name;
    END create_new_temp_table_name;
    FUNCTION create_new_temp_table_name(prefix IN VARCHAR2)
    RETURN VARCHAR2 IS
    BEGIN
    RETURN create_new_temp_table_name(prefix, 30);
    END create_new_temp_table_name;
    FUNCTION ADD_TEMP_TABLE(tempTables IN OUT NOCOPY TABLE_ARRAY, temp_table IN VARCHAR2) RETURN VARCHAR2 IS
    BEGIN
    tempTables.EXTEND;
    tempTables(tempTables.COUNT) := temp_table;
    return temp_table;
    END;
    PROCEDURE DROP_TEMP_TABLES(tempTables IN OUT NOCOPY TABLE_ARRAY) IS
    v_temp VARCHAR2(30);
    BEGIN
    FOR i IN 1..tempTables.COUNT LOOP
    v_temp := tempTables(i);
    drop_table(v_temp);
    drop_view(v_temp);
    tempTables.DELETE(i);
    END LOOP;
    END;
    PROCEDURE CHECK_RESULTS(drop_output IN BOOLEAN,
    result_name IN VARCHAR2) IS
    BEGIN
    -- drop all results if drop = true, otherwise make sure all results don't exist already (raise exception)
    IF result_name IS NOT NULL THEN
    IF drop_output THEN
    drop_table(result_name);
    drop_view(result_name);
    ELSIF (table_exist(result_name)) THEN
    RAISE_APPLICATION_ERROR(-20000, 'Result table exists: '||result_name);
    END IF;
    END IF;
    END;
    PROCEDURE CHECK_MODEL(drop_output IN BOOLEAN,
    model_name IN VARCHAR2) IS
    BEGIN
    -- drop all results if drop = true, otherwise make sure all results don't exist already (raise exception)
    IF model_name IS NOT NULL THEN
    IF drop_output THEN
    drop_model(model_name);
    ELSIF (model_exist(model_name)) THEN
    RAISE_APPLICATION_ERROR(-20001, 'Model exists: '||model_name);
    END IF;
    END IF;
    END;
    PROCEDURE create_table_from_query(query IN OUT NOCOPY LSTMT_REC_TYPE)
    IS
    v_cursor NUMBER;
    v_feedback INTEGER;
    BEGIN
    v_cursor := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(
    c => v_cursor,
    statement => query.lstmt,
    lb => query.lb,
    ub => query.ub,
    lfflg => FALSE,
    language_flag => dbms_sql.native);
    v_feedback := DBMS_SQL.EXECUTE(v_cursor);
    DBMS_SQL.CLOSE_CURSOR(v_cursor);
    EXCEPTION WHEN OTHERS THEN
    IF DBMS_SQL.IS_OPEN(v_cursor) THEN
    DBMS_SQL.CLOSE_CURSOR(v_cursor);
    END IF;
    RAISE;
    END;
    FUNCTION get_row_count(tableName IN VARCHAR2)
    RETURN INTEGER IS
    v_stmt VARCHAR(100);
    qcount INTEGER := 0;
    BEGIN
    v_stmt := 'SELECT COUNT(*) FROM '|| tableName;
    EXECUTE IMMEDIATE v_stmt INTO qcount;
    RETURN qcount;
    END get_row_count;
    PROCEDURE SET_EQUAL_DISTRIBUTION (
    counts IN OUT VALUE_COUNT_LIST )
    IS
    v_minvalue NUMBER := 0;
    BEGIN
    FOR i IN counts.FIRST..counts.LAST
    LOOP
    IF ( i = counts.FIRST )
    THEN
    v_minvalue := counts(i);
    ELSIF ( counts(i) > 0 AND v_minvalue > counts(i) )
    THEN
    v_minvalue := counts(i);
    END IF;
    END LOOP;
    FOR i IN counts.FIRST..counts.LAST
    LOOP
    counts(i) := v_minvalue;
    END LOOP;
    END SET_EQUAL_DISTRIBUTION;
    PROCEDURE GET_STRATIFIED_DISTRIBUTION (
    table_name VARCHAR2,
    attribute_name VARCHAR2,
    percentage NUMBER,
    attr_values IN OUT NOCOPY TARGET_VALUES_LIST,
    counts IN OUT NOCOPY VALUE_COUNT_LIST,
    counts_sampled IN OUT NOCOPY VALUE_COUNT_LIST )
    IS
    v_tmp_stmt VARCHAR2(4000);
    BEGIN
    v_tmp_stmt :=
    'SELECT /*+ noparallel(t)*/ ' || attribute_name ||
    ', count(*), ROUND ( ( count(*) * ' || percentage || ') / 100.0 ) FROM '|| table_name ||
    ' WHERE ' || attribute_name ||' IS NOT NULL GROUP BY ' || attribute_name;
    EXECUTE IMMEDIATE v_tmp_stmt
    BULK COLLECT INTO attr_values, counts, counts_sampled;
    END GET_STRATIFIED_DISTRIBUTION;
    FUNCTION GENERATE_STRATIFIED_SQL (
    v_2d_temp_view VARCHAR2,
    src_table_name VARCHAR2,
    attr_names TARGET_VALUES_LIST,
    attribute_name VARCHAR2,
    percentage NUMBER,
    op VARCHAR2,
    equal_distribution IN BOOLEAN DEFAULT FALSE) RETURN LSTMT_REC_TYPE
    IS
    v_tmp_lstmt LSTMT_REC_TYPE;
    attr_values_res TARGET_VALUES_LIST;
    counts_res VALUE_COUNT_LIST;
    counts_sampled_res VALUE_COUNT_LIST;
    tmp_str VARCHAR2(4000);
    sample_count PLS_INTEGER;
    BEGIN
    GET_STRATIFIED_DISTRIBUTION(src_table_name, attribute_name, percentage, attr_values_res, counts_res, counts_sampled_res);
    IF ( equal_distribution = TRUE )
    THEN
    SET_EQUAL_DISTRIBUTION(counts_sampled_res);
    END IF;
    v_tmp_lstmt.ub := 0; -- initialize
    ls_append(v_tmp_lstmt, 'CREATE TABLE ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, '( SELECT ');
    FOR i IN attr_names.FIRST..attr_names.LAST
    LOOP
    IF ( i != attr_names.FIRST )
    THEN
    ls_append(v_tmp_lstmt,',');
    END IF;
    ls_append(v_tmp_lstmt, attr_names(i));
    END LOOP;
    ls_append(v_tmp_lstmt, ' FROM (SELECT /*+ no_merge */ t.*, ROWNUM RNUM FROM ' || src_table_name || ' t) WHERE ' );
    FOR i IN attr_values_res.FIRST..attr_values_res.LAST
    LOOP
    IF ( i != attr_values_res.FIRST )
    THEN
    tmp_str := ' OR ';
    END IF;
    IF ( counts_res(i) <= 2 ) THEN
    sample_count := counts_res(i);
    ELSE
    sample_count := counts_sampled_res(i);
    END IF;
    tmp_str := tmp_str ||
    '( ' || attribute_name || ' = ''' || attr_values_res(i) || '''' ||
    ' AND ORA_HASH(RNUM,(' || counts_res(i) || ' -1),12345) ' || op || sample_count || ') ';
    ls_append(v_tmp_lstmt, tmp_str );
    END LOOP;
    ls_append(v_tmp_lstmt, ') ');
    return v_tmp_lstmt;
    END GENERATE_STRATIFIED_SQL;
    PROCEDURE "MINING_DATA_BUI666498540_BA"(case_table IN VARCHAR2 DEFAULT '"DMUSER"."MINING_DATA_BUILD_V"',
    additional_table_1 IN VARCHAR2 DEFAULT NULL,
    model_name IN VARCHAR2 DEFAULT 'MINING_DATA_B80870_SV',
    confusion_matrix_name IN VARCHAR2 DEFAULT '"DM4J$T504449054041_M"',
    lift_result_name IN VARCHAR2 DEFAULT '"DM4J$T504449083327_L"',
    roc_result_name IN VARCHAR2 DEFAULT '"DM4J$T504449092305_R"',
    test_metric_name IN VARCHAR2 DEFAULT '"DM4J$MINING_D51278_TM"',
    drop_output IN BOOLEAN DEFAULT FALSE)
    IS
    additional_data TABLE_ARRAY := TABLE_ARRAY(
    additional_table_1
    v_tempTables TABLE_ARRAY := TABLE_ARRAY();
    v_2d_view VARCHAR2(30);
    v_2d_view_build VARCHAR2(30);
    v_2d_view_test VARCHAR2(30);
    v_2d_temp_view VARCHAR2(30);
    v_txn_views TABLE_ARRAY := TABLE_ARRAY();
    v_txn_views_build TABLE_ARRAY := TABLE_ARRAY();
    v_txn_views_test TABLE_ARRAY := TABLE_ARRAY();
    v_txn_temp_views TABLE_ARRAY := TABLE_ARRAY();
    v_case_data SQL_STATEMENT_TYPE := case_table;
    v_case_id VARCHAR2(30) := 'DMR$CASE_ID';
    v_tmp_lstmt LSTMT_REC_TYPE;
    v_target_value VARCHAR2(4000) := '1';
    v_num_quantiles NUMBER := 10;
    v_build_data VARCHAR2(30);
    v_test_data VARCHAR2(30);
    v_prior VARCHAR2(30);
    v_build_setting VARCHAR2(30);
    v_apply_result VARCHAR2(30);
    v_build_cm VARCHAR2(30);
    v_test_cm VARCHAR2(30);
    v_accuracy NUMBER;
    v_area_under_curve NUMBER;
    v_avg_accuracy NUMBER;
    v_predictive_confidence NUMBER;
    v_confusion_matrix VARCHAR2(30);
    v_gen_caseId BOOLEAN := FALSE;
    v_2d_txt_view VARCHAR2(30);
    v_content_index VARCHAR2(30);
    v_content_index_pref VARCHAR2(30);
    v_category_temp_table VARCHAR2(30);
    v_term_definitions VARCHAR2(30);
    v_term_final_table VARCHAR2(30);
    v_term_final_table_index VARCHAR2(30);
    v_term_final_table_test VARCHAR2(30);
    pragma autonomous_transaction;
    BEGIN
    CHECK_MODEL(drop_output, model_name);
    CHECK_RESULTS(drop_output, test_metric_name);
    CHECK_RESULTS(drop_output, confusion_matrix_name);
    CHECK_RESULTS(drop_output, lift_result_name);
    CHECK_RESULTS(drop_output, roc_result_name);
    IF (v_gen_caseId) THEN
    v_case_data := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    EXECUTE IMMEDIATE 'CREATE TABLE '||v_case_data||' as SELECT rownum as DMR$CASE_ID, t.* FROM ('||case_table||') t ';
    EXECUTE IMMEDIATE 'ALTER TABLE '||v_case_data||' add constraint '||create_new_temp_table_name('PK')||' primary key (DMR$CASE_ID)';
    END IF;
    ----- Start: Input Data Preparation -----
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt, 'SELECT "CASE_TABLE"."CUST_ID" as "DMR$CASE_ID", TO_CHAR( "CASE_TABLE"."AFFINITY_CARD") AS "AFFINITY_CARD",
    "CASE_TABLE"."AGE" AS "AGE",
    TO_CHAR( "CASE_TABLE"."BOOKKEEPING_APPLICATION") AS "BOOKKEEPING_APPLICATION",
    TO_CHAR( "CASE_TABLE"."BULK_PACK_DISKETTES") AS "BULK_PACK_DISKETTES",
    "CASE_TABLE"."COUNTRY_NAME" AS "COUNTRY_NAME",
    "CASE_TABLE"."CUST_GENDER" AS "CUST_GENDER",
    "CASE_TABLE"."CUST_INCOME_LEVEL" AS "CUST_INCOME_LEVEL",
    "CASE_TABLE"."CUST_MARITAL_STATUS" AS "CUST_MARITAL_STATUS",
    "CASE_TABLE"."EDUCATION" AS "EDUCATION",
    TO_CHAR( "CASE_TABLE"."FLAT_PANEL_MONITOR") AS "FLAT_PANEL_MONITOR",
    TO_CHAR( "CASE_TABLE"."HOME_THEATER_PACKAGE") AS "HOME_THEATER_PACKAGE",
    "CASE_TABLE"."HOUSEHOLD_SIZE" AS "HOUSEHOLD_SIZE",
    "CASE_TABLE"."OCCUPATION" AS "OCCUPATION",
    TO_CHAR( "CASE_TABLE"."OS_DOC_SET_KANJI") AS "OS_DOC_SET_KANJI",
    TO_CHAR( "CASE_TABLE"."Y_BOX_GAMES") AS "Y_BOX_GAMES",
    "CASE_TABLE"."YRS_RESIDENCE" AS "YRS_RESIDENCE" FROM (' || v_case_data || ') CASE_TABLE ');
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view := v_2d_temp_view;
    ----- End: Input Data Preparation -----
    ----- Start: Outlier Treatment Transformation -----
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt, 'SELECT
    "AFFINITY_CARD",
    ( CASE WHEN "AGE" < -1.3 THEN -1.3
    WHEN "AGE" >= -1.3 AND "AGE" <= 79.77 THEN "AGE"
    WHEN "AGE" > 79.77 THEN 79.77
    end) "AGE"
    "BOOKKEEPING_APPLICATION",
    "BULK_PACK_DISKETTES",
    "COUNTRY_NAME",
    "CUST_GENDER",
    "CUST_INCOME_LEVEL",
    "CUST_MARITAL_STATUS",
    "DMR$CASE_ID",
    "EDUCATION",
    "FLAT_PANEL_MONITOR",
    "HOME_THEATER_PACKAGE",
    "HOUSEHOLD_SIZE",
    "OCCUPATION",
    "OS_DOC_SET_KANJI",
    "Y_BOX_GAMES",
    ( CASE WHEN "YRS_RESIDENCE" < -1.7 THEN -1.7
    WHEN "YRS_RESIDENCE" >= -1.7 AND "YRS_RESIDENCE" <= 10 THEN "YRS_RESIDENCE"
    WHEN "YRS_RESIDENCE" > 10 THEN 10
    end) "YRS_RESIDENCE"
    FROM ');
    ls_append(v_tmp_lstmt, v_2d_view);
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view := v_2d_temp_view;
    ----- End: Outlier Treatment Transformation -----
    ----- Start: Missing Values Transformation -----
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt, 'SELECT
    DECODE ( "AGE" , NULL,
    39.23831 , "AGE" ) "AGE" ,
    DECODE ( "YRS_RESIDENCE" , NULL,
    4.128 , "YRS_RESIDENCE" ) "YRS_RESIDENCE" ,
    DECODE ( "BOOKKEEPING_APPLICATION" , NULL,
    ''1'' , "BOOKKEEPING_APPLICATION" ) "BOOKKEEPING_APPLICATION" ,
    DECODE ( "BULK_PACK_DISKETTES" , NULL,
    ''1'' , "BULK_PACK_DISKETTES" ) "BULK_PACK_DISKETTES" ,
    DECODE ( "COUNTRY_NAME" , NULL,
    ''United States of America'' , "COUNTRY_NAME" ) "COUNTRY_NAME" ,
    DECODE ( "CUST_GENDER" , NULL,
    ''M'' , "CUST_GENDER" ) "CUST_GENDER" ,
    DECODE ( "CUST_INCOME_LEVEL" , NULL,
    ''J: 190,000 - 249,999'' , "CUST_INCOME_LEVEL" ) "CUST_INCOME_LEVEL" ,
    DECODE ( "CUST_MARITAL_STATUS" , NULL,
    ''Married'' , "CUST_MARITAL_STATUS" ) "CUST_MARITAL_STATUS" ,
    DECODE ( "EDUCATION" , NULL,
    ''HS-grad'' , "EDUCATION" ) "EDUCATION" ,
    DECODE ( "FLAT_PANEL_MONITOR" , NULL,
    ''1'' , "FLAT_PANEL_MONITOR" ) "FLAT_PANEL_MONITOR" ,
    DECODE ( "HOME_THEATER_PACKAGE" , NULL,
    ''1'' , "HOME_THEATER_PACKAGE" ) "HOME_THEATER_PACKAGE" ,
    DECODE ( "HOUSEHOLD_SIZE" , NULL,
    ''3'' , "HOUSEHOLD_SIZE" ) "HOUSEHOLD_SIZE" ,
    DECODE ( "OCCUPATION" , NULL,
    ''Exec.'' , "OCCUPATION" ) "OCCUPATION" ,
    DECODE ( "OS_DOC_SET_KANJI" , NULL,
    ''0'' , "OS_DOC_SET_KANJI" ) "OS_DOC_SET_KANJI" ,
    DECODE ( "Y_BOX_GAMES" , NULL,
    ''0'' , "Y_BOX_GAMES" ) "Y_BOX_GAMES" ,
    "AFFINITY_CARD",
    "DMR$CASE_ID"
    FROM ');
    ls_append(v_tmp_lstmt, v_2d_view);
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view := v_2d_temp_view;
    ----- End: Missing Values Transformation -----
    ----- Start: Normalize Transformation -----
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt, 'SELECT
    "BOOKKEEPING_APPLICATION",
    "BULK_PACK_DISKETTES",
    "COUNTRY_NAME",
    "CUST_GENDER",
    "CUST_INCOME_LEVEL",
    "CUST_MARITAL_STATUS",
    "EDUCATION",
    "FLAT_PANEL_MONITOR",
    "HOME_THEATER_PACKAGE",
    "HOUSEHOLD_SIZE",
    "OCCUPATION",
    "OS_DOC_SET_KANJI",
    "Y_BOX_GAMES",
    "AFFINITY_CARD",
    "DMR$CASE_ID",
    LEAST(1, GREATEST(0, (ROUND(("AGE" - 17.0) / (79.77 - 17.0),15) * (1.0 - 0.0) + 0.0))) "AGE",
    LEAST(1, GREATEST(0, (ROUND(("YRS_RESIDENCE" - 0.0) / (10.0 - 0.0),15) * (1.0 - 0.0) + 0.0))) "YRS_RESIDENCE"
    FROM ');
    ls_append(v_tmp_lstmt, v_2d_view);
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view := v_2d_temp_view;
    ----- End: Normalize Transformation -----
    ----- Start: Stratified Split Transformation -----
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, GENERATE_STRATIFIED_SQL(v_2d_temp_view, v_2d_view, TARGET_VALUES_LIST('"BOOKKEEPING_APPLICATION"',
    '"BULK_PACK_DISKETTES"',
    '"COUNTRY_NAME"',
    '"CUST_GENDER"',
    '"CUST_INCOME_LEVEL"',
    '"CUST_MARITAL_STATUS"',
    '"EDUCATION"',
    '"FLAT_PANEL_MONITOR"',
    '"HOME_THEATER_PACKAGE"',
    '"HOUSEHOLD_SIZE"',
    '"OCCUPATION"',
    '"OS_DOC_SET_KANJI"',
    '"Y_BOX_GAMES"',
    '"AFFINITY_CARD"',
    '"DMR$CASE_ID"',
    '"AGE"',
    '"YRS_RESIDENCE"'), '"AFFINITY_CARD"', 60, ' < ' ));
    create_table_from_query(v_tmp_lstmt);
    v_2d_view_build := v_2d_temp_view;
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, GENERATE_STRATIFIED_SQL(v_2d_temp_view, v_2d_view, TARGET_VALUES_LIST('"BOOKKEEPING_APPLICATION"',
    '"BULK_PACK_DISKETTES"',
    '"COUNTRY_NAME"',
    '"CUST_GENDER"',
    '"CUST_INCOME_LEVEL"',
    '"CUST_MARITAL_STATUS"',
    '"EDUCATION"',
    '"FLAT_PANEL_MONITOR"',
    '"HOME_THEATER_PACKAGE"',
    '"HOUSEHOLD_SIZE"',
    '"OCCUPATION"',
    '"OS_DOC_SET_KANJI"',
    '"Y_BOX_GAMES"',
    '"AFFINITY_CARD"',
    '"DMR$CASE_ID"',
    '"AGE"',
    '"YRS_RESIDENCE"'), '"AFFINITY_CARD"', 60, ' >= ' ));
    create_table_from_query(v_tmp_lstmt);
    v_2d_view_test := v_2d_temp_view;
    ----- End: Stratified Split Transformation -----
    ----- Start: Mining Data Preparation -----
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt,
    'SELECT caseTable."AFFINITY_CARD"
    , caseTable."AGE"
    , caseTable."BOOKKEEPING_APPLICATION"
    , caseTable."BULK_PACK_DISKETTES"
    , caseTable."COUNTRY_NAME"
    , caseTable."CUST_GENDER"
    , caseTable."CUST_INCOME_LEVEL"
    , caseTable."CUST_MARITAL_STATUS"
    , caseTable."DMR$CASE_ID"
    , caseTable."EDUCATION"
    , caseTable."FLAT_PANEL_MONITOR"
    , caseTable."HOME_THEATER_PACKAGE"
    , caseTable."HOUSEHOLD_SIZE"
    , caseTable."OCCUPATION"
    , caseTable."OS_DOC_SET_KANJI"
    , caseTable."Y_BOX_GAMES"
    , caseTable."YRS_RESIDENCE"
    FROM ('); ls_append(v_tmp_lstmt, v_2d_view_build); ls_append(v_tmp_lstmt, ') caseTable
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view_build := v_2d_temp_view;
    v_tmp_lstmt.ub := 0; -- initialize
    v_2d_temp_view := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ls_append(v_tmp_lstmt, 'CREATE VIEW ');
    ls_append(v_tmp_lstmt, v_2d_temp_view);
    ls_append(v_tmp_lstmt, ' AS ');
    ls_append(v_tmp_lstmt, ' ( ');
    ls_append(v_tmp_lstmt,
    'SELECT caseTable."AFFINITY_CARD"
    , caseTable."AGE"
    , caseTable."BOOKKEEPING_APPLICATION"
    , caseTable."BULK_PACK_DISKETTES"
    , caseTable."COUNTRY_NAME"
    , caseTable."CUST_GENDER"
    , caseTable."CUST_INCOME_LEVEL"
    , caseTable."CUST_MARITAL_STATUS"
    , caseTable."DMR$CASE_ID"
    , caseTable."EDUCATION"
    , caseTable."FLAT_PANEL_MONITOR"
    , caseTable."HOME_THEATER_PACKAGE"
    , caseTable."HOUSEHOLD_SIZE"
    , caseTable."OCCUPATION"
    , caseTable."OS_DOC_SET_KANJI"
    , caseTable."Y_BOX_GAMES"
    , caseTable."YRS_RESIDENCE"
    FROM ('); ls_append(v_tmp_lstmt, v_2d_view_test); ls_append(v_tmp_lstmt, ') caseTable
    ls_append(v_tmp_lstmt, ' ) ');
    create_table_from_query(v_tmp_lstmt);
    v_2d_view_test := v_2d_temp_view;
    v_build_data := v_2d_view_build;
    v_test_data := v_2d_view_test;
    ----- End: Mining Data Preparation -----
    v_prior := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    EXECUTE IMMEDIATE 'CREATE TABLE ' || v_prior || ' (TARGET_VALUE VARCHAR2(4000), PRIOR_PROBABILITY NUMBER)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_prior || ' VALUES (''0'', 0.25333333333333335)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_prior || ' VALUES (''1'', 0.7466666666666666)';
    COMMIT;
    v_build_setting := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    EXECUTE IMMEDIATE 'CREATE TABLE ' || v_build_setting || ' (setting_name VARCHAR2(30), setting_value VARCHAR2(128))';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''JDMS_TARGET_NAME'', ''"AFFINITY_CARD"'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''SVMS_ACTIVE_LEARNING'', ''SVMS_AL_ENABLE'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''JDMS_FUNCTION_TYPE'', ''CLASSIFICATION'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''ALGO_NAME'', ''ALGO_SUPPORT_VECTOR_MACHINES'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''SVMS_CONV_TOLERANCE'', ''0.0010'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_build_setting || ' VALUES (''CLAS_PRIORS_TABLE_NAME'', :priorTable)' USING v_prior;
    COMMIT;
    -- BUILD MODEL
    DBMS_DATA_MINING.CREATE_MODEL(
    model_name => model_name,
    mining_function => dbms_data_mining.classification,
    data_table_name => v_build_data,
    case_id_column_name => v_case_id,
    target_column_name => 'AFFINITY_CARD',
    settings_table_name => v_build_setting);
    v_test_cm := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    EXECUTE IMMEDIATE 'CREATE TABLE ' || v_test_cm || ' (actual_target_value VARCHAR2(4000), predicted_target_value VARCHAR2(4000), cost NUMBER)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_test_cm || ' VALUES (''0'', ''0'', 0.0)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_test_cm || ' VALUES (''0'', ''1'', 1.0)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_test_cm || ' VALUES (''1'', ''0'', 1.0)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_test_cm || ' VALUES (''1'', ''1'', 0.0)';
    COMMIT;
    -- TEST MODEL
    IF (test_metric_name IS NOT NULL) THEN
    -- CREATE APPLY RESULT FOR TEST
    v_apply_result := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    DBMS_DATA_MINING.APPLY(
    model_name => model_name,
    data_table_name => v_test_data,
    case_id_column_name => v_case_id,
    result_table_name => v_apply_result);
    EXECUTE IMMEDIATE 'CREATE TABLE ' || test_metric_name || ' (METRIC_NAME VARCHAR2(30), METRIC_VARCHAR_VALUE VARCHAR2(31), METRIC_NUM_VALUE NUMBER)';
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''MODEL_NAME'', :model)' USING model_name;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''TEST_DATA_NAME'', :test_data)' USING v_test_data;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''MINING_FUNCTION'', ''CLASSIFICATION'')';
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''TARGET_ATTRIBUTE'', :target)' USING 'AFFINITY_CARD';
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''POSITIVE_TARGET_VALUE'', :target_value)' USING v_target_value;
    COMMIT;
    IF confusion_matrix_name IS NULL THEN
    v_confusion_matrix := ADD_TEMP_TABLE(v_tempTables, create_new_temp_table_name('DM$T'));
    ELSE
    v_confusion_matrix := confusion_matrix_name;
    END IF;
    DBMS_DATA_MINING.COMPUTE_CONFUSION_MATRIX (
    accuracy => v_accuracy,
    apply_result_table_name => v_apply_result,
    target_table_name => v_test_data,
    case_id_column_name => v_case_id,
    target_column_name => 'AFFINITY_CARD',
    confusion_matrix_table_name => v_confusion_matrix,
    score_column_name => 'PREDICTION',
    score_criterion_column_name => 'PROBABILITY',
    cost_matrix_table_name => v_test_cm);
    -- DBMS_OUTPUT.PUT_LINE('**** MODEL ACCURACY ****: ' || ROUND(accuracy, 4));
    IF (confusion_matrix_name IS NOT NULL) THEN
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_NUM_VALUE) VALUES (''ACCURACY'', :accuracy)' USING v_accuracy;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''CONFUSION_MATRIX_TABLE'', :confusion_matrix_name)' USING confusion_matrix_name;
    COMMIT;
    -- Average Accuracy
    EXECUTE IMMEDIATE '
    WITH
    a as
    (SELECT a.actual_target_value, sum(a.value) recall_total
    FROM ' || confusion_matrix_name || ' a
    group by a.actual_target_value)
    b as
    (SELECT count(distinct b.actual_target_value) num_recalls
    FROM ' || confusion_matrix_name || ' b)
    c as
    (SELECT c.actual_target_value, value
    FROM ' || confusion_matrix_name || ' c
    where actual_target_value = predicted_target_value)
    d as
    (SELECT sum(c.value/a.recall_total) tot_accuracy
    FROM a, c
    where a.actual_target_value = c.actual_target_value)
    SELECT d.tot_accuracy/b.num_recalls * 100 avg_accuracy
    FROM b, d' INTO v_avg_accuracy;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_NUM_VALUE) VALUES (''AVG_ACCURACY'', :avg_accuracy)' USING v_avg_accuracy;
    COMMIT;
    END IF;
    -- Predictive Confidence
    EXECUTE IMMEDIATE '
    WITH
    a as
    (SELECT a.actual_target_value, sum(a.value) recall_total
    FROM ' || v_confusion_matrix || ' a
    group by a.actual_target_value)
    b as
    (SELECT count(distinct b.actual_target_value) num_classes
    FROM ' || v_confusion_matrix || ' b)
    c as
    (SELECT c.actual_target_value, value
    FROM ' || v_confusion_matrix || ' c
    where actual_target_value = predicted_target_value)
    d as
    (SELECT sum(c.value/a.recall_total) tot_accuracy
    FROM a, c
    where a.actual_target_value = c.actual_target_value)
    SELECT (1 - (1 - d.tot_accuracy/b.num_classes) / GREATEST(0.0001, ((b.num_classes-1)/b.num_classes))) * 100
    FROM b, d' INTO v_predictive_confidence;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_NUM_VALUE) VALUES (''PREDICTIVE_CONFIDENCE'', :predictive_confidence)' USING v_predictive_confidence;
    COMMIT;
    IF lift_result_name IS NOT NULL AND v_target_value IS NOT NULL THEN
    DBMS_DATA_MINING.COMPUTE_LIFT (
    apply_result_table_name => v_apply_result,
    target_table_name => v_test_data,
    case_id_column_name => v_case_id,
    target_column_name => 'AFFINITY_CARD',
    lift_table_name => lift_result_name,
    positive_target_value => v_target_value,
    num_quantiles => v_num_quantiles,
    cost_matrix_table_name => v_test_cm);
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''LIFT_TABLE'', :lift_result_name)' USING lift_result_name;
    COMMIT;
    END IF;
    IF roc_result_name IS NOT NULL AND v_target_value IS NOT NULL THEN
    DBMS_DATA_MINING.COMPUTE_ROC (
    roc_area_under_curve => v_area_under_curve,
    apply_result_table_name => v_apply_result,
    target_table_name => v_test_data,
    case_id_column_name => v_case_id,
    target_column_name => 'AFFINITY_CARD',
    roc_table_name => roc_result_name,
    positive_target_value => v_target_value,
    score_column_name => 'PREDICTION',
    score_criterion_column_name => 'PROBABILITY');
    -- DBMS_OUTPUT.PUT_LINE('**** AREA UNDER ROC CURVE ****: ' || area_under_curve );
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_VARCHAR_VALUE) VALUES (''ROC_TABLE'', :roc_result_name)' USING roc_result_name;
    EXECUTE IMMEDIATE 'INSERT INTO ' || test_metric_name || ' (METRIC_NAME, METRIC_NUM_VALUE) VALUES (''AREA_UNDER_CURVE'', :v_area_under_curve)' USING v_area_under_curve;
    COMMIT;
    END IF;
    END IF;
    DROP_TEMP_TABLES(v_tempTables);
    EXCEPTION WHEN OTHERS THEN
    DROP_TEMP_TABLES(v_tempTables);
    RAISE;
    END;
    END;
    /

  • What data type is used for storing password,

    What data type is used for storing pass word in oracle db, i mean if user inputs some thing from forms it should be in Encrypted form in db, please any help??
    Thank you
    Hina

    Data type is VARCHAR2:
    SQL> desc dba_users;
    Name                                      Null?    Type
    USERNAME                                  NOT NULL VARCHAR2(30)
    USER_ID                                   NOT NULL NUMBER
    PASSWORD                                           VARCHAR2(30)
    ACCOUNT_STATUS                            NOT NULL VARCHAR2(32)
    LOCK_DATE                                          DATE
    EXPIRY_DATE                                        DATE
    DEFAULT_TABLESPACE                        NOT NULL VARCHAR2(30)
    TEMPORARY_TABLESPACE                      NOT NULL VARCHAR2(30)
    CREATED                                   NOT NULL DATE
    PROFILE                                   NOT NULL VARCHAR2(30)
    INITIAL_RSRC_CONSUMER_GROUP                        VARCHAR2(30)
    EXTERNAL_NAME                                      VARCHAR2(4000)
    PASSWORD_VERSIONS                                  VARCHAR2(8)
    EDITIONS_ENABLED                                   VARCHAR2(1)
    AUTHENTICATION_TYPE                                VARCHAR2(8)You can use SQL function ORA_HASH to hash password: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions124.htm#SQLRF06313.

  • What encryption method is used for built-in password manager?

    What changes were made between versions 3.6 and 4?

    Data type is VARCHAR2:
    SQL> desc dba_users;
    Name                                      Null?    Type
    USERNAME                                  NOT NULL VARCHAR2(30)
    USER_ID                                   NOT NULL NUMBER
    PASSWORD                                           VARCHAR2(30)
    ACCOUNT_STATUS                            NOT NULL VARCHAR2(32)
    LOCK_DATE                                          DATE
    EXPIRY_DATE                                        DATE
    DEFAULT_TABLESPACE                        NOT NULL VARCHAR2(30)
    TEMPORARY_TABLESPACE                      NOT NULL VARCHAR2(30)
    CREATED                                   NOT NULL DATE
    PROFILE                                   NOT NULL VARCHAR2(30)
    INITIAL_RSRC_CONSUMER_GROUP                        VARCHAR2(30)
    EXTERNAL_NAME                                      VARCHAR2(4000)
    PASSWORD_VERSIONS                                  VARCHAR2(8)
    EDITIONS_ENABLED                                   VARCHAR2(1)
    AUTHENTICATION_TYPE                                VARCHAR2(8)You can use SQL function ORA_HASH to hash password: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions124.htm#SQLRF06313.

  • Materialized view not properly refreshing

    Hi,
    As materialized view is not refreshing properly. we compare the sum of hashcode materialized view with the sum of hash code of the base view or table the materialized view is defined. If it's found equal then materialized view got refreshed succesfully else not.
    But in below example the column value is interchanged in between the row eventhough hashcode is same.
    Is there any other way to find the materialized view got refreshed successfully or not.
    SQL> create table temp as select object_name, subobject_name from user_objects where rownum<3;
    Table created
    SQL> select * from temp;
    OBJECT_NAME SUBOBJECT_NAME
    ATP_BN_I_1
    ATP_START_END_DATE_I_2
    SQL> create materialized view mv1 as select * from temp;
    Materialized view created
    SQL> select * from mv1;
    OBJECT_NAME SUBOBJECT_NAME
    ATP_BN_I_1
    ATP_START_END_DATE_I_2
    SQL> select sum(nvl(ora_hash("OBJECT_NAME"||"SUBOBJECT_NAME"),0)) from temp;
    SUM(NVL(ORA_HASH("OBJECT_NAME"
    4852176374
    SQL> select sum(nvl(ora_hash("OBJECT_NAME"||"SUBOBJECT_NAME"),0)) from MV1;
    SUM(NVL(ORA_HASH("OBJECT_NAME"
    4852176374
    SQL> UPDATE TEMP SET OBJECT_NAME=SUBOBJECT_NAME,SUBOBJECT_NAME=OBJECT_NAME;
    2 rows updated
    SQL> COMMIT;
    Commit complete
    SQL> select * from mv1;
    OBJECT_NAME SUBOBJECT_NAME
    ATP_BN_I_1
    ATP_START_END_DATE_I_2
    SQL> select * from temp;
    OBJECT_NAME SUBOBJECT_NAME
    ATP_BN_I_1
    ATP_START_END_DATE_I_2
    SQL> select sum(nvl(ora_hash("OBJECT_NAME"||"SUBOBJECT_NAME"),0)) from MV1;
    SUM(NVL(ORA_HASH("OBJECT_NAME"
    4852176374
    SQL> select sum(nvl(ora_hash("object_name"||"subobject_name"),0)) from temp;
    select sum(nvl(ora_hash("object_name"||"subobject_name"),0)) from temp
    ORA-00904: "subobject_name": invalid identifier
    SQL> select sum(nvl(ora_hash("OBJECT_NAME"||"SUBOBJECT_NAME"),0)) from temp;
    SUM(NVL(ORA_HASH("OBJECT_NAME"
    4852176374
    Any help really appreciated.
    Thanks in advance.

    unique wrote:
    Is there any other way to find the materialized view got refreshed successfully or not.You can look at the last_refresh_date and staleness columns of all_mviews: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1105.htm#REFRN20139
    Or maybe use the all_mview_refresh_times view: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1104.htm#sthref1068
    Regards,
    Rob.

  • Plz help me to understand sql trace

    Hi,
    i need your help to understand the sql trace and where exactly i should concentrate,
    i am also going through docs,
    your help is appreciated,
    select count(rep)
    from
    (select /*+ leading(v1 v2) use_nl_with_index(v2) */ count(v1.val) rep from
      (select rn, val from (select rownum rn, val from (select /*+ no_merge
      no_parallel(t) no_parallel_index(t) dbms_stats cursor_sharing_exact
      use_weak_name_resl dynamic_sampling(0) no_monitoring */"FFPR_FFAMS_ID" val
      from sys.ora_temp_1_ds_108308 t where "FFPR_FFAMS_ID" is not null group by
      "FFPR_FFAMS_ID" having count("FFPR_FFAMS_ID") = 1)) where ora_hash(rn) <=
      273538662) v1, (select /*+ index(t2) */ "FFPR_FFAMS_ID" val from
      "DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS" t2) v2 where v2.val = v1.val
      group by v1.val having count(v1.val) <= 2)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.29          0       8131          0           1
    total        3      0.00       0.30          0       8131          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 213     (recursive depth: 1)
    select /*+ no_parallel_index(t,"FFPR_FFAMS_FK_I") dbms_stats
      cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring
      no_expand index(t,"FFPR_FFAMS_FK_I") */ count(*) as nrw,count(distinct
      sys_op_lbid(692895,'L',t.rowid)) as nlb,count(distinct "FFPR_FFAMS_ID") as
      ndk,sys_op_countchg(substrb(t.rowid,1,15),1) as clf
    from
    "DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS" t where ("FFPR_FFAMS_ID" is not
      null) and (TBL$OR$IDX$PART$NUM("DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS",
      0,4,0,"ROWID") = :objn)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       2.56          0        425          0           1
    total        3      0.00       2.56          0        425          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 213     (recursive depth: 1)
    select /*+ no_parallel_index(t,"FFPR_FFAMS_FK_I") dbms_stats
      cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring
      no_expand index(t,"FFPR_FFAMS_FK_I") */ count(*) as nrw,count(distinct
      sys_op_lbid(692895,'L',t.rowid)) as nlb,count(distinct "FFPR_FFAMS_ID") as
      ndk,sys_op_countchg(substrb(t.rowid,1,15),1) as clf
    from
    "DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS" t where "FFPR_FFAMS_ID" is not
      null
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       2.56          0        427          0           1
    total        3      0.00       2.56          0        427          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 213     (recursive depth: 1)
    select /*+ no_parallel_index(t,"FFPR_PK_I") dbms_stats cursor_sharing_exact
      use_weak_name_resl dynamic_sampling(0) no_monitoring no_expand index(t,
      "FFPR_PK_I") */ count(*) as nrw,count(distinct sys_op_lbid(692907,'L',
      t.rowid)) as nlb,null as ndk,sys_op_countchg(substrb(t.rowid,1,15),1) as
      clf
    from
    "DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS" t where ("FFPR_ID" is not null
      or "FFPR_PLAN_NAME" is not null) and
      (TBL$OR$IDX$PART$NUM("DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS",0,4,0,
      "ROWID") = :objn)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       1.51        847        857          0           1
    total        3      0.00       1.52        847        857          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 213     (recursive depth: 1)
    select /*+ no_parallel_index(t,"FFPR_PK_I") dbms_stats cursor_sharing_exact
      use_weak_name_resl dynamic_sampling(0) no_monitoring no_expand index(t,
      "FFPR_PK_I") */ count(*) as nrw,count(distinct sys_op_lbid(692907,'L',
      t.rowid)) as nlb,null as ndk,sys_op_countchg(substrb(t.rowid,1,15),1) as
      clf
    from
    "DM_FM_REPORTING_OWNER"."FM_FP_PLAN_RESULTS" t where "FFPR_ID" is not null
      or "FFPR_PLAN_NAME" is not null
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       1.26          0        850          0           1
    total        3      0.00       1.27          0        850          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 213     (recursive depth: 1)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       13      0.00       0.03          0          0          0           0
    Execute     13      0.00       1.32         43        242         29           9
    Fetch        4      0.00       0.00          0          0          0           4
    total       30      0.00       1.36         43        242         29          13
    Misses in library cache during parse: 4
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse     2945      0.00       1.04          0          0          0           0
    Execute   3741      0.00       5.49       3137      12995       7050      203362
    Fetch     3088      0.00      38.42       3344      39486         27        9811
    total     9774      0.00      44.96       6481      52481       7077      213173
    Misses in library cache during parse: 284
    Misses in library cache during execute: 160
      144  user  SQL statements in session.
    2814  internal SQL statements in session.
    2958  SQL statements in session.Regards
    nic

    Hi,
    i did the homework, but some how i dont seem to understand what oracle is doing behind
    esp with hints like
    select /*+ leading(v1 v2) use_nl_with_index(v2) */ count(v1.val)
    /*+ no_parallel(t) no_parallel_index(t) dbms_stats
      cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring
    substrb(dump(min("XXX"),16,0,32),1,120),
      substrb(dump(max("XXX"),16,0,32),1,120),i havent used this things any where in my program, but still they are used,
    so i got confused, can you throw some light on this issue,
    regards
    nic

  • Need clarification on doing bulk updates

    Hi All,
    I got a requirement where I need to insert around 100 Million records and do updates on the entire content of the table.
    Requirement is I have a customer order table as given below
    CREATE TABLE customer_order(group_no number, order_no number) nologging no compress parallel 10;
    This is going to have millions of rows (100 Million ).
    When we are inserting the data we are inserting only order_no.
    After insertion we need to update the group_no for all these orders. Here every 1000 order_no should have one group_no assigned to it. But when are picking up the 1000 order_no's those 1000 should be randomly picked up from the table and fors those 1000 orders we need to assign group no.
    We are able to insert 100 Million rows into this table in under 5 minutes. (FYI there are no indexes on this table as we found indexes are of no use here and creation of indexes itself is taking more than 3 hours and the index size is greater than table size).
    To get the random order numbers when are using DBMS_RANDOM..VALUE package it is taking for ever. Can anyone let us know how to tackle this challenging situation.
    Appreciate your inputs here.
    Thanks,
    Maddy.

    Do you need exactly 1000 order_no per group_no? If close enough is good enough I'd use:
    INSERT
      INTO customer_order
      SELECT  ora_hash(level,100000 - 1),
              level
        FROM  dual
        CONNECT BY level <= 100000000
    /For example:
    SQL> CREATE TABLE customer_order(group_no number, order_no number)
      2  /
    Table created.
    SQL> INSERT
      2    INTO customer_order
      3    SELECT  ora_hash(level,10 - 1),
      4            level
      5      FROM  dual
      6      CONNECT BY level <= 10000
      7  /
    10000 rows created.
    SQL> select  group_no,
      2          count(*),
      3          min(order_no),
      4          max(order_no)
      5    from  customer_order
      6    group by group_no
      7  /
      GROUP_NO   COUNT(*) MIN(ORDER_NO) MAX(ORDER_NO)
             1       1001             4          9992
             6        991             2          9999
             2        989             6          9995
             4        989            18         10000
             5       1028            37          9996
             8       1006             5          9990
             7       1021             1          9988
             3        973            10          9998
             9        985             3          9977
             0       1017             8          9986
    10 rows selected.
    SQL> As you can see number of order_no per group no is close enough to 1000 and order_no within group_no are mixed (not sequential). And in any case, it would be more efficient to populate both order_no and group_no in single insert and then, if you need exact count per group no, issue smaller update.
    SY.

Maybe you are looking for

  • CIN Import process problem

    Hello, We have CIN import process in which client does not wants to use CVD conditions ( JCV1, JECV, J1CV). We wants to use only JADC and JCDB conditions. Process : 1. Create PO with conditions JADC and JCDB and some more Z conditions. 2. Bill of ent

  • Optional prompt value to be set from java bo sdk

    hi i am trying to refresh a report which has 4 prompts 2 of them are mandatory and 2 of them are optional. Please find the code below Prompts prompts = di.getPrompts();            if(prompts != null){                    promptCount = prompts.getCount

  • How to check the performance of the database instance in oracle apps 11i

    hii everybody, i want to know,how to check the performance of the database instance using oracle applications 11i.your help highly appreciated,thanks.

  • Since I downloaded the free upadted version,I cannot cut and paste

    I know that my mouse is working. but this happened since Friday. I tried to change the setting on the mouse but I still am unablea to cut and pasteed

  • New site created with Muse

    Why does my Muse site seem to "jumpy" when I navigate through it online and why are my navigation tabs larger online then when I view them in "muse"? http://www.roserwilliams.com Thank you Jody