Wierd error in PL/SQL Package

I have a package that does a global update of a rather large and complicated table schema. It had been working fine but, over the weekend, it failed after processing approximately 9,000 of 10,000 records with this error:
ORA-01031 Insufficient Privileges
Now, I can understand if the silly thing NEVER worked, but WHY would I get THIS error after I've processed most of the records. The database is in 9i ver 2.
I've looked through the code and I can't see anywhere where it would be changing the USERID or password or anything like that so I'm a little stumped. Any and all assistance gratefully appreciated.
Leigh Smith

This is strange. The error that comes up for the insufficient privs is normally due to the privs being granted from the roles and tried to be used in the packages/procedures. That gives us the insufficient priviledge error. But , if it worked before, it should work now too.
Try granting the user running this package a direct priviledge over the underlying table if you can and see if it changes some thing. Otherwise, probably a more thorough check over the lines of the code would be required.
What's the database version and o/s?
HTH
Aman....

Similar Messages

  • CDS-11025 Error: Oracle Designer generation error with PL/SQL package

    Hi friends,
    We tried to generate a database package from Oracle Designer (10.1.2.6) and getting "syntax errors" but the package has no syntax errors when we copy and paste the code and compile in TOAD (10.6)
    Error from Designer:
    Server Generator 10.1.2.6 (Build 10.1.2.11.12) , Wed Oct 17 10:58:43 2012
    Copyright (c) Oracle Corporation 1995, 2010. All rights reserved.
    CDS-11025 Error: The PL/SQL within PACKAGE BODY AVP_WATER_ANALYSIS_V has syntax errors - At token 'END', around:
    ...te_dist.VLV_INTL_ID;
    END LOOP;
    Processing Complete: 1 error(s), 0 warning(s)
    code snippet from the Error message:
    FOR rec_update_dist IN cur_update_dist (i_anlyd_intl_id,
    i_iterd_intl_id,
    i_phsed_intl_id,
    i_wtrc_intl_id)
    LOOP
    UPDATE AVP_VALVE AvpValve
    SET AvpValve.DIST_FROM_EDGE = rec_update_dist.DIST_FROM_EDGE
    WHERE AvpValve.ANLYD_INTL_ID = rec_update_dist.ANLYD_INTL_ID
    AND AvpValve.ITERD_INTL_ID = rec_update_dist.ITERD_INTL_ID
    AND AvpValve.PHSED_INTL_ID = rec_update_dist.PHSED_INTL_ID
    AND AvpValve.WTRC_INTL_ID = rec_update_dist.WTRC_INTL_ID
    AND AvpValve.VLV_INTL_ID = rec_update_dist.VLV_INTL_ID;
    END LOOP;
    Thanks for any feedback,
    Jim

    Found the problem.
    It was an issue with the CURSOR with the SELECT ... FROM (SELECT CASE WHEN THEN ELSE END). After swithing to the DECODE statement, Designer is able to generate the package.
    CASE
    WHEN ISOLATION_IND = 'Y' THEN
    'A'
    WHEN OPERATED_IND = 'Y' THEN
    'B'
    ELSE
    'C'
    END
    decode(ISOLATION_IND,'Y','A',decode(OPERATED_IND,'Y','B','C'))
    However, still strange to me that Designer doesn't like the CASE as part of SELECT.
    Edited by: user476620 on Oct 18, 2012 8:13 PM

  • Error with PL/SQL package

    Hi ,
    I have written a package specification given below :
    create or replace PACKAGE BILL_PACKAGE AS
    storeId varchar2(5);
    startDate varchar2(10);
    FUNCTION F_Bill(str_id IN tel_tr_ltm_bl_py.id_str_rt%TYPE,ws_id IN tel_tr_ltm_bl_py.id_ws%TYPE,v_date IN tel_tr_ltm_bl_py.dc_dy_bsn%TYPE) RETURN boolean;
    END BILLPAYPACKAGE;
    I have written the package body also .Now when i am calling the function F_Bill , I am gettin this error :
    PLS-00201: identifier 'BILL_PACKAGE.STARTDATE' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 3, column 1:
    PLS-00201: identifier 'BILL_PACKAGE.STOREID' must be declared
    ORA-06550: line 3, column 1:
    PL/SQL: Statement ignored
    This same package is running fine on another local database.
    What could be the reason for this?
    Is this an acess issue ?In db which we are getting an error , we are using a user 'ConUser' to connect to a schema 'b_owner'.
    How can we check this if this is a privilege issue.
    Thanks!

    >
    This same package is running fine on another local database.
    What could be the reason for this?
    Is this an acess issue ?In db which we are getting an error , we are using a user 'ConUser' to connect to a schema 'b_owner'.
    How can we check this if this is a privilege issue.The user "ConUSer" needs execute privileges for the pacakge.
    Also it depends how he calls the package or the variables in it.
    You can check the privs with
    select * from all_tab_privs where table_name = 'BILL_PACKAGE';this must be run as user ConUser.
    You could also have a problem with name resolution. The name of the package is not BILL_PACKAGE. It is "b_owner.BILL_PACKAGE".
    If you omit the schema name then the current user is tried. So if you call BILL_PACKAGE then this is translated into "ConUSer.BILL_PACKAGE".
    You can change this by creating a synonym like
    create synonym bill_package for b_owner.bill_package;

  • Error returned using SQL package

    Hi,
    I'm trying to connect to a database using the example code supplied in the docs here at java but I am getting the following error.
    Error: The name "SQLWarning" is not declared as a type. : C:\Program Files\Asymetrix\SuperCede\Projects\Project1\Component3\Source1.java (133)
    1. Can anyone explain this
    2. Is there an online database/listing of compiler error messages that explain javac error messages in more detail.
    thanks,
    Remo

    Asymetrix SuperCede - Applet EditionOK, I'm not sure what this is. Is it an alternative comppiler or is it an IDE that uses Sun's standard compiler to do compilation.
    I'm guessing it doesn't use Sun's compiler as that doesn't seem like a standard compilation error. Maybe you should try using the standard JDK and see if that works.
    Also, I suggest that a database of compilation errors would need to be Asymetrix SuperCede specific if it is an alternative compiler.

  • Error when publishing a PL/SQL package as a Webservice

    Hi all,
    I am using the JDeveloper (10.1.3.1.0) to publish a PL/SQL package as a Webservice, and I am having some troubles on the generation process.
    The problem that I am facing is on the generated code for the database side, where some methods have a “$GET_” at the end of its name.
    This “$GET_” is handled by the database as a special word, and the package can’t be compiled.
    If the ‘$’ character is removed from all the methods, the package can be compiled and the Webservice works fine.
    What’s wrong? Is there a bug on the generation process of the JDeveloper?
    Regards,
    Rui Torres

    OK, This is the PL/SQL package:
    Function:
    FUNCTION Obtener_paises RETURN res_webservice AS
    v_respuesta res_webservice;
    i PLS_INTEGER:=1;
    CURSOR C_paises IS
    SELECT cpais, tpais
    FROM paises
    ORDER BY tpais;
    BEGIN
    v_respuesta := res_webservice(null,null);
    v_respuesta.error := res_error(null,null,null);
    v_respuesta.error.cerror := 0;
    v_respuesta.error.cerror_ora := 0;
    v_respuesta.error.terror := null;
    v_respuesta.datos := res_datos ();
    FOR v_pais IN C_paises LOOP
    v_respuesta.datos.extend;
    v_respuesta.datos(i) := reg_datos(null,null);
    v_respuesta.datos(i).codigo := v_pais.cpais;
    v_respuesta.datos(i).descripcion := v_pais.tpais;
    i := i + 1;
    END LOOP;
    Insertar_log(NULL,SYSDATE,'C','Obtener_paises',NULL,'ERROR:0');
    RETURN v_respuesta;
    EXCEPTION
    WHEN OTHERS THEN
    v_respuesta.error.cerror := 1;
    v_respuesta.error.cerror_ora := SQLCODE;
    v_respuesta.error.terror := substr(SQLERRM,1,80);
    Insertar_log(NULL,SYSDATE,'C','Obtener_paises',NULL,'ERROR:1 '||substr(SQLERRM,1,120));
    RETURN v_respuesta;
    END Obtener_paises;
    TYPES USED:
    CREATE OR REPLACE
    TYPE res_webservice AS OBJECT (error res_error, datos res_datos);
    CREATE OR REPLACE
    TYPE res_error AS OBJECT (cerror NUMBER(1), cerror_ora VARCHAR2(12), terror VARCHAR2(80));
    CREATE OR REPLACE
    TYPE res_datos AS TABLE OF reg_datos;
    CREATE OR REPLACE
    TYPE reg_datos AS OBJECT(codigo VARCHAR2(12), descripcion VARCHAR2(150));
    Thanks in advanced...
    Could happen this bacause of these defined types???

  • 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;
    /

  • Getting an error running an SSIS package from SQL server agent

    This is the first time I'm running an SSIS package in SQL server agent.
    I'm running a SQL server agent job and getting this error message:
    Am I using the correct options? (options list below)
    Message
    Executed as user: SITEX\stxdatasqlexec. Microsoft (R) SQL Server Execute Package Utility  Version 10.50.1600.1 for 32-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  1:42:00 PM  Error: 2014-04-17
    13:42:01.01     Code: 0xC0011007     Source: {B72BF421-785A-44EC-9570-D2A40B046CA7}      Description: Unable to load the package as XML because of package does not have a valid XML format. A
    specific XML parser error will be posted.  End Error  Error: 2014-04-17 13:42:01.02     Code: 0xC0011002     Source: {B72BF421-785A-44EC-9570-D2A40B046CA7}      Description: Failed
    to open package file "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx" due to error 0x80070003 "The system cannot find the path specified.".  This happens when loading a package and the file cannot be opened or loaded correctly
    into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  End Error  Could not load package "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx"
    because of error 0xC0011002.  Description: Failed to open package file "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx" due to error 0x80070003 "The system cannot find the path specified.".  This happens when loading a
    package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  Source:
    {B72BF421-785A-44EC-9570-D2A40B046CA7}  Started:  1:42:00 PM  Finished: 1:42:01 PM  Elapsed:  0.047 seconds.  The package could not be found.  The step failed.
    Here are the options I'm using:
    package source - file system
    data source  destination = my SQL server db
    execution option - use 32 bit runtime
    command line entry:
    - /FILE "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx"  /CONNECTION DestinationConnectionOLEDB;"\"Data Source=esxdspr-sql01.sitex.com;Initial Catalog=SuesTbls;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=false;\""
    /CONNECTION SourceConnectionFlatFile;"\\sitex.com\dfs\Production\SFTPData\LPSEFTProcess\FromAADFS\Rpt_Nbr_Rollsperbatch_20140331_20_0.txt"
    /X86  /CHECKPOINTING OFF /REPORTING E
    I checked the filename so it must be the XML format it's complaining about.

    Thank you, pituach.
    I tried running the package using just my c drive without partition, C:\Nbr_Rolls.dtsx, but still getting the same
    error. I do not see any option on this site to post my package. I know it's not the path that's the issue. Our support desk already fixed that because I was getting a different message before.
    Message
    Executed as user: SITEX\stxdatasqlexec. Microsoft (R) SQL Server Execute Package Utility  Version 10.50.1600.1 for 32-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  11:23:00 AM  Error: 2014-04-18
    11:23:00.44     Code: 0xC0011007     Source: {2BEE62EB-DD08-4867-9F5C-660167964650}      Description: Unable to load the package as XML because of package does not have a valid XML format. A
    specific XML parser error will be posted.  End Error  Error: 2014-04-18 11:23:00.45     Code: 0xC0011002     Source: {2BEE62EB-DD08-4867-9F5C-660167964650}      Description: Failed
    to open package file "C:\Nbr_Rolls.dtsx" due to error 0x800C0006 "The system cannot locate the object specified.".  This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of
    either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  End Error  Could not load package "C:\Nbr_Rolls.dtsx" because of error 0xC0011002.  Description: Failed
    to open package file "C:\Nbr_Rolls.dtsx" due to error 0x800C0006 "The system cannot locate the object specified.".  This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of
    either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  Source: {2BEE62EB-DD08-4867-9F5C-660167964650}  Started:  11:23:00 AM  Finished: 11:23:00 AM 
    Elapsed:  0.125 seconds.  The package could not be found.  The step failed.

  • Starting Rman getting error PL/SQL package not current

    I come across a problem. My server is windows 2003 and Oracle is 10g Release 2.
    My previous DBA install Oracle 10g R1, 10gR2 and Oracle Data Warehouse Builder 10g on the same server at different Oracle_Home. When I came to this work. I tried to use Rman for backup. When i went to server command line, type Rman, Rman target /. the error message was:
    PL/SQL package SYS.DBMS_BACKUP_RESTORE version 10.02.00.02 in TARGET database is not current and PL/SQL package SYS.DBMS_RCVMAN version 10.02.00.02 in TARGET database is not current.
    I found the solution from oracle_metalink ( Note:429499.1). I followed note to use Oracle Universal Installer to move the 10.2.0.2 home. Then I can start Rman. Then I fixed some other small errors. I came back to loginto Rman. The system told me the same errors. I used Oracle Installer to check the Oracle_Home. Only two home exist. One is 10gR2 10.2.0.2. Another one is data warehouse builder with version 10.2.0.3. So it seems that 10gR2 Home is not current. How can I remove this Oracle_Home? If I remove it off, database will be dead. So if I remove oracle data warehouse builder, will it make two PL/SQL package for Rman current? or I have to remove DW builder first, then patch 10gR2 Home to 10.2.0.3? Please help. Thanks.

    damorgan:
    No. it is not related to oracle_home and oracle_sid. It is related to PATH setting. I have solved the problem. Thanks for your comment.

  • ORA-06502: PL/SQL: numeric or value error ORA-06512: at "package.proc

    Hi,
    I'm getting the following error , when calling a procedure. Any input appreciated please
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "package.procedure ", line 513
    ORA-06512: at line 26
    v_counter     NUMBER;
    v_counter := 0; -- line number 513
    FOR i in p_rec_attr.FIRST..p_rec_attr.LAST
    LOOP
    --IF instr(p_rec_attr(i),'=')<>0 THEN
    IF v_counter = 0 THEN
    soap_request := soap_request||'<doc:attributes>
    <!--Zero or more repetitions:-->
    <doc:CategoryAttributeVO>
    <!--Optional:-->
    <doc:name>'||substr(p_rec_attr(i),1,instr(p_rec_attr(i),'=')-1)||'</doc:name>
    <!--Optional:-->
    <doc:value>'||substr(p_rec_attr(i),instr(p_rec_attr(i),'=')+1)||'</doc:value>
    </doc:CategoryAttributeVO>';
    v_counter := v_counter + 1;
    ELSE
    IF i=p_rec_attr.last THEN
    v_category_name := p_rec_attr(i);
    soap_request := soap_request||'
    </doc:attributes>
    <!--Optional:-->
    <doc:name>'||v_category_name||'</doc:name>';
    v_counter := 0;
    ELSE
    soap_request := soap_request||'
    <!--Zero or more repetitions:-->
    <doc:CategoryAttributeVO>
    <!--Optional:-->
    <doc:name>'||substr(p_rec_attr(i),1,instr(p_rec_attr(i),'=')-1)||'</doc:name>
    <!--Optional:-->
    <doc:value>'||substr(p_rec_attr(i),instr(p_rec_attr(i),'=')+1)||'</doc:value>
    </doc:CategoryAttributeVO>';
    v_counter := v_counter + 1;
    END IF;
    END IF;
    --ELSE
    --END IF;
    END LOOP;
    Thanks

    Hi
    I tried this which is :
    create or replace
    procedure test is
    v_counter     NUMBER;
    begin
    v_counter := 0; -- line number 513
    FOR i in 1..10
    LOOP
    --IF instr(p_rec_attr(i),'=')0 THEN
    IF v_counter = 0 THEN
    v_counter := v_counter + 1;
    ELSE
    IF i=9 THEN
    v_counter := 0;
    ELSE
    v_counter := v_counter + 1;
    END IF;
    END IF;
    END LOOP;
    end;
    Which does ot throw any error...I think it is being generated from somewhere else

  • Service_doctor.sql -- There are errors in one or more PL/SQL package

    Hi,
    Script service_doctor.sql is run through repository owner. It is giving following error message.
    There are errors in one or more PL/SQL packages and functionPlatform properties have been loaded correctly
    Platform location has been seeded correctly
    NLS messages have been loaded correctly
    The platform service is not availableService script is accessible to the database server
    Connection information stored within the repository is correct
    PL/SQL procedure successfully completed.
    Please guide me what can be done to solve the error.
    Thank you in advance.
    Amit Shah.

    Hi Amit,
    I am facing this error every time I run the service_doctor.sql. After that once I have executed this script -- select * from user_errors -- to see what possibly could be wrong. It returned me one procedure name -- WB_OLAP_LOAD_DIMENSION_GENUK. But I was not very sure what to do with this.
    Now also I am getting the same error --- >>>>>> There are errors in one or more PL/SQL packages and function. But it didn't stop me from doing anything in OWB / Process flow / Workflow environment and I can work fine.
    Just wanted to share this with you. However, the result that you are getting shows (>>>>>> The platform service is not available) that Control center service is not up. Please execute the start_service.sql and after that it you run service_doctor again, you'll get only the first error -- >>>>>> There are errors in one or more PL/SQL packages and function --- but that shouldn't stop you from doing anything in OWB.
    If anyone knows what causes the --- >>>>>> There are errors in one or more PL/SQL packages and function -- error, and what are the implications of this in OWB environment, and what is the solution to it, please do share.
    Cheers,
    Swagata

  • "There are errors in one or more PL/SQL packages and functions"

    Hi all,
    first of all - my configuration:
    - OWB 10.0.3.0
    - one Server HP-UX
    - two oracle database instances (plato and platodev)
    My problem:
    when i try to start "Deployment Manager" and try to connect to the platodev instance i get the RTC-5260 and ORA-01017.
    I have no problems to connect to the second instance "plato".
    The output of service_doctor is as followed:
    ===================
    SQL> @service_doctor
    There are errors in one or more PL/SQL packages and functionsPlatform properties have been loaded correctly
    Platform location has been seeded correctly
    NLS messages have been loaded correctly
    The platform service is available
    There is a problem accessing the service startup script from the databaseserver
    Here is the detailed error message which contains the name of the startscript file:-
    The runtime property 'service_command' either does not exist orcannot be read successfully
    oracle.jdbc.driver.OracleSQLException: ORA-00942:
    table or view does not exist
    Please verify that the disk containing the file is visible to thedatabase server
    Please verify that the database server account has access rights on thefile
    There is a problem with the repository connection information used tostart the service
    Here is the detailed error message which contains the connectioninformation passed to the service:-
    Cannot retrieve the repository owner host, port, service-name fromwithin the database server
    Please verify that this information is accurate
    If this information is correct, then please use the'set_repository_password.sql' script to reset the stored password
    PL/SQL procedure successfully completed.
    ================================0
    I did not change the password.
    Can anyone help me?
    I appreciate your help.
    Thank you

    Solved!
    It was a wrong entry in wb_rt_service_nodes column service_name.

  • Error in recompiling a PL/SQL package

    Hi,
    When I updated my function for the PL/SQL package, I get this error. Any help would be great. Thanks.
    create or replace package packagename as
    ERROR at line 1:
    ORA-00955: name is already used by an existing object

    Hi,
    You can't have a stand-alone function and a package with the same name.
    "DROP" the function, then "CREATE OR REPLACE" the package.
    CREATE OR REPLACE PACKAGE packagename ..." is equivalent to
    DROP PACKAGE packagename, followed by
    CREATE PACKAGE packagename.
    The only difference is that
    DROP PACKAGE packagename will give you an error message when a package called packagename doesn't already exist, and
    CREATE OR REPLACE PACKAGE packagename won't.
    Neither
    DROP PACKAGE packagename nor
    CREATE OR REPLACE PACKAGE packagename will drop any other kind of object that happens to be named packagename, such as a table, view, user, procedure, or, in your case, function.

  • Error with Oracle10G Sql Browser while execute package with exec clause

    Dear Experts,
    Please tell me why i am getting Error ORA- 00900 while executing this script with Oracle10G Sql Browserbut not getting error with Oracle9i Sql Browser
    var r1 refcursor;
    var r2 refcursor;
    exec ETKT_CANCEL_TICKET_PCK.GET_DATA(:r1,:r2,'05052007/00000003/0000994','23');

    It would be interesting to know, what Sql Browser is.

  • Creating PL/SQL packages

    Hello,
    The problem I am confronted with is reusing generated models.
    In the process of DataMinig several steps are used: prepare data, Attribute selection (using AI), and building, testing and applying models.
    If PL/SQL packages are used two problems occur:
    First: Long, hand driven process of building:
    Model generation in ODM,
    PL/SQL package building in ODM and Export to SQL file,
    importing package to DB, compiling and running.
    I am sorry, but I don't understand why is it necessary to export PL/SQL packages in a file? As if these products aren't both Oracle products?
    Second: If data (in time) changes and AI selects new attributes, then all next steps fail, since column names, and even some values, are hard coded! Therefore it is necessary to go trough the build and export process all over again. This really hurts.
    Do you have a suggestion how to get around this problem?
    I already considered using a SPSS Clementine, but since it is not an Oracle product I still believe, the original Oracle solution should give me some advantages.
    Oh and another issue.
    I tried using PL/SQL generator (Ver.: 10.1.3.0.17) in JDeveloper (ver.: 10.1.3.0.4), but it gave me an error:
    java.lang.NoClassDefFoundError: oracle/dmt/dm4j/DM4JConnectionManager
         at oracle.dmt.dm4j.extension.CodeGenerator.invoke(Unknown Source)
         at oracle.ide.wizard.WizardManager.invokeWizard(WizardManager.java:310)
         at oracle.ide.wizard.WizardManager$2.run(WizardManager.java:358)
         at oracle.ide.util.IdeUtil.invokeAfterRepaint(IdeUtil.java:1093)
         at oracle.ide.wizard.WizardManager$1.run(WizardManager.java:366)
         at oracle.ide.util.IdeUtil$1$1.run(IdeUtil.java:1073)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Thanks for the reply,
    Igor

    Hi,
    The code generation available in ODMr would allow you to deploy the build, apply or test process as generated code.
    I am not sure what your application goal is, but if you simply want to deploy a model be used in an apply process that is rather straight forward.
    You would build the model using ODMr. Then create an Apply Activity, again using ODMr.
    The Apply Activity can then be used to generate code (pl/sql) using the JDev RTM release (10.1.3.2 or above). We will also have a version that will work with SQLDev shortly.
    The generated code is immediately placed into the db for you.
    If you want to score in a separate db you can either create a db link from that db or move both the model and the apply pl/sql code to the new db (using dba utilities).
    If you want to rebuild a model, where you would add/remove attributes, change transformations etc. then you will have to regenerate the code.
    If you simply want to rebuild the model without changing any transformations and settings you could also deploy the model build generated code.
    As for the JDev failure, we are going to look into that. Have you tried the JDev 10.1.3.3 release available on the Oracle web site?
    Thanks, Mark

  • How to get changes of a custom PL/SQL package updated in ISG?

    Hi All,
    I need some help on how to change a custom PL/SQL package in ISG integration repository:
    I already uploaded my custom PL/SQL package to the integration repositoy some time ago. Now I have made some changes to PL/SQL record/table types defined in the package (added some fields and removed some others). These changed record/table types are used by a procedure I already uploaded to the integration repository. When regenerating the WSDL for my PL/SQL package in integration repository I get an error that the wrapper for respective procedure can't be found. When checking up the SQL types that were automatically generated (by JPublisher) for corresponding PL/SQL types, these generated SQL types are invalid...
    So it seems that in one case JPublisher generated an empty SQL type (with no attributes). In another case JPublisher generated the SQL type with old attribute list, so it didn't adopt the changes of corresponding PL/SQL type in the package...
    Can anybody tell me how to get the changes of a cusotm PL/SQL package updated in ISG? Or is there any possibility to first remove a whole PL/SQL package from the ISG integration repository (and getting rid of all old automatically generated SQL types), so that I can newly upload my PL/SQL package afterwards?
    Thanks
    Konrad
    Edited by: Konrad on 24.10.2011 10:51

    Thanks Daniel, for your reply...
    (-> for info: I'm a colleague of Konrad...)
    Yes, we used a higher version number - and the upload of iLDT file works fine...
    But, the problem occured when generating the WSDL...
    However, I think we have found an approach of how to get the changes of a custom PL/SQL package updated correctly in ISG:
    1. Save a copy of PL/SQL package and then delete it in the database
    2. Regenerate the WSDL for PL/SQL package in ISG (seems that all atutomatically generated JPub wrappers and SQL types are also deleted)
    3. Restart all processes
    4. Create the changed version of PL/SQL package in the database again
    5. upload of iLDT
    6. Regenerate the WSDL for PL/SQL package in ISG
    Best Regards
    Carolin

Maybe you are looking for