UPPER in plsql

The script below asks for a value of UPPER. Why does the dbms not sees that it's a function?
DECLARE
  OldEnvirement VARCHAR(2000);
  NewEnvirement VARCHAR(2000);
   BEGIN
      OldEnvirement = 'Production';
      NewEnvirement = 'Development';
      UPDATE config_item
      SET config_item.system_value = REPLACE(UPPER(config_item.system_value),UPPER(OldEnvirement),NewEnvirement)
      WHERE UPPER(config_item.system_value) LIKE '%' & ,UPPER(OldEnvirement) & '%';
      COMMIT;
   END;
/

DECLARE
Envirement VARCHAR(2000);
NewEnvirement VARCHAR(2000);
BEGIN
OldEnvirement = 'Production';
NewEnvirement = 'Development';
UPDATE config_item
SET config_item.system_value =
REPLACE(UPPER(config_item.system_value),UPPER(OldEnvi
ement),NewEnvirement)
WHERE UPPER(config_item.system_value) LIKE '%'
& ,UPPER(OldEnvirement) & '%';
COMMIT;
END;
/ I expect that you meant to do:
      UPDATE config_item     
      SET config_item.system_value = REPLACE(UPPER(config_item.system_value),UPPER(OldEnvirement),NewEnvirement)
      WHERE UPPER(config_item.system_value) LIKE '%'||UPPER(OldEnvirement)||'%';

Similar Messages

  • Owbsys.wb_rt_api_exec.open fails after upgrade to OWB 11gR2

    The following code is used as a PLSQL wrapper to execute OWB mappings and is based on the good old run_my_own_stuff.sql. We have been mandated to use Tivoli as the corporate scheduler, meaning we do not have Workflow as a solution. We have implemented the audit_execution_id as an input parameter to all the mappings to be able to link the data to the OWBSYS audit tables, as well as return mapping performance and success info to the execution process/session. I have implemented this exact same procedure in 10gR1, 10gR2 and 11gR1 (current dev env) with no problems at all - the code ports easily. However following an upgrade (actually an export/import of the repository from 11gR1 on a 64bit solaris to 11gR2 on Exadata running enterprise linux 5) - actually the test server (I know, I know, I said the same thing!), the code now fails on the wb_rt_api_exec.open line (highlighted).
    CREATE OR REPLACE PROCEDURE bi_ref_data.map (p_map_name IN VARCHAR2)
    -- Procedure to execute ETL mapping package via command line call
    -- Mapping names are held in the BI_REF_DATA.MAP_NAME table
    -- with the mapping type and location data
    AS
    v_repos_owner VARCHAR2 (30) := <repository_owner>;
    v_workspace_owner VARCHAR2 (30) := <workspace_owner>;
    v_workspace_name VARCHAR2 (30) := <workspace_name>;
    v_loc_name VARCHAR2 (30);
    v_map_type VARCHAR2 (30);
    v_map_name VARCHAR2 (30) := UPPER (p_map_name);
    v_retval VARCHAR2 (255);
    v_audit_execution_id NUMBER; -- Audit Execution Id
    v_audit_result NUMBER;
    v_start_time timestamp := LOCALTIMESTAMP;
    v_end_time timestamp;
    v_execution_time NUMBER;
    v_record_rate NUMBER := 0;
    v_records_selected NUMBER;
    v_records_inserted NUMBER;
    v_records_updated NUMBER;
    v_records_deleted NUMBER;
    v_records_merged NUMBER;
    v_errors NUMBER;
    v_failure VARCHAR2 (4000);
    e_no_data_found_in_audit exception;
    v_audit_exec_count NUMBER;
    e_execution_id_error exception;
    BEGIN
    SELECT UPPER (loc_name), UPPER (map_type)
    INTO v_loc_name, v_map_type
    FROM bi_ref_data.owb_map_table
    WHERE UPPER (map_name) = UPPER (v_map_name);
    IF UPPER (v_map_type) = 'PLSQL'
    THEN
    v_map_type := 'PLSQL';
    ELSIF UPPER (v_map_type) = 'SQL_LOADER'
    THEN
    v_map_type := 'SQLLoader';
    ELSIF UPPER (v_map_type) = 'SAP'
    THEN
    v_map_type := 'SAP';
    ELSIF UPPER (v_map_type) = 'DATA_AUDITOR'
    THEN
    v_map_type := 'DataAuditor';
    ELSIF UPPER (v_map_type) = 'PROCESS'
    THEN
    v_map_type := 'ProcessFlow';
    END IF;
    -- Changed code for owb11gr2
    -- owbsys.wb_workspace_management.set_workspace (v_workspace_name, v_workspace_owner);
    owbsys.wb_rt_script_util.set_workspace (v_workspace_owner || '.' || v_workspace_name);
    v_audit_execution_id   := owbsys.wb_rt_api_exec.open (v_map_type, v_map_name, v_loc_name);
    IF v_audit_execution_id IS NULL
    OR v_audit_execution_id = 0
    THEN
    RAISE e_execution_id_error;
    END IF;
    v_retval := v_retval || 'audit_execution_id=' || TO_CHAR (v_audit_execution_id);
    v_audit_result := owbsys.wb_rt_api_exec.execute (v_audit_execution_id);
    IF v_audit_result = owbsys.wb_rt_api_exec.result_success
    THEN
    v_retval := v_retval || ' --> SUCCESS';
    ELSIF v_audit_result = owbsys.wb_rt_api_exec.result_warning
    THEN
    v_retval := v_retval || ' --> WARNING';
    ELSIF v_audit_result = owbsys.wb_rt_api_exec.result_failure
    THEN
    v_retval := v_retval || ' --> FAILURE';
    ELSE
    v_retval := v_retval || ' --> UNKNOWN';
    END IF;
    DBMS_OUTPUT.put_line (v_retval);
    owbsys.wb_rt_api_exec.close (v_audit_execution_id);
    v_end_time := LOCALTIMESTAMP;
    v_execution_time := bi_ref_data.get_seconds_from_interval (v_end_time - v_start_time);
    v_retval := 'Execution time = ' ||
    v_execution_time ||
    ' seconds.';
    DBMS_OUTPUT.put_line (v_retval);
    SELECT COUNT (w.rta_select)
    INTO v_audit_exec_count
    FROM owbsys.owb$wb_rt_audit w
    WHERE w.rte_id = v_audit_execution_id;
    IF v_audit_exec_count = 0
    THEN
    RAISE e_no_data_found_in_audit;
    END IF;
    SELECT w.rta_select,
    w.rta_insert,
    w.rta_update,
    w.rta_delete,
    w.rta_merge,
    rta_errors
    INTO v_records_selected,
    v_records_inserted,
    v_records_updated,
    v_records_deleted,
    v_records_merged,
    v_errors
    FROM owbsys.owb$wb_rt_audit w
    WHERE w.rte_id = v_audit_execution_id;
    v_retval := v_records_selected || ' records selected';
    DBMS_OUTPUT.put_line (v_retval);
    IF v_records_inserted > 0
    THEN
    v_retval := v_records_inserted || ' inserted';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF v_records_updated > 0
    THEN
    v_retval := v_records_updated || ' updated';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF v_records_deleted > 0
    THEN
    v_retval := v_records_deleted || ' deleted';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF v_records_merged > 0
    THEN
    v_retval := v_records_merged || ' merged';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF v_errors > 0
    THEN
    v_retval := v_errors || ' errors';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF v_execution_time > 0
    THEN
    v_record_rate := TRUNC ( (v_records_inserted + v_records_updated + v_records_deleted + v_records_merged) / v_execution_time, 2);
    v_retval := v_record_rate || ' records/sec';
    DBMS_OUTPUT.put_line (v_retval);
    END IF;
    IF (v_audit_result = owbsys.wb_rt_api_exec.result_failure
    OR v_audit_result = owbsys.wb_rt_api_exec.result_warning)
    THEN
    FOR cursor_error
    IN (SELECT DISTINCT aml.plain_text
    FROM owbsys.owb$wb_rt_audit_messages am
    INNER JOIN
    owbsys.owb$wb_rt_audit_message_lines aml
    ON am.audit_message_id = aml.audit_message_id
    WHERE am.audit_execution_id = v_audit_execution_id)
    LOOP
    DBMS_OUTPUT.put_line (cursor_error.plain_text);
    END LOOP;
    END IF;
    -- OWBSYS.wb_rt_api_exec.close (v_audit_execution_id);
    COMMIT;
    EXCEPTION
    WHEN e_execution_id_error
    THEN
    raise_application_error (-20011, 'Invalid execution ID returned from OWB');
    -- RAISE;
    WHEN e_no_data_found_in_audit
    THEN
    raise_application_error (-20010, 'No data found in audit table for execution_id - ' || v_audit_execution_id);
    -- RAISE;
    WHEN NO_DATA_FOUND
    THEN
    raise_application_error (-20001, 'Error in reading data from OWBSYS tables.');
    -- RAISE;
    END;
    Does anyone out there know if there is a difference between 11gR1 and R2 in the way that the wb_rt_api_exec function works?
    Is there a simple way to retrieve the audit_id before executing the mapping, or at a push during the mapping so that we can maintain the link between the session data and the OWBSYS audit data?
    Martin

    Hi David, I have been reading some of your posts and blogs around OWB and I still have not found the answer.
    OK, thereis/was a script that Oracle Support/forums/OTN sent out a while ago called "run_my_iowb_stuff" - I am sure you will be familiar with it. I based the code I uploaded on it and added additional functionality. In essence, I wanted to use the audit_id as an input parameter tot he mapping, so that I can register the audit_id in the management tables, and associate each row of loaded data with a specific mapping_id which would allow a simple link to the owbsys audit tables to complete the audit circle. To that end, I used the owbsys.wb_rt_api_exec.open procedure to register the mapping execution, and then on the execute procedure of the same package, I passed this audit_id in as a custom parameter:
    <<snip>>
    owbsys.wb_workspace_management.set_workspace (v_workspace_name, v_workspace_owner);
    v_audit_execution_id := owbsys.wb_rt_api_exec.open (v_map_type, v_map_name, v_loc_name, 'PLSQL');
    IF v_audit_execution_id IS NULL
    OR v_audit_execution_id = 0
    THEN
    RAISE e_execution_id_error;
    END IF;
    v_retval := v_retval || 'audit_execution_id=' || TO_CHAR (v_audit_execution_id);
    IF v_include_mapping_id > 0 -- if non-zero, submit owb execution id as an input parameter to the map process
    THEN
    owbsys.wb_rt_api_exec.override_input_parameter (
    v_audit_execution_id,
    'p_execution_id',
    TO_CHAR (v_audit_execution_id),
    owbsys.wb_rt_api_exec.parameter_kind_custom
    END IF;
    <<snip>>
    The execution is closed, also by the use of the audit_id ( "owbsys.wb_rt_api_exec.close (v_audit_execution_id)" )
    I can also use the audit_id to inspect the audit tables to retrieve the records processed as well as any associated error messages, and format them for the calling application (owSQL*Plus, which is normally the context of our current use).
    This procedure has been working weel up to now until we moved over to 11gR2 when all of a sudden the audit_id is not returned when executing "v_audit_execution_id := owbsys.wb_rt_api_exec.open (v_map_type, v_map_name, v_loc_name);". Prior to 11gR2 this worked like a charm - now it has crashed to a halt.
    As an interesting twist, I have tried to substitute a sequence number for the audit_id, and then tried to get the audit_id after the mapping completes, so that I can put both the sequence and audit id in a table so it maintains the link. However in attempting to use the owbsys.wb_rt_script_util.run_task procedure which now appears to be the only thing left working, I was astonished to see the following output in sqlplus:
    SQL> exec map1('stg_brand')
    Stage 1: Decoding Parameters
    | location_name=STAGE_MOD
    | task_type=PLSQLMAP
    | task_name=STG_BRAND
    Stage 2: Opening Task
    | l_audit_execution_id=2135
    Stage 3: Overriding Parameters
    Stage 4: Executing Task
    | l_audit_result=1 (SUCCESS)
    Stage 5: Closing Task
    Stage 6: Processing Result
    | exit=1
    --> SUCCESS
    Execution time = .647362 seconds.
    records/sec
    PL/SQL procedure successfully completed.
    SQL>
    This output seems so identical to the "run_my_owb_stuff" that either Oracle support generated their "run_my_owb_stuff" as a lightweight owbsys.wb_rt_script_util.run_task procedure, or Oracle incorporated the "run_my_owb_stuff" script into their owbsys.wb_rt_script_util.run_task procedure! Which way round I cannot say, but it is surely one or the other! To make matters worse, I have raised this with Oracle Support, and they have the temerity to claim that they do not support the "run_my_owb_stuff" script, but think enough of it to incorporate it into their own package in a production release!
    To overcome my problems, in the short term, I need to be able to access the audit_id either during or after the execution of the mapping, so that I can at least associate that with a sequence number I am having to pass in as a parameter to each mapping. In the longer term, i would like a solution to be able to access the audit_id before I execute the mapping, as I could by calling the "owbsys.wb_rt_api_exec.open " procedure. Ideally this would be solved first and I would not need to use a sequence at all.
    Hope this clarifies things a bit.
    Regards
    Martin

  • Oracle type error using cygwin on windows to connect via sqlplus to oracle.

    Hi,
    Found already some information on the internet regarding this topic but wasn't able to solve it so far.
    So all informartion, tips are more then welcome.
    Scripts runs with admin account 'DBA_Services'
    Sqlplus connection sqlplus sys/***@oracle_sid
    Thx already
    OWBrun Script (v2.0)
    Enviroment : GAMMA
    Hostname : pvspdb04
    Database : sgviv5
    Date : 05Nov2010
    Time : 15:58:21
    Schema : dwhins
    RuntimeRep: OWBRUN
    Mapping : INS_DLITE_CTRL_JOB_03
    Location : DNA_STAGING_LOCATION
    Type load : PLSQL
    Custom par: ,
    Identifier: INS_DLITE_CTRL_JOB_03_20101105155820
    Logfile : /ING/DWH/ora_dwh_loader/log/dwhins/owbrun_dwhins_INS_DLITE_CTRL_JOB_03_20101105155820.log
    === Check DB connect ===
    05-NOV-2010 15:58:22
    DB connection test is OK (attemps=1)
    === OWB RUN ===
    SQL*Plus: Release 10.1.0.2.0 - Production on Fri Nov 5 15:58:22 2010
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
    SQL> SQL> SQL> SQL>
    Session altered.
    Elapsed: 00:00:00.00
    SQL>
    Session altered.
    Elapsed: 00:00:00.00
    SQL>
    Session altered.
    Elapsed: 00:00:00.00
    SQL>
    Session altered.
    Elapsed: 00:00:00.00
    SQL> SQL> SQL> SQL> SQL>
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    SQL> ++ Execute owbruntask dwhins.INS_DLITE_CTRL_JOB_03
    SQL>
    Stage 1: Decoding Parameters
    | location_name=DNA_STAGING_LOCATION
    | task_type=PLSQL
    | task_name=INS_DLITE_CTRL_JOB_03
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are correct.
    ORA-06512: at line 267
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning, OLAP and Data Mining options Exitcode = 33 Error : OWBRUN INS_DLITE_CTRL_JOB_03
    Date : 05Nov2010
    Time : 15:58:24

    This are the most important scripts:
    DLITE_Sub1_201.ksh
    #!/bin/ksh
    #set -x
    cp /ING/DWH/ora_dwh_loader/conf/stgins.cfg.sgviv5 /ING/DWH/ora_dwh_loader/conf/stgins.cfg
    export FPATH=/ING/IIB/DNA/Interfaces/Scripts
    export FINPATH=/ING/IIB/DNA/In/
    export FOUTPATH=/ING/IIB/DNA/Out/
    #load script into memory
    autoload DLITE_fct_JS
    #load script into memory
    #autoload DNA_fct_JS_EXEC
    JS_SCRIPT=`basename $0`
    JS_ID=201
    JS_TSK_ID=001;JS_TSK_NAM="FP_START_Remove_Files"
    echo "\nstart subtask '${JS_TSK_NAM}"
    cd /ING/IIB/DNA/Out
    rm -f DLITE_CAPSIL_CODE_*.CSV
    rm -f DLITE_CAPSIL_VAL_*.CSV
    rm -f DLITE_VARIA_CODE_*.CSV
    rm -f DLITE_VARIA_VAL_*.CSV
    echo "\nend subtask '${JS_TSK_NAM}"
    JS_TSK_ID=002;JS_TSK_NAM="F_DLITE_01_CODE_DESC"
    cd /ING/IIB/DNA/Interfaces/Scripts
    echo "\nstart subtask '${JS_TSK_NAM}"
    ksh DLITE_owbrun.ksh -s dwhins -t PROCESS -m F_DLITE_01_CODE_DESC -l LOC_DNA_FLOW_STORE -c ","
    JS_TSK_STA=$?
    echo "\nverifying correct execution of subtask '${JS_TSK_NAM}"
    if [ ${JS_TSK_STA} -ne 0 ] ; then
    ksh DLITE_owbrun.ksh -s dwhins -t PLSQL -m INS_DLITE_CTRL_JOB_03 -l DNA_STAGING_LOCATION -c ","
    exit 1
    fi
    echo "\nend subtask '${JS_TSK_NAM}"
    JS_TSK_ID=002;JS_TSK_NAM="Check header/footer of files"
    echo "\nstart subtask '${JS_TSK_NAM}"
    ksh DLITE_CheckHeaderFooter.ksh
    JS_TSK_STA=$?
    if [ ${JS_TSK_STA} -ne 0 ] ; then
    exit 1
    fi
    echo "\nend subtask '${JS_TSK_NAM}"
    DLITE_owbrun.ksh
    . /ING/IIB/DNA/Interfaces/Scripts/DLITE_ods_set_env.ksh
    fout_melding()
         echo "Error : ${1}" | tee -a ${LOGFILE}
         echo " Date     :     $(date +%d%b%Y)" >> ${LOGFILE}
         echo " Time     :     $(date +%H:%M:%S)" >> ${LOGFILE}
    if [ -s ${LOGFILE:=/tmp/foutmelding} ]
    then
    cat ${LOGFILE} | mailx -s "'hostname':${ORACLE_SID};'Enviroment' :${APPL_ENV} : Error OWB run ${SCHEMA} : ${MAPPING}" "${dstG_OWB_errors[*]} ${dstA_OWB_errors[*]}"
    else
    echo "Error : ${1}" | mailx -s "'hostname':${ORACLE_SID};'Enviroment' :${APPL_ENV} : Error OWB run ${SCHEMA} : ${MAPPING}" "${dstG_OWB_errors[*]} ${dstA_OWB_errors[*]}"
    fi
    rm -f ${STATSFILE}
    waarschuwing()
         echo "Warning : ${1}" | tee -a ${LOGFILE}
         echo " Date     :     $(date +%d%b%Y)" >> ${LOGFILE}
         echo " Time     :     $(date +%H:%M:%S)" >> ${LOGFILE}
    if [ -s ${LOGFILE:=/tmp1/foutmelding} ]
    then
    echo ${1} | mailx -s "'hostname':${ORACLE_SID};'Enviroment' :${APPL_ENV} : Warning OWB run ${SCHEMA} : ${TABLENAME}" "${dstG_OWB_errors[*]} ${dstA_OWB_errors[*]}"
    else
    echo "Warning : ${1}" | mailx -s "'hostname':${ORACLE_SID};'Enviroment' :${APPL_ENV} : Warning OWB run ${SCHEMA} : ${TABLENAME}" "${dstG_OWB_errors[*]} ${dstA_OWB_errors[*]}"
    fi
    USAGE="Usage : owbrun.ksh -s target_schema -t type -m mapping -l location -c custom_param -p system_param [-i ident]"
    umask 022
    ORVERSION=2.0
    set -- `getopt s:t:m:c:p:i:l: $*`
    if [ $? -ne 0 ]
    then
         echo ${USAGE}
         exit 2
    fi
    while [ $# -gt 0 ]
    do
    case ${1} in
         -s)
              SCHEMA=${2}
              shift 2
         -t)
              LOADTYPE=${2}
              shift 2
         -l)
              LOCATION=${2}
              shift 2
         -m)
              MAPPING=${2}
              shift 2
         -i)
              IDENT=${2}
              shift 2
         -c)
              CUSTPARAM=${2}
              shift 2
              shift
              break
    esac
    done
    export LISTFILENAMES=${*}
    if [ "${SCHEMA}" = "" ]
    then
         fout_melding "Target Schema is mandatory"
         echo ${USAGE}
         exit 1
    fi
    if [ "${MAPPING}" = "" ]
    then
         echo "Error : Mapping is mandatory"
         echo ${USAGE}
         exit 1
    fi
    if [ "${LOCATION}" = "" ]
    then
         echo "Error : Location is mandatory"
         echo ${USAGE}
         exit 1
    fi
    MAPPING=$(echo ${MAPPING} | tr [:lower:] [:upper:])
    if [ "${LOADTYPE}" = "" ]
    then
         echo "Error : Type (PLSQL/SQLLDR/PROCESS) is mandatory"
         echo ${USAGE}
         exit 1
    fi
    LOADTYPE=$(echo ${LOADTYPE} | tr [:lower:] [:upper:])
    if [ "${LOADTYPE}" != "PLSQL" -a "${LOADTYPE}" != "SQLLDR" -a "${LOADTYPE}" != "PROCESS" ]
    then
         echo "Error : Illegal type ${LOADTYPE}"
         echo ${USAGE}
         exit 1
    fi
    export SCHEMA=$(echo ${SCHEMA} | tr [:upper:] [:lower:])
    export UPSCHEMA=$(echo ${SCHEMA} | tr [:lower:] [:upper:])
    # Call the Configuration script
    . /ING/DWH/ora_dwh_loader/bin/config.ksh -s ${SCHEMA}
    exitcode=$?
    if [ $exitcode -ne 0 ]
    then
         echo "Error : during config.ksh"
         exit ${exitcode}
    fi
    if [ "${IDENT}" = "" ]
    then
         IDENT=${MAPPING}_$(date +%Y%m%d%H%M%S)
         CUSTPARAM=$(echo ${CUSTPARAM} | awk -f ${BASEPATH}/bin/owbrun.awk "datum=$(date +%Y%m%d%H%M%S)")
    fi
    if [ "${RUNREP}" = "" ]
    then
         fout_melding "Runtime Repository is mandatory (see ${SCHEMA}.cfg)"
         echo ${USAGE}
         exit 1
    fi
    export BPIDFILE=${TMPDRIVE}/owbrun_${SCHEMA}_${IDENT}_$$.pidlist
    export LOGFILE=${LOGDRIVE}/owbrun_${SCHEMA}_${IDENT}.log
    export STATSFILE=${LOGDRIVE}/owbrun_${SCHEMA}_${IDENT}.stats
    echo "OWBrun Script (v${ORVERSION})" > ${LOGFILE}
    echo "Enviroment : ${APPL_ENV}" >> ${LOGFILE}
    echo "Hostname : $(hostname)" >> ${LOGFILE}
    echo "Database : ${ORACLE_SID}" >> ${LOGFILE}
    echo "Date     :     $(date +%d%b%Y)" >> ${LOGFILE}
    echo "Time     :     $(date +%H:%M:%S)" >> ${LOGFILE}
    echo "Schema     : ${SCHEMA}" >> ${LOGFILE}
    echo "RuntimeRep: ${RUNREP}" >> ${LOGFILE}
    echo "Mapping : ${MAPPING}" >> ${LOGFILE}
    echo "Location : ${LOCATION}" >> ${LOGFILE}
    echo "Type load : ${LOADTYPE}" >> ${LOGFILE}
    echo "Custom par: ${CUSTPARAM}" >> ${LOGFILE}
    echo "Identifier: ${IDENT}" >> ${LOGFILE}
    echo "Logfile     :     ${LOGFILE}" >> ${LOGFILE}
    echo " " >> ${LOGFILE}
    echo "Hostname : $(hostname)" > ${STATSFILE}
    echo "Database : ${ORACLE_SID}" >> ${STATSFILE}
    echo "Schema     : ${SCHEMA}" >> ${STATSFILE}
    echo "Mapping : ${TABLENAME}" >> ${STATSFILE}
    echo "Period : P${PERIOD}" >> ${STATSFILE}
    echo "Type load : ${LOADTYP}" >> ${STATSFILE}
    echo "Identifier: ${IDENT}" >> ${STATSFILE}
    echo "Start     : $(date +%d%m%Y%H%M%S)" >> ${STATSFILE}
    echo "=== Check DB connect ===" >> ${LOGFILE}
    ${BASEPATH}/bin/chk_db_connect.ksh >> ${LOGFILE}
    exitcode=${?}
    if [ $exitcode -ne 0 ]
    then
         fout_melding "Could NOT connect to database ${ORACLE_SID}"
         exit ${exitcode}
    fi
    echo "=== OWB RUN ===" >> ${LOGFILE}
    sqlplus 'system/*****' <<-EOF >> ${LOGFILE}
    set timing on
    set serveroutput on
    alter session set sort_area_size=2621440;
    alter session set hash_area_size=2621440;
    alter session set skip_unusable_indexes=true;
    alter session enable resumable timeout ${ResumableTimeout} name 'OwbRunTask ${UPSCHEMA}.${MAPPING}';
    set pages 0
    set timing on
    set serveroutput on
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    exec dbms_application_info.set_module('OWBRUNTASK','${UPSCHEMA}.${MAPPING}');
    Prompt ++ Execute owbruntask ${SCHEMA}.${MAPPING}
    declare
    p_repos_owner varchar2(100):= '${RUNREP}';
    p_location_name varchar2(100):='${LOCATION}';
    p_task_type varchar2(100) :='${LOADTYPE}';
    p_task_name varchar2(100) default '${MAPPING}';
    p_system_params varchar2(100) default '","';
    p_custom_params varchar2(200) default '${CUSTPARAM}"';
    p_oem_friendly number default 0;
    l_oem_style boolean := case (p_oem_friendly)
    when 0 then false
    else true
    end ;
    l_audit_execution_id number; -- Audit Execution Id
    l_audit_result number := ${RUNREP}.wb_rt_api_exec.RESULT_FAILURE; -- Result Code
    l_audit_result_disp varchar2(64) := 'FAILURE'; -- Result Display Code
    l_task_type_name varchar2(64); -- Task Type Name
    l_task_type varchar2(64); -- Task Type
    l_task_name varchar2(64); -- Task Name
    l_location_name varchar2(64); -- Location Name
    l_return number ;
    fout exception;
    opgepast exception;
    p_parameters varchar2(4000);
    p_parameter_kind number;
    l_anchor_offset number := 1;
    l_start_offset number := 1;
    l_equals_offset number;
    l_comma_offset number;
    l_value_offset number;
    l_esc_offset number;
    l_esc_count number;
    l_esc_char varchar2(4);
    l_parameter_name varchar2(4000);
    l_parameter_value varchar2(4000);
    begin
    p_custom_params:=replace(p_custom_params,'~',' ');
    execute immediate ('alter session set current_schema = ' || p_repos_owner) ;
    -- Initialize Return Code
    l_return := ${RUNREP}.wb_rt_api_exec.RESULT_FAILURE;
    -- Import Parameters
    dbms_output.put_line('Stage 1: Decoding Parameters');
    l_task_type_name := p_task_type ;
    if UPPER(l_task_type_name) = 'PLSQL'
    then
    l_task_type := 'PLSQL';
    elsif UPPER(l_task_type_name) = 'SQL_LOADER'
    then
    l_task_type := 'SQLLoader';
    elsif UPPER(l_task_type_name) = 'PROCESS'
    then
    l_task_type := 'ProcessFlow';
    else
    l_task_type := l_task_type_name;
    end if;
    l_task_name := p_task_name ;
    l_location_name := p_location_name ;
    dbms_output.put_line('| location_name=' || l_location_name);
    dbms_output.put_line('| task_type=' || l_task_type);
    dbms_output.put_line('| task_name=' || l_task_name);
    -- Decode Parameters
    begin
    -- Prepare Execution
    dbms_output.put_line('Stage 2: Opening Task');
    l_audit_execution_id := ${RUNREP}.wb_rt_api_exec.open(l_task_type, l_task_name, l_location_name);
    dbms_output.put_line('| l_audit_execution_id=' || to_char(l_audit_execution_id));
    commit;
    -- Override Parameters
    p_parameters:=p_system_params;
    p_parameter_kind :=${RUNREP}.wb_rt_api_exec.PARAMETER_KIND_SYSTEM;
    l_anchor_offset:= 1;
    l_start_offset:= 1;
    l_equals_offset:=0;
    l_comma_offset:=0;
    l_value_offset:=0;
    l_esc_offset:=0;
    l_esc_count:=0;
    l_esc_char:=null;
    l_parameter_name:=null;
    l_parameter_value:=null;
    begin
    loop
    l_equals_offset := INSTR(p_parameters, '=', l_start_offset);
    exit when l_equals_offset = 0;
    l_start_offset := l_equals_offset + 1;
    loop
    l_comma_offset := INSTR(p_parameters, ',', l_start_offset);
    if l_comma_offset = 0
    then
    l_comma_offset := length(p_parameters) + 1;
    exit;
    else
    l_esc_count := 0;
    l_esc_offset := l_comma_offset - 1;
    loop
    l_esc_char := SUBSTR(p_parameters, l_esc_offset, 1);
    exit when l_esc_char != '\';
    l_esc_count := l_esc_count + 1;
    l_esc_offset := l_esc_offset - 1;
    end loop;
    if MOD(l_esc_count, 2) != 0
    then
    l_start_offset := l_comma_offset + 1;
    else
    exit;
    end if;
    end if;
    end loop;
    l_parameter_name := LTRIM(RTRIM(SUBSTR(p_parameters, l_anchor_offset, l_equals_offset - l_anchor_offset)));
    l_parameter_value := SUBSTR(p_parameters, l_equals_offset + 1, l_comma_offset - (l_equals_offset + 1));
    -- Override Input Parameter
    ${RUNREP}.wb_rt_api_exec.override_input_parameter(l_audit_execution_id,l_parameter_name,l_parameter_value,p_parameter_kind);
    exit when l_comma_offset >= length(p_parameters)-1;
    l_start_offset := l_comma_offset + 1;
    l_anchor_offset := l_start_offset;
    end loop;
    end;
    p_parameters:=p_custom_params;
    p_parameter_kind :=${RUNREP}.wb_rt_api_exec.PARAMETER_KIND_CUSTOM;
    l_anchor_offset:= 1;
    l_start_offset:= 1;
    l_equals_offset:=0;
    l_comma_offset:=0;
    l_value_offset:=0;
    l_esc_offset:=0;
    l_esc_count:=0;
    l_esc_char:=null;
    l_parameter_name:=null;
    l_parameter_value:=null;
    begin
    loop
    l_equals_offset := INSTR(p_parameters, '=', l_start_offset);
    exit when l_equals_offset = 0;
    l_start_offset := l_equals_offset + 1;
    loop
    l_comma_offset := INSTR(p_parameters, ',', l_start_offset);
    if l_comma_offset = 0
    then
    l_comma_offset := length(p_parameters) + 1;
    exit;
    else
    l_esc_count := 0;
    l_esc_offset := l_comma_offset - 1;
    loop
    l_esc_char := SUBSTR(p_parameters, l_esc_offset, 1);
    exit when l_esc_char != '\';
    l_esc_count := l_esc_count + 1;
    l_esc_offset := l_esc_offset - 1;
    end loop;
    if MOD(l_esc_count, 2) != 0
    then
    l_start_offset := l_comma_offset + 1;
    else
    exit;
    end if;
    end if;
    end loop;
    l_parameter_name := LTRIM(RTRIM(SUBSTR(p_parameters, l_anchor_offset, l_equals_offset - l_anchor_offset)));
    l_parameter_value := SUBSTR(p_parameters, l_equals_offset + 1, l_comma_offset - (l_equals_offset + 1));
    -- Override Input Parameter
    ${RUNREP}.wb_rt_api_exec.override_input_parameter(l_audit_execution_id,l_parameter_name,l_parameter_value,p_parameter_kind);
    exit when l_comma_offset >= length(p_parameters)-1;
    l_start_offset := l_comma_offset + 1;
    l_anchor_offset := l_start_offset;
    end loop;
    end;
    -- Execute
    dbms_output.put_line('Stage 4: Executing Task');
    l_audit_result := ${RUNREP}.wb_rt_api_exec.execute(l_audit_execution_id);
    if l_audit_result = ${RUNREP}.wb_rt_api_exec.RESULT_SUCCESS
    then
    l_audit_result_disp := 'SUCCESS';
    elsif l_audit_result = ${RUNREP}.wb_rt_api_exec.RESULT_WARNING
    then
    l_audit_result_disp := 'WARNING';
    elsif l_audit_result = ${RUNREP}.wb_rt_api_exec.RESULT_FAILURE
    then
    l_audit_result_disp := 'FAILURE';
    else
    l_audit_result_disp := 'UNKNOWN';
    end if;
    dbms_output.put_line('| l_audit_result=' || to_char(l_audit_result) || ' (' || l_audit_result_disp || ')');
    -- Finish Execution
    dbms_output.put_line('Stage 5: Closing Task');
    ${RUNREP}.wb_rt_api_exec.close(l_audit_execution_id);
    commit;
    dbms_output.put_line('Stage 6: Processing Result');
    if l_oem_style
    then
    if l_audit_result = ${RUNREP}.wb_rt_api_exec.RESULT_SUCCESS
    then
    l_return := 0;
    elsif l_audit_result = ${RUNREP}.wb_rt_api_exec.RESULT_WARNING
    then
    l_return := 0;
    else
    l_return := l_audit_result;
    end if;
    else
    l_return := l_audit_result;
    end if;
    dbms_output.put_line('| exit=' || to_char(l_return));
    if (l_return = 3) then
    raise fout;
    elsif (l_return = 2 ) then
    raise opgepast;
    end if;
    exception
    when fout then
    raise_application_error(-20002, 'Error during executing task');
    when opgepast then
    raise_application_error(-20003, 'Warning during executing task');
    when no_data_found
    then
    raise_application_error(-20001, 'Task not found - Please check the Task Type, Name and Location are correct.');
    end;
    dbms_output.put_line('| exit=' || to_char(l_return));
    end ;
    EOF
    exitcode=${?}
    if [ ${exitcode} -ne 0 ]
    then
         echo "Exitcode = ${exitcode}" >> ${LOGFILE}     
         fout_melding "OWBRUN ${MAPPING} "
         exit ${exitcode}
    else
         echo "OWBRUN succesfull" >> ${LOGFILE}
    fi
    echo "---------------------------------------------------------------------" >> ${LOGFILE}
    echo "Date     :     $(date +%d%b%Y)" >> ${LOGFILE}
    echo "Time     :     $(date +%H:%M:%S)" >> ${LOGFILE}
    echo "Terminated succesfull" >> ${LOGFILE}
    echo "---------------------------------------------------------------------" >> ${LOGFILE}
    echo "Stop     : $(date +%d%m%Y%H%M%S)" >> ${STATSFILE}
    times >> ${STATSFILE}
    #echo "Loader Statistics" >> ${LOGFILE}
    #awk -f ${BASEPATH}/bin/loadstat.awk ${STATSFILE} >> ${LOGFILE}
    #${BASEPATH}/bin/loadstat.ksh -s ${SCHEMA} -f ${STATSFILE}
    exit 0

  • Oem_exec_template.sql

    I am planning to schedule mappings using OEM and referred this:
    http://www.oracle.com/technology/products/warehouse/htdocs/oem_scheduling_viewlet_swf.html
    But I cannot find oem_exec_template.sql script in the mentioned directory.....I am using OWB 11g

    or here is the script:
    rem SYNOPSYS
    rem
    rem @oem_exec_template.sql rt_owner location_name {PLSQL | SQL_LOADER | PROCESS} task_name system_params custom_params
    rem
    rem NAME
    rem
    rem oem_exec_template.sql - OEM Execution Template
    rem
    rem USAGE
    rem
    rem rt_owner := e.g. MY_RUNTIME - Name of the Runtime Repository Owner
    rem
    rem location_name :- e.g. MY_WAREHOUSE - Physical Name of the Location to which this task was deployed
    rem (i.e. a DB Location or a Process Location or the Platform Schema)
    rem Note: Always use "PlaformSchema" for SQL_LOADER types.
    rem
    rem task_type :- PLSQL - OWB PL/SQL Mapping
    rem | SQL_LOADER - OWB SQL*Loader Mapping
    rem | PROCESS - OWB ProcessFlow
    rem
    rem task_name :- e.g. MY_MAPPING - Physical Name of the Deployed Object
    rem
    rem custom_params :- { , | (name = value [, name = value]...)}
    rem e.g. ","
    rem or MY_PARAM=1,YOUR_PARAM=true
    rem
    rem system_params :- { , | (name = value [, name = value]...)}
    rem e.g. ","
    rem or MY_PARAM=1,YOUR_PARAM=true
    rem
    rem RETURNS
    rem
    rem 0 if task reports SUCCESS or WARNING, otherwise >0
    rem
    rem
    rem DESCRIPTION
    rem
    rem This SQL*Plus script can be pasted into a user-defined OEM SQL*Plus Job. This job
    rem can be then used with OEM's 'Create Like' functionality to either create new
    rem parameterized jobs or to submit new jobs for immediate execution.
    rem
    rem This script is design to be run from a Runtime User, not the Runtime Repository Owner.
    rem The Runtime Repository Owner is nominated to the parameters.
    rem
    rem In its unchanged form the script takes the three keys required to identify
    rem the executable task.
    rem
    rem The task is executed with the default parameters configured prior to deployment.
    rem
    rem The custom_params and system_params values override the default input parameters
    rem of the task.
    rem
    rem Note: The comma character can be escaped using the backslash character; likewise the backslash
    rem character can be escaped by itself.
    rem
    rem A list of the valid System Parameters for each task type can be obtained from the OWB
    rem documentation, but generally the deployed defaults are sufficient. The Custom Parameters
    rem are defined on the object in the OWB Designer.
    rem
    rem EXAMPLE
    rem
    rem @oem_exec_template.sql MY_RUNTIME MY_WAREHOUSE PLSQL MY_MAPPING "," ","
    rem @oem_exec_template.sql MY_RUNTIME PlatformSchema SQL_LOADER MY_LOAD "," ","
    rem @oem_exec_template.sql MY_RUNTIME MY_WORKFLOW PROCESS MY_PROCESS "," ","
    rem
    rem Note: @oem_exec_template.sql must not included in the OEM parameter field as is added
    rem automatically by OEM.
    define OEM_FRIENDLY=true
    set serveroutput on
    set verify off
    whenever sqlerror exit failure;
    define REPOS_OWNER=&1
    define LOCATION_NAME=&2
    define TASK_TYPE=&3
    define TASK_NAME=&4
    define SYSTEM_PARAMS=&5
    define CUSTOM_PARAMS=&6
    alter session set current_schema = &REPOS_OWNER;
    set role wb_r_&REPOS_OWNER, wb_u_&REPOS_OWNER;
    variable exec_return_code number;
    declare
    l_oem_style boolean := &OEM_FRIENDLY;
    l_audit_execution_id number; -- Audit Execution Id
    l_audit_result number := wb_rt_api_exec.RESULT_FAILURE; -- Result Code
    l_audit_result_disp varchar2(64) := 'FAILURE'; -- Result Display Code
    l_task_type_name varchar2(64); -- Task Type Name
    l_task_type varchar2(64); -- Task Type
    l_task_name varchar2(64); -- Task Name
    l_location_name varchar2(64); -- Location Name
    procedure override_input_parameter
    p_audit_execution_id in number,
    p_parameter_name in varchar2,
    p_value in varchar2,
    p_parameter_kind in number
    is
    l_parameter_kind varchar2(64);
    begin
    if p_parameter_kind = wb_rt_api_exec.PARAMETER_KIND_SYSTEM
    then
    l_parameter_kind := 'SYSTEM';
    else
    l_parameter_kind := 'CUSTOM';
    end if;
    dbms_output.put_line('| ' || p_parameter_name || '%' || l_parameter_kind || '=' || '''' || p_value || '''');
    wb_rt_api_exec.override_input_parameter
    p_audit_execution_id,
    p_parameter_name,
    p_value,
    p_parameter_kind
    end;
    procedure override_input_parameters
    p_audit_execution_id in number,
    p_parameters varchar2,
    p_parameter_kind in number
    is
    l_anchor_offset number := 1;
    l_start_offset number := 1;
    l_equals_offset number;
    l_comma_offset number;
    l_value_offset number;
    l_esc_offset number;
    l_esc_count number;
    l_esc_char varchar2(4);
    l_parameter_name varchar2(4000);
    l_parameter_value varchar2(4000);
    function strip_escape
    p_escapedString varchar2
    return varchar2
    is
    l_strippedString varchar2(4000);
    l_a_char varchar2(4);
    l_b_char varchar2(4);
    l_strip_offset number := 1;
    begin
    loop
    exit when p_escapedString is null or l_strip_offset > length(p_escapedString);
    l_a_char := SUBSTR(p_escapedString, l_strip_offset, 1);
    if l_strip_offset = length(p_escapedString)
    then
    l_strippedString := l_strippedString || l_a_char;
    exit;
    else
    if l_a_char = '\'
    then
    l_b_char := SUBSTR(p_escapedString, l_strip_offset + 1, 1);
    if l_b_char = '\' or l_b_char = ','
    then
    l_strippedString := l_strippedString || l_b_char;
    l_strip_offset := l_strip_offset + 1;
    end if;
    else
    l_strippedString := l_strippedString || l_a_char;
    end if;
    end if;
    l_strip_offset := l_strip_offset + 1;
    end loop;
    return l_strippedString;
    end;
    begin
    loop
    l_equals_offset := INSTR(p_parameters, '=', l_start_offset);
    exit when l_equals_offset = 0;
    l_start_offset := l_equals_offset + 1;
    loop
    l_comma_offset := INSTR(p_parameters, ',', l_start_offset);
    if l_comma_offset = 0
    then
    l_comma_offset := length(p_parameters) + 1;
    exit;
    else
    l_esc_count := 0;
    l_esc_offset := l_comma_offset - 1;
    loop
    l_esc_char := SUBSTR(p_parameters, l_esc_offset, 1);
    exit when l_esc_char != '\';
    l_esc_count := l_esc_count + 1;
    l_esc_offset := l_esc_offset - 1;
    end loop;
    if MOD(l_esc_count, 2) != 0
    then
    l_start_offset := l_comma_offset + 1;
    else
    exit;
    end if;
    end if;
    end loop;
    l_parameter_name := LTRIM(RTRIM(SUBSTR(p_parameters, l_anchor_offset, l_equals_offset - l_anchor_offset)));
    l_parameter_value := strip_escape(SUBSTR(p_parameters, l_equals_offset + 1, l_comma_offset - (l_equals_offset + 1)));
    -- Override Input Parameter
    override_input_parameter(p_audit_execution_id, l_parameter_name, l_parameter_value, p_parameter_kind);
    exit when l_comma_offset >= length(p_parameters)-1;
    l_start_offset := l_comma_offset + 1;
    l_anchor_offset := l_start_offset;
    end loop;
    end;
    procedure override_custom_input_params
    p_audit_execution_id in number,
    p_parameters varchar2
    is
    l_parameter_kind number := wb_rt_api_exec.PARAMETER_KIND_CUSTOM;
    begin
    override_input_parameters(p_audit_execution_id, p_parameters, l_parameter_kind);
    null;
    end;
    procedure override_system_input_params
    p_audit_execution_id in number,
    p_parameters varchar2
    is
    l_parameter_kind number := wb_rt_api_exec.PARAMETER_KIND_SYSTEM;
    begin
    override_input_parameters(p_audit_execution_id, p_parameters, l_parameter_kind);
    null;
    end;
    begin
    -- Initialize Return Code
    :exec_return_code := wb_rt_api_exec.RESULT_FAILURE;
    -- Import Parameters
    dbms_output.put_line('Stage 1: Decoding Parameters');
    l_task_type_name := '&TASK_TYPE';
    if UPPER(l_task_type_name) = 'PLSQL'
    then
    l_task_type := 'PLSQL';
    elsif UPPER(l_task_type_name) = 'SQL_LOADER'
    then
    l_task_type := 'SQLLoader';
    elsif UPPER(l_task_type_name) = 'PROCESS'
    then
    l_task_type := 'ProcessFlow';
    else
    l_task_type := l_task_type_name;
    end if;
    l_task_name := '&TASK_NAME';
    l_location_name := '&LOCATION_NAME';
    dbms_output.put_line('| location_name=' || l_location_name);
    dbms_output.put_line('| task_type=' || l_task_type);
    dbms_output.put_line('| task_name=' || l_task_name);
    -- Decode Parameters
    begin
    -- Prepare Execution
    dbms_output.put_line('Stage 2: Opening Task');
    l_audit_execution_id := wb_rt_api_exec.open(l_task_type, l_task_name, l_location_name);
    dbms_output.put_line('| l_audit_execution_id=' || to_char(l_audit_execution_id));
    commit;
    -- Override Parameters
    dbms_output.put_line('Stage 3: Overriding Parameters');
    override_system_input_params(l_audit_execution_id, '&SYSTEM_PARAMS');
    override_custom_input_params(l_audit_execution_id, '&CUSTOM_PARAMS');
    -- Execute
    dbms_output.put_line('Stage 4: Executing Task');
    l_audit_result := wb_rt_api_exec.execute(l_audit_execution_id);
    if l_audit_result = wb_rt_api_exec.RESULT_SUCCESS
    then
    l_audit_result_disp := 'SUCCESS';
    elsif l_audit_result = wb_rt_api_exec.RESULT_WARNING
    then
    l_audit_result_disp := 'WARNING';
    elsif l_audit_result = wb_rt_api_exec.RESULT_FAILURE
    then
    l_audit_result_disp := 'FAILURE';
    else
    l_audit_result_disp := 'UNKNOWN';
    end if;
    dbms_output.put_line('| l_audit_result=' || to_char(l_audit_result) || ' (' || l_audit_result_disp || ')');
    -- Finish Execution
    dbms_output.put_line('Stage 5: Closing Task');
    wb_rt_api_exec.close(l_audit_execution_id);
    commit;
    dbms_output.put_line('Stage 6: Processing Result');
    if l_oem_style
    then
    if l_audit_result = wb_rt_api_exec.RESULT_SUCCESS
    then
    :exec_return_code := 0;
    elsif l_audit_result = wb_rt_api_exec.RESULT_WARNING
    then
    :exec_return_code := 0;
    else
    :exec_return_code := l_audit_result;
    end if;
    else
    :exec_return_code := l_audit_result;
    end if;
    dbms_output.put_line('| exit=' || to_char(:exec_return_code));
    exception
    when no_data_found
    then
    raise_application_error(-20001, 'Task not found - Please check the Task Type, Name and Location are correct.');
    end;
    end;
    exit :exec_return_code;
    ;

  • DB upgrade from 9.2.0.4 to 9.2.0.6 or upper with apps. 11.5.9

    Hi friends,
    I want to upgrade my db 9.2.0.4 to 9.2.0.6 or upper version and my db is used by Oracle EBS 11.5.9.
    I've never patched an oracle db on solaris and my system is solaris sparc.
    i dont know hot patch.
    Is there any document that tells step by step with all commands about applying db patches.
    Thanks

    Everything you need is in Section 2 of the 11i 9.2.0 Interoperability Doc:
    Oracle Applications Release 11i with Oracle9i Release 2 (9.2.0)
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=216550.1
    You should upgrade directly to 9.2.0.8 rather than use the older 9.2.0.6 as you will just hit other database bugs that other people already got fixed and rolled into 9.2.0.8. Alternatively, consider upgrading to 10.1.0.5 or 10.2.0.3.
    You cannot apply a database patch hot (especially dot release upgrades) as all oracle processes used by that Oracle Home (your 11i instance) need to be down while the software is upgraded and relinked.

  • Error in PLSQL Procedure...

    Hi Guys,
    I have the following functions inside a package...
    I was trying to create directories dynamically in the runtime in side a plsql...
    FUNCTION Get_Site_Dir_Name (
       site_     IN VARCHAR2,
       dir_type_ IN VARCHAR2 ) RETURN VARCHAR2
    IS
    BEGIN
       RETURN (REPLACE(site_, ' ', NULL) || UPPER(dir_type_));
    END Get_Site_Dir_Name;
    PROCEDURE Set_Dir_Path (
       dir_path_ IN VARCHAR2,
       site_ IN VARCHAR2,
       dir_type_ IN VARCHAR2 )
    IS
    BEGIN
       CREATE OR REPLACE DIRECTORY Get_Site_Dir_Name(site_, dir_type_) AS dir_path_;
    END Set_Dir_Path;But this gives me an error when deploying...
    Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY SITE_API:
    LINE/COL ERROR
    1354/4 PLS-00103: Encountered the symbol "CREATE" when expecting one of
    the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    Can some one help me with this?
    Many Thanks....

    dir_name_ := 'TESTDIR';
    stmt_ := 'EXECUTE IMMEDIATE CREATE OR REPLACE DIRECTORY :dir_name AS :dir_path;';
    EXECUTE IMMEDIATE stmt_
    USING IN dir_name_,
    IN dir_path_;Remove ;
    stmt_ := CREATE OR REPLACE DIRECTORY :dir_name AS :dir_path';or
    SQL> Declare
      2  dir_name varchar2(20) := 'TESTDIR';
      3  dir_path varchar2(20) := 'C:\';
      4  stmt varchar2(100);
      5  Begin
      6  EXECUTE IMMEDIATE 'CREATE DIRECTORY '||dir_name||' AS '''||dir_path||'''';
      7  Dbms_output.put_line('Directory is created');
      8  end;
      9  /
    Directory is created
    PL/SQL procedure successfully completed.Twinkle
    Edited by: Twinkle on Nov 18, 2009 4:39 PM

  • How to process next record in oracle PLSQL

    Hi,
    I am processing below record set with the help of BULK COLLECT in Oracle PLSQL Procedure. While processing I am checking model is one that need not be substituted. If it is 'NA' or 'N/A', I need process next record (marked as bold in code snipet)
    Please guide me how to do it ?
    TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE INDEX BY BINARY_INTEGER;
    L_money t_get_money ;
    L_subst_model VARCHAR2(40);
    L_Notify_Manager     VARCHAR2(1);
    L_grade          VARCHAR2(20);
    L_Error_Message     VARCHAR2(1);
    BEGIN
    OPEN c_get_money ;
    FETCH c_get_money BULK COLLECT INTO L_money ;
    CLOSE c_get_money;
    FOR I IN 1..L_money.count LOOP
    -- check if the model is one that need not be substituted
    IF (upper(L_money(i). subst_model) in ('N/A', 'NA')
    THEN
    L_NOTIFY_MANAGER(I) := 'Y';
    L_GRADE(I) := 'ERROR';
    L_error_message(i) := 'substitute Model is not N/A or NA' ;
    -------Here I want to process NEXT RECORD--------
    END IF ;
    END;

    One of the solution for below version of 11g...
    DECLARE
         TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE
                                       INDEX BY BINARY_INTEGER;
         L_money              t_get_money;
         L_subst_model        VARCHAR2 (40);
         L_Notify_Manager   VARCHAR2 (1);
         L_grade              VARCHAR2 (20);
         L_Error_Message    VARCHAR2 (1);
    BEGIN
         OPEN c_get_money;
         FETCH c_get_money
         BULK COLLECT INTO L_money;
         CLOSE c_get_money;
         FOR I IN 1 .. L_money.COUNT LOOP
              IF UPPER (L_money (i).subst_model) IN ('N/A', 'NA') THEN
                   GOTO Nextrecord;
              END IF;
              L_NOTIFY_MANAGER (I)   := 'Y';
              L_GRADE (I)              := 'ERROR';
              L_error_message (i)    := 'substitute Model is not N/A or NA';
            <<Nextrecord>>
              NULL;
         END LOOP;
    END;One of the solution for 11gR1 and above...
    DECLARE
         TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE
                                       INDEX BY BINARY_INTEGER;
         L_money              t_get_money;
         L_subst_model        VARCHAR2 (40);
         L_Notify_Manager   VARCHAR2 (1);
         L_grade              VARCHAR2 (20);
         L_Error_Message    VARCHAR2 (1);
    BEGIN
         OPEN c_get_money;
         FETCH c_get_money
         BULK COLLECT INTO L_money;
         CLOSE c_get_money;
         FOR I IN 1 .. L_money.COUNT LOOP
              IF UPPER (L_money (i).subst_model) IN ('N/A', 'NA') THEN
                   CONTINUE;
              END IF;
              L_NOTIFY_MANAGER (I)   := 'Y';
              L_GRADE (I)              := 'ERROR';
              L_error_message (i)    := 'substitute Model is not N/A or NA';
         END LOOP;
    END;

  • Can't get my plsql working, ORA-05602 error

    Hello all, I am experiencing an issue with my plsql and I have check all my variables and it seems to be hidden from my eyes. This is my package:
    create or replace package body PKG_TESTSTR is
       type segment is record (
          bbold  boolean,
          bundr  boolean,
          bital  boolean,
          bleft  boolean,
          brigh  boolean,
          bcent  boolean,
          bjust  boolean,
          btipo  varchar2(1),
          text   VARCHAR2(32767));
       type LSEGMENTS is TABLE OF segment index by pls_integer;
       function splitSegments2(input VarChar2) return LSEGMENTS
       Is
          l_idx     pls_integer;
          bbold     boolean := false;
          bundr     boolean := false;
          bital     boolean := false;
          bleft     boolean := false;
          brigh     boolean := false;
          bcent     boolean := false;
          bjust     boolean := false;
          btipo     varchar2(1);
          info      VarChar2(32767);
          i         pls_integer := 0;
          segments  LSEGMENTS;
       Begin
          info := input;
          loop
             l_idx := instr(info,'<');
             i := i + 1;
             segments(i).bbold := bbold;
             segments(i).bundr := bundr;
             segments(i).bital := bital;
             segments(i).bleft := bleft;
             segments(i).brigh := brigh;
             segments(i).bcent := bcent;
             segments(i).bjust := bjust;
             segments(i).btipo := btipo;
             if l_idx > 0 then
                if upper(substr(info,l_idx+1,2)) = 'B>' then
                   if bbold then raise_application_error(-20010, 'B'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bbold := true;
                   info  := substr(info,l_idx+3);
                   btipo := 'F';
                elsif upper(substr(info,l_idx+1,2)) = 'I>' then
                   if bital then raise_application_error(-20010, 'I'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bital := true;
                   info  := substr(info,l_idx+3);
                   btipo := 'F';
                elsif upper(substr(info,l_idx+1,2)) = 'U>' then
                   if bundr then raise_application_error(-20010, 'U'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bundr := true;
                   info  := substr(info,l_idx+3);
                   btipo := 'F';
                elsif upper(substr(info,l_idx+1,15)) = 'P ALIGN="LEFT">' then
                   if bleft then raise_application_error(-20010, 'P LEFT'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bleft := true;
                   info  := substr(info,l_idx+16);
                   btipo := 'A';
                elsif upper(substr(info,l_idx+1,16)) = 'P ALIGN="RIGHT">' then
                   if brigh then raise_application_error(-20010, 'P RIGHT'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   brigh := true;
                   info  := substr(info,l_idx+17);
                   btipo := 'A';
                elsif upper(substr(info,l_idx+1,17)) = 'P ALIGN="CENTER">' then
                   if bcent then raise_application_error(-20010, 'P CENTER'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bcent := true;
                   info  := substr(info,l_idx+18);
                   btipo := 'A';
                elsif upper(substr(info,l_idx+1,18)) = 'P ALIGN="JUSTIFY">' then
                   if bjust then raise_application_error(-20010, 'P JUSTIFY'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bjust := true;
                   info  := substr(info,l_idx+19);
                   btipo := 'A';
                elsif upper(substr(info,l_idx+1,3)) = '/B>' then
                   if not bbold then raise_application_error(-20010, '/B'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bbold := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/I>' then
                   if not bital then raise_application_error(-20010, '/I'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bital := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/U>' then
                   if not bundr then raise_application_error(-20010, '/U'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bundr := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/P>' and bleft then
                   if not bleft then raise_application_error(-20010, '/P LEFT'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bleft := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/P>' and brigh then
                   if not brigh then raise_application_error(-20010, '/P RIGHT'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   brigh := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/P>' and bcent then
                   if not bcent then raise_application_error(-20010, '/P CENTER'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bcent := false;
                   info  := substr(info,l_idx+4);
                elsif upper(substr(info,l_idx+1,3)) = '/P>' and bjust then
                   if not bjust then raise_application_error(-20010, '/P JUSTIFY'); end if;
                   if l_idx = 1 then
                      i := i - 1;
                   else
                      segments(i).text := substr(info,1,l_idx-1);
                   end if;
                   bjust := false;
                   info  := substr(info,l_idx+4);
                else
                   segments(i).text := substr(info,1,l_idx);
                   info  := substr(info,l_idx+1);
                   btipo := 'T';
                end if;
             else
                segments(i).text := info;
                exit;
             end if;
          end loop;
          return segments;
       End;
       function generateReportsTags(input Varchar2) return Varchar2
       Is
          segments LSEGMENTS;
          resp     varchar2(32767);
          --resp     long;
          bold     boolean := false;
          alin     boolean := false;
          tipo     varchar2(1);
          y        number;
       Begin
          dbms_output.put_line('Iniciando execucao');
          y := 0;
          segments := splitSegments2(input);
          dbms_output.put_line('Passou pelo split');     
          for i in segments.first .. segments.last loop
             if i = 1 then
                resp := '<report>' || chr(13) || chr(10);
                resp := resp || '<layout>' || chr(13) || chr(10);
                resp := resp || '<section name="main">' || chr(13) || chr(10);
                resp := resp || '<body>' || chr(13) || chr(10);
                resp := resp || '<frame name="M_1">' || chr(13) || chr(10);
                resp := resp || '<geometryInfo x="0.00000" y="0.00000" width="7.12500" height="3.00000"/>' || chr(13) || chr(10);
                resp := resp || '<generalLayout verticalElasticity="variable"/>' || chr(13) || chr(10);
                resp := resp || '<text name="B_1" minWidowLines="1">' || chr(13) || chr(10);
                resp := resp || '<textSettings spacing="single"/>' || chr(13) || chr(10);
             end if;
             if nvl(tipo,' ') <> ' ' and nvl(tipo,' ') <> nvl(segments(i).btipo,' ') then
                resp := resp || '</text>' || chr(13) || chr(10);
                resp := resp || '<text name="B_1" minWidowLines="1">' || chr(13) || chr(10);
             end if;
             if segments(i).btipo in ('A') then
                if segments(i).brigh then
                   resp := resp || '<textSettings justify="end" spacing="single"/>' || chr(13) || chr(10);
                elsif segments(i).bcent then
                   resp := resp || '<textSettings justify="center" spacing="single"/>' || chr(13) || chr(10);
                elsif segments(i).bjust then
                   resp := resp || '<textSettings justify="flush" spacing="single"/>' || chr(13) || chr(10);
                elsif segments(i).bleft then
                   resp := resp || '<textSettings justify="start" spacing="single"/>' || chr(13) || chr(10);
                end if;
             end if;
             if i = 1 then
                y := 0.00000;
                resp := resp || '<geometryInfo x="0.06250" y="0.00000" width="7.00000" height="0.75000"/>' || chr(13) || chr(10);
                resp := resp || '<generalLayout verticalElasticity="variable"/>' || chr(13) || chr(10);
             elsif nvl(tipo,' ') <> ' ' and nvl(tipo,' ') <> nvl(segments(i).btipo,' ') then
                y := y + 0.75000;
                --width="7.06250"
                resp := resp || '<geometryInfo x="0.06250" y="'|| to_char(y + 0.00000, '0.00000') ||'" width="7.00000" height="0.75000"/>' || chr(13) || chr(10);
                resp := resp || '<generalLayout verticalElasticity="variable"/>' || chr(13) || chr(10);
             end if;        
             resp := resp || '<textSegment>' || chr(13) || chr(10);
             if segments(i).bbold then
                resp := resp || ' bold="yes"';
             end if;
             if segments(i).bital then
                resp := resp || ' italic="yes"';
             end if;
             if segments(i).bundr then
                resp := resp || ' underline="yes"';
             end if;
             resp := resp || '/>' || chr(13) || chr(10);
             resp := resp || '<string>' || chr(13) || chr(10);
             resp := resp || '<![CDATA[';
             resp := resp || segments(i).text;
             resp := resp || ']]>' || chr(13) || chr(10);
             resp := resp || '</string>' || chr(13) || chr(10);
             resp := resp || '</textSegment>' || chr(13) || chr(10);
             if (bold = true or alin = true) then        
                bold := false; 
                alin := false;
             end if;
             tipo := segments(i).btipo;
             if i = segments.last then
                resp := resp || '</text>' || chr(13) || chr(10);
                resp := resp || '</frame>' || chr(13) || chr(10);
                resp := resp || '</body>'    || chr(13) || chr(10);
                resp := resp || '</section>' || chr(13) || chr(10);
                resp := resp || '</layout>'  || chr(13) || chr(10);
                resp := resp || '</report>'  || chr(13) || chr(10);
            end if;
          end loop;
          return resp;
       End;
       procedure splitSegments(input VarChar2)
       Is
          segments LSEGMENTS;
          function Prin (bbold boolean, bundr boolean, bital boolean, bleft boolean, brigh boolean, bcent boolean, bjust boolean) return VarChar2
          Is
             resp VarChar2(3) := '';
          begin
             if bbold then resp := resp || 'B'; end if;
             if bundr then resp := resp || 'U'; end if;
             if bital then resp := resp || 'I'; end if;
             if bleft then resp := resp || 'P'; end if;
             if brigh then resp := resp || 'P'; end if;
             if bcent then resp := resp || 'P'; end if;
             if bjust then resp := resp || 'P'; end if;
             return resp;
          end;
       Begin
          segments := splitSegments2(input);
          for i in segments.first .. segments.last loop
             dbms_output.put_line(prin(segments(i).bbold, segments(i).bundr, segments(i).bital, segments(i).bleft, segments(i).brigh, segments(i).bcent, segments(i).bjust) || ' : ' || segments(i).text);
          end loop;
       End;
    end PKG_TESTSTR;I am getting an ORA-05602 error, and then an ORA-05612 at line 3 when I try to use and input with more than 4000 chars. Is this the problem?? I have changed all my varchar2 variables to get 32767 chars but i am still facing the same error.
    What I am possible doing wrong?
    Many thanks for all replies
    Thiago Locatelli

    That would be a bit of a problem once I cant get the part where it is raising such error. I have put dbms_output for debug, but everything goes in the outpout window but the error occurs.
    I am using plsql/developer to test the function...

  • PLSQL compiles but doesn't run.. I've declared it everywhere but still..

    PLSQL compiles but doesn’t run.. I’ve declared it everywhere but still..
    Afternoon.. Hopefully a quick one for someone.. I’m trying to run a Concurrent Program in ORACLE Financials using a Data Template derived BI Publisher report.
    Error message received..
    SUBIXCLT module: UofS Expense Claim Tracking Report
    +--------------------------------------------------------------------------
    All Parameters: raisedby=:status=:claimant=:expense_date_from=:expense_date_to=:LP_ORDERED_BY=Expense Report Number
    Data Template Code: SUBIXCLT
    Data Template Application Short Name: PO
    Debug Flag: N
    {raisedby=, claimant=, expense_date_to=, expense_date_from=, status=, LP_ORDERED_BY=Expense Report Number}
    Calling XDO Data Engine...
    [060410_025628319][][STATEMENT] Start process Data
    [060410_025628324][][STATEMENT] Process Data ...
    [060410_025628329][][STATEMENT] Executing data triggers...
    [060410_025628329][][STATEMENT] BEGIN
    SUBIXCLT.claimant := :claimant ;
    SUBIXCLT.expense_date_from := :expense_date_from ;
    SUBIXCLT.expense_date_to := :expense_date_to ;
    SUBIXCLT.raisedby := :raisedby ;
    SUBIXCLT.status := :status ;
    SUBIXCLT.lp_ordered_by := :lp_ordered_by ;
    :XDO_OUT_PARAMETER := 1;
    END;
    l_flag Boolean;
    BEGIN
    l_flag := SUBIXCLT.BEFOREREPORT(L_ORDERED) ;
    if (l_flag) then
    :XDO_OUT_PARAMETER := 1;
    end if;
    end;
    [060410_025628356][][EXCEPTION] SQLException encounter while executing data trigger....
    java.sql.SQLException: ORA-06550: line 4, column 33:
    PLS-00201: identifier 'L_ORDERED' must be declared
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignoredThe Data Template
    The Data Template
    <?xml version="1.0" encoding="utf-8" ?>
    - <dataTemplate name="UofS_OutstandngExpenses_Report" defaultPackage="SUBIXCLT" dataSourceRef="FINDEV" version="1.0">
    - <properties>
      <property name="xml_tag_case" value="upper" />
      <property name="include_parameters" value="true" />
      <property name="debug_mode" value="on" />
      </properties>
    - <parameters>
      <parameter name="claimant" dataType="character" defaultValue="" />
      <parameter name="expense_date_from" dataType="date" defaultValue="" />
      <parameter name="expense_date_to" dataType="date" defaultValue="" />
      <parameter name="raisedby" dataType="character" defaultValue="" />
      <parameter name="status" dataType="character" defaultValue="" />
      <parameter name="lp_ordered_by" dataType="character" defaultValue="" />
      </parameters>
    - <dataQuery>
      <dataTrigger name="beforeReportTrigger" source="SUBIXCLT.BEFOREREPORT(L_ORDERED)" />
    - <sqlStatement name="Q1">
    - <![CDATA[
    SELECT DISTINCT
    erh.invoice_num,
    pap.full_name EMP_CLAIMING,
    DECODE(NVL(erh.expense_status_code, 'Not yet Submitted (NULL)'), 'CANCELLED', 'CANCELLED',
         'EMPAPPR', 'Pending Individuals Approval',      'ERROR', 'Pending System Administrator Action',
         'HOLD_PENDING_RECEIPTS     ', 'Hold Pending Receipts', 'INPROGRESS', 'In Progress', 'INVOICED', 'Ready for Payment',
         'MGRAPPR', 'Pending Payables Approval', 'MGRPAYAPPR', 'Ready for Invoicing', 'PAID', 'Paid',
         'PARPAID', 'Partially Paid',     'PAYAPPR', 'Payables Approved',     'PENDMGR', 'Pending Manager Approval',
         'PEND_HOLDS_CLEARANCE', 'Pending Payment Verification',     'REJECTED', 'Rejected',     'RESOLUTN',     'Pending Your Resolution',
         'RETURNED',     'Returned',     'SAVED',     'Saved',     'SUBMITTED',     'Submitted',     'UNUSED',     'UNUSED',
         'WITHDRAWN','Withdrawn',     'Not yet Submitted (NULL)') "EXPENSE_STATUS" ,
    NVL(TO_CHAR(erh.report_submitted_date,'dd-MON-yyyy'),'NULL') SUBMIT_DATE,
    NVL(TO_CHAR(erh.expense_last_status_date,'dd-MON-yyyy'),'NULL') LAST_UPDATE,
    erh.override_approver_name ER_Approver,
    fu.description EXP_ADMIN,
    erh.total,
    erh.description 
    FROM
    AP_EXPENSE_REPORT_HEADERS_all erh,
    per_all_people_f pap, fnd_user fu
    WHERE erh.employee_id = pap.person_id
    AND fu.user_id = erh.created_by
    AND NVL(erh.expense_status_code, 'Not yet Submitted') NOT IN  ('MGRAPPR', 'INVOICED', 'PAID', 'PARPAID')
    AND pap.full_name = NVL(:claimant, pap.full_name)
    AND TRUNC(erh.report_submitted_date) BETWEEN NVL(:expense_date_from, '01-JAN-1999') AND NVL(:expense_date_to,'31-DEC-2299')
    AND fu.description = NVL(:raisedby,fu.description)
    AND erh.expense_status_code = NVL(:status,erh.expense_status_code) &LP_ORDERED_BY
      ]]>
      </sqlStatement>
      </dataQuery>
      <dataTrigger name="beforeReportTrigger" source="SUBIXCLT.BEFOREREPORT(L_ORDERED)" />
    - <dataStructure>
    - <group name="G_XP_CLM_TRACKNG" source="Q1">
      <element name="INVOICE_NUM" value="INVOICE_NUM" />
      <element name="EMP_CLAIMING" value="EMP_CLAIMING" />
      <element name="EXPENSE_STATUS" value="EXPENSE_STATUS" />
      <element name="SUBMIT_DATE" value="SUBMIT_DATE" />
      <element name="LAST_UPDATE" value="LAST_UPDATE" />
      <element name="LP_ORDERED_BY" dataType="varchar2" value="SUBIXCLT.LP_ORDERED_BY" />
      </group>
      </dataStructure>
      </dataTemplate>The PL SQL..
    The PL SQL..
    CREATE OR REPLACE PACKAGE Subixclt IS
    L_ORDERED  VARCHAR2(50);
    RAISEDBY VARCHAR2(50);
    STATUS VARCHAR2(50);
    CLAIMANT VARCHAR2(50);
    LP_ORDERED_BY VARCHAR2(50);
    FUNCTION BEFOREREPORT(L_ORDERED IN VARCHAR2) RETURN VARCHAR2;
    EXPENSE_DATE_FROM DATE;
    EXPENSE_DATE_TO DATE;
    --RETURN VARCHAR2;
    END;
    CREATE OR REPLACE PACKAGE BODY Subixclt IS
    FUNCTION BEFOREREPORT(L_ORDERED IN VARCHAR2)RETURN VARCHAR2 IS
    BEGIN
    Fnd_File.PUT_LINE(Fnd_File.LOG,'L_ORDERED'||L_ORDERED);
    DECLARE
    LP_ORDERED_BY VARCHAR2(50);
    L_ORDERED  VARCHAR2(50);
    RAISEDBY VARCHAR2(50);
    STATUS VARCHAR2(50);
    CLAIMANT VARCHAR2(100);
    EXPENSE_DATE_FROM DATE;
    EXPENSE_DATE_TO DATE;
    BEGIN
    IF (LP_ORDERED_BY='Expense Report Number') THEN
         LP_ORDERED_BY :='order by 1 asc;';
      ELSIF (LP_ORDERED_BY='Person Claiming') THEN
         LP_ORDERED_BY :='order by 2 asc;';
      ELSIF (LP_ORDERED_BY='Submit Date') THEN
      LP_ORDERED_BY :='order by 4 asc;';
      END IF;
    RETURN(L_ORDERED);
    --RETURN NULL;
    END;
    END;
    END;Thanks for looking..
    Steven
    Edited by: Mr_Alkan on Jun 4, 2010 3:35 PM

    One has to initialise a session first for use with Oracle Apps if you want to make it run as a concurrent job.
    Any decleration within your package will not be recognised unless initialisation is sucessful.
    Investigate the built-in packages:
    FND_GLOBAL - for initialisation
    FND_SUBMIT - for setting session relevant parameters
    -- function returns true or false depending on whether the initialisation was sucessful or not
    create or replace function is_Init_OK (p_User_Name       in varchar2
                                          ,p_Responsibility  in varchar2
                                          ,p_Language        in varchar2) return boolean as
      b_Set_NLS   boolean;
      b_Set_Mode  boolean;
      r_ISet      fnd_Init := Get_Init_Set(p_User_Name, p_Responsibility);
      begin
        -- 1
        fnd_global.apps_initialize(r_ISet.User_ID, r_ISet.Resp_ID, r_ISet.App_ID);
        -- 2
        b_Set_NLS := fnd_submit.set_nls_options(p_Language);
        -- 3
        b_Set_Mode  := fnd_submit.set_mode (false);
        return (b_Set_Mode and b_Set_NLS and (    (r_ISet.Resp_ID is not null)
                                              and (r_ISet.User_ID is not null)
        exception
          when others then
            return false;
    end is_Init_OK;
    -- for example
    declare
      l_User_ID number = 'IMPORT_POST'; --- import post user
      l_Resp    number =  'Import and Posting responsibility' -- import posting responsibility
      l_Language varchar2(100) := 'AMERICAN';
      b_Init boolean := false;
      INIT_EXCEPTION exception;
    begin
      b_Init := is_Init_OK(l_User_ID, l_Resp, l_Language);
      if (not b_Init) then
        raise INIT_EXCEPTION;
      end if;
      -- conitnue with your processing
      exception 
        when others then
          when INIT_EXECPTION then
          when others then
    end;
    /

  • PLSQL in Infinite Loop -- Help!

    The PLSQL procedure below seems to go into an infinite loop. I am hoping that someone out there can tell me why? Many thanks in advance!
    create or replace procedure GF_POC_Migration is
    v_subdo_data varchar2(180); /* email address */
    v_subdo_type varchar2(180); /* email, rss, my yahoo, etc */
    v_subdo_created date;
    v_subdo_modified date;
    v_subdo_subs_id number(20); /* POC subscritpion set id */
    v_subs_identifier varchar2(80); /* POC System cookie identifier */
    v_subs_id number(19); /* POC Subscription SET Id */
    v_sub_id number(19); /* POC Subscription Id*/
    v_subs_created date;
    v_subs_modified date;
    v_sub_created date;
    v_sub_modified date;
    v_consumer_id number(19);
    v_client_shopper_id number(19);
    v_client_id number(19);
    v_sequence_nxtval number(19);
    v_als_id number(19); /* Alert Selector Id */
    v_product_name varchar2(100);
    v_category_name varchar2(254);
    /* Sub Delivery Options from the POC System contains all the information for
    the consumers email address. Using this to drive the process of migration -
    consumer by consumer*/
    Cursor SUBDO_CURSOR IS
    select SUBDO_SUBS_ID, SUBDO_DATA, SUBDO_TYPE, t.SUBS_CREATED, t.SUBS_MODIFIED
    from rm_sub_delivery_options s, rm_subscription_sets t
    where s.subdo_data not in (select t.ooe_email from rm_optout_emails t)
    and t.subs_id = s.subdo_subs_id;
    /* Subscription Sets in the POC system relates to RM_CLIENT_SHOPPER in v1.5 */
    Cursor SUBSCRIPTION_SETS_CURSOR IS
    select subs_identifier, subs_created, subs_modified, subs_id
    from rm_subscription_sets t
    where t.subs_id = v_subdo_subs_id;
    Cursor CLIENTS_CURSOR IS
    select client_id from rm_client t
    where identifier='GUESSFACTORY';
    Cursor NXTVAL_GLOBAL_SEQ IS /* Rainmaker's one and only seq # generator in v1.5 */
    Select rm_global_sequence.nextval
    from dual;
    Cursor SUBSCRIPTIONS_CURSOR IS
    select t.sub_id, t.sub_created, t.sub_modified
    from rm_subscriptions t
    where t.sub_subs_id = v_subs_id;
    CURSOR POC_CAT_AND_PRODS_CURSOR IS /* Get the selector via two view joins to POC & v1.5 */
    select als_id, tier3, full_cat_name
    from poc_catsprodssubs poc, v15_categories_mig v15
    where upper(poc.prd_name)=upper(v15.tier3)
    and upper(poc.prd_identifier)=upper(v15.full_cat_name)
    and poc.sub_id = v_sub_id;
    begin
    /*DBMS_OUTPUT.ENABLE(100000000);*/
    OPEN CLIENTS_CURSOR; /* Get the Guess Factory ID the one time */
    FETCH CLIENTS_CURSOR INTO v_client_id;
    CLOSE CLIENTS_CURSOR;
    OPEN SUBDO_CURSOR;
    LOOP
    FETCH SUBDO_CURSOR /* Get the Signup Email, RSS, etc Info */
    INTO v_subdo_subs_id, v_subdo_data, v_subdo_type, v_subdo_created, v_subdo_modified;
    EXIT WHEN SUBDO_CURSOR%NOTFOUND;
    /*dbms_output.put_line('v_subdo_subs_id = ' || v_subdo_subs_id || ' + ' || v_subdo_data);*/
    LOOP /* Each line of RM_SUBSCRIPTION_SETS - need to create a new row in RM_CLIENT_SHOPPER */
    OPEN NXTVAL_GLOBAL_SEQ; /* Get the next seq value */
    FETCH NXTVAL_GLOBAL_SEQ INTO v_sequence_nxtval;
    v_client_shopper_id := v_sequence_nxtval; /* Capture client_shopper_id */
    CLOSE NXTVAL_GLOBAL_SEQ;
    /*dbms_output.put_line('v_clientshopper_id = ' || v_client_shopper_id || ' + ' || v_sequence_nxtval);*/
    /* Get corresponding records from RM_SUBSCRIPTION_OPTIONS */
    OPEN SUBSCRIPTION_SETS_CURSOR;
    FETCH SUBSCRIPTION_SETS_CURSOR
    INTO v_subs_identifier, v_subs_created, v_subs_modified, v_subs_id;
    EXIT WHEN SUBSCRIPTION_SETS_CURSOR%NOTFOUND;
    /*dbms_output.put_line('poc cookie = ' || v_subs_identifier || ' + ' || v_subs_id);*/
    /* Get the Consumer Id */
    OPEN NXTVAL_GLOBAL_SEQ;
    FETCH NXTVAL_GLOBAL_SEQ INTO v_sequence_nxtval;
    v_consumer_id := v_sequence_nxtval;
    /*dbms_output.put_line('v_consumer_id = ' || v_consumer_id || ' + ' || v_sequence_nxtval);*/
    CLOSE NXTVAL_GLOBAL_SEQ;
    /* Start the Client Inserts */
    INSERT INTO RM_CONSUMER (CONSUMER_ID, CHANGE_NUMBER, STATUS, CREATED, MODIFIED)
    VALUES(v_consumer_id, 0,0, v_subs_created, v_subs_modified);
    /* dbms_output.put_line('Insert to Client Shopper' || v_client_shopper_id || ' + ' ||'Consumer Id:' ||v_consumer_id);
    dbms_output.put_line('Also..Client Id' || v_client_id );*/
    INSERT INTO RM_CLIENT_SHOPPER (CLIENT_SHOPPER_ID, CONSUMER_ID, CHANGE_NUMBER, COOKIE_IDENTIFIER,
    CLIENT_ID, STATUS, LAST_KNOWN_CRS_PROD_IDX, SIGNUP_SUCCESS_STEP, SIGNUP_FAILURE_STEP,
    CREATED, MODIFIED)
    VALUES (v_client_shopper_id, v_consumer_id, 5, v_subs_identifier, v_client_id, 2,0,1,0,v_subs_created, v_subs_modified);
    CLOSE SUBSCRIPTION_SETS_CURSOR;
    /* Start handing the SUBSCRIPTIONS: move POC --> v1.5 */
    OPEN SUBSCRIPTIONS_CURSOR;
    OPEN POC_CAT_AND_PRODS_CURSOR; /* I know I shouldn't be opening/closing this but ... */
    LOOP
    FETCH SUBSCRIPTIONS_CURSOR
    INTO v_sub_id, v_sub_created, v_sub_modified; /* Get subscription info from the POC tables */
    EXIT WHEN SUBSCRIPTIONS_CURSOR%NOTFOUND;
    /*dbms_output.put_line('v_sub_id = ' || v_sub_id || ' + ' || v_sub_created);*/
    INSERT INTO RM_SUBSCRIPTION (SUBSCRIPTION_ID, CHANGE_NUMBER, CREATED, MODIFIED)
    VALUES (rm_global_sequence.nextval, 0, v_sub_created, v_sub_modified);
    FETCH POC_CAT_AND_PRODS_CURSOR
    INTO v_als_id, v_product_name, v_category_name; /* Get correct Alert Selector, Product & Category by matching to the v1.5 tables */
    EXIT WHEN POC_CAT_AND_PRODS_CURSOR%NOTFOUND;
    INSERT INTO RM_NEW_ARRIVALS_SUBSCRIPTION (SUBSCRIPTION_ID,ALERT_SELECTOR_ID,
    CLIENT_SHOPPER_ID, IS_PRIMARY, STATUS) /* Populate the v1.5 Alert Selector selections */
    VALUES(rm_global_sequence.currval, v_als_id, v_client_shopper_id, 0, 1 );
    END LOOP; /* Subsrciption */
    CLOSE POC_CAT_AND_PRODS_CURSOR;
    CLOSE SUBSCRIPTIONS_CURSOR;
    END LOOP; /*Sub Scription Sets */
    /* Populate the v1.5 RM_DELIVERY_OPTIONS table */
    INSERT INTO RM_DELIVERY_OPTION (DELIVERY_OPTION_ID, CHANGE_NUMBER, TYPE, DATA, CLIENT_SHOPPER_ID,CREATED, MODIFIED)
    VALUES (RM_GLOBAL_SEQUENCE.NEXTVAL, 0, v_subdo_type, v_subdo_data, v_client_shopper_id, v_subdo_created, v_subdo_modified);
    /*COMMIT;*/
    END LOOP; /* Main Control Loop */
    CLOSE SUBDO_CURSOR;
    END GF_POC_Migration;

    If you cut out all the things that are obviously open/closed etc. and look at your loops...
    BEGIN
       OPEN subdo_cursor;
       LOOP
          FETCH subdo_cursor INTO v_subdo_subs_id, v_subdo_data, v_subdo_type, v_subdo_created, v_subdo_modified;
          EXIT WHEN subdo_cursor%NOTFOUND;
          LOOP
             OPEN subscriptions_cursor;
             OPEN poc_cat_and_prods_cursor;
             LOOP
                FETCH subscriptions_cursor INTO v_sub_id, v_sub_created, v_sub_modified;
                EXIT WHEN subscriptions_cursor%NOTFOUND;
                FETCH poc_cat_and_prods_cursor INTO v_als_id, v_product_name, v_category_name;
                EXIT WHEN poc_cat_and_prods_cursor%NOTFOUND;
             END LOOP;                                          /* Subsrciption */
             CLOSE poc_cat_and_prods_cursor;
             CLOSE subscriptions_cursor;
          END LOOP;  << THERE IS NOTHING TO EXIT THIS LOOP
       END LOOP;
       CLOSE subdo_cursor;
    END gf_poc_migration;

  • Simple - plsql query

    I am new to plsql and want to do following in plsql code:
    code start select max(col1) from table1;
    -- and save the max value in variable VAR1
    select COL1, case COL2 when VAR1 THEN 'VALUE ONE'
    ELSE 'VALUE ELSE'
    END
    from table1
    -- I want to see the o/p of second select on the screen
    code ends how can i write the above plsql code.

    No, its not working... see the below..
    create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
    create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
    select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
    INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
    but when i use
    select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
    TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
    i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
    the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
    .. any help...
    not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
    requirements is
    mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx

  • Report based on sql or plsql

    Hello,
    I have an LOV_COLS, which contains the columns of scott.emp and is represented by a list P50_MY_COLS, and textfield P50_SEARCHTERM where I can enter a search term.
    Now I like to have a report which displays something like SELECT EMPNO, ENAME, MGR, SAL, COMM FROM EMP WHERE UPPER(:P50_MY_COLS) LIKE UPPER(:P50_SEARCHTERM) if a button P50_SEARCH is pressed.
    I'd like also to control the Columns if they contain NULL. The report should display the respective rows after pressing the Button P50_NULLSEARCH
    After the desired rows are reported I'd like to be abel to edit the rows...
    How can this be realized ? What is the source of the report ?
    I use the Apex 2.1 which comes with the Oracle XE installation.
    Can someone provide an example ?
    Where in the docs are the differences (with examples) of the different sql and plsql based reports explained ?
    Can a report by based on a plsql procedure/function which resides in the database (not inside the Apex-pages) ?
    thx in advance
    Edited by: wucis on Mar 10, 2011 1:17 PM

    Sharmila,
    Thanks for your response. Maybe I wasn't clear enough in my previous statement. I will give an example of what I am trying to accomplish.
    Let's say I have 2 date fields(SUBMITDATE,COMPLETEDATE) in a table TABLE A
    I want to calculate a field called CYCLETIME with the following conditions:
    If COMPLTEDATE is NULL, then CYCLETIME = SYSDATE-SUBMITDATE
    IF COMPLTEEDATE is not null, then CYCLETIME = COMPLTEEDATE-SUBMITDATE
    Would appreciate any help.
    Thanks
    Dev
    Hi,
    You can do the calculation in the sql query itself. Here is an example which shows the sum of salaray for each department in the scott.emp table.
    select deptno,sum(sal) sal
    from scott.emp
    group by deptno
    Thanks,
    Sharmila

  • PLSQL-generated SQL report with variable number of columns

    I created an app to track college football bowl picks:
    http://apex.oracle.com/pls/otn/f?p=21723
    The main report region includes columns for the various games as well as a column for each participant. In order not to hard code the number of participants, I used PLSQL to generate the SQL so that new columns could be added on the fly.
    However, whenever I add a new user I get this result -
    report error:
    ORA-01403: no data found
    If I copy and paste the PLSQL into a new report region and then delete the old one, however, all is well.
    Is there something I can do to overcome this?
    Thanks.
    Bill

    Roberto
    <br><br>
    Here are the tables:
    <br><br>
    BOWL_GAMES<br>
    ID     NUMBER<br>
    NAME     VARCHAR2(30)<br>
    FAV     VARCHAR2(20)<br>
    DOG     VARCHAR2(20)<br>
    BDATE     DATE<br>
    LINE     NUMBER(3,1)<br>
    FAV_SCORE     NUMBER(4,0)<br>
    DOG_SCORE     NUMBER(4,0)<br>
    <br>
    BOWL_USERS<br>
    ID     NUMBER<br>
    USERNAME     VARCHAR2(20)<br>
    PW     VARCHAR2(20)<br>
    NAME     VARCHAR2(20)<br>
    EMAIL     VARCHAR2(50)<br>
    <br>
    BOWL_PICKS<br>
    ID     NUMBER(5,0)<br>
    USERID     NUMBER(10,0)<br>
    GAMEID     NUMBER(10,0)<br>
    PICK     NUMBER(1,0)<br>
    <br>
    <br>
    Below is my PLSQL. Feel free to try out the app. Thanks.
    <br><br>
    Bill<br><br>
    declare<br>
    p_sql varchar2(32767);<br>
    cursor c1 is select * from bowl_users order by id;<br>
    begin<br>
    p_sql := q'! select to_char(b.bdate, 'Mon FMdd') "Date", b.name, '< a href="javascript$pickEm(''' || b.fav || ''')">' || b.fav || '</ a> -' || b.line || ' < a href="javascript$pickEm(''' || b.dog || ''')">' || b.dog || '</ a>' "Line" !';<br>
    for a1 in c1 loop<br>
    p_sql := p_sql || q'! , bowl_strike(b.id, !' || a1.id || q'! , 0) || (select decode(p.pick, 0, substr(b.dog,1,4), 1, substr(b.fav,1,4), 'No pick') from bowl_picks p where p.userid = !' || a1.id || q'! and p.gameid = b.id) || bowl_strike(b.id, !' || a1.id || q'! , 1) "!' || upper(a1.name) || q'!" !';<br>
    end loop;<br>
    p_sql := p_sql || q'! , bowl_score(b.id) "SCORE" from bowl_games b order by b.bdate !';<br>
    return replace(p_sql,'$',':');<br>
    end;
    <br><br>
    Message was edited by:
    [email protected]

  • Error ERR-9131 Error in PLSQL function body for item default code, item=P24

    Hi All,
    Am getting the below error in my page 24
    ORA-01403: no data found
    Error ERR-9131 Error in PLSQL function body for item default code, item=P24_REQ_BY_ID
    OK
    I dont know what to do?:(
    Suddenly am getting this error in the page.
    Can anyone help me to understand why this error is coming?
    Thanks & Regards,
    Ramya
    Edited by: 901942 on Jan 29, 2012 10:16 PM

    Data stored in these tables is different. If Oracle says that there's no record that satisfies the WHERE condition, why do you think that it lies? It is too stupid to do that.
    Therefore, you need to handle the exception. There are several ways to do it. Here are some of them.
    The first one is the most obvious - EXCEPTION handling section.
    DECLARE
      default_value VARCHAR2(100);
    BEGIN
      SELECT ISID INTO default_value
        FROM USER_TBL
        WHERE UPPER(ISID) = UPPER(:APP_USER);
      RETURN default_value;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN (null);  -- or whatever you find appropriate
    END;Another one is to use aggregate function (MAX is a good choice) as it won't return NO-DATA-FOUND, but NULL:
    DECLARE
      default_value VARCHAR2(100);
    BEGIN
      SELECT MAX(ISID) INTO default_value
        FROM USER_TBL
        WHERE UPPER(ISID) = UPPER(:APP_USER);
      RETURN default_value;
    END;

  • Why does plsql give compilation error for select statement?

    When I run following plsql program, it gives compilation error. Could somebody please point me out what could be wrong here? I am running it from system user.
    create or replace procedure drop_user_proc (iname in varchar2) is
    uname varchar2(100);
    begin
    select username into uname from dba_users where username = upper(iname);
    end drop_user_proc;
    select username from dba_users where username = upper('newuser');
    When I run it, I get following error. dba_users is there that is the reason it works outside plsql block, but it doesn't from inside block.
    SQL> @t4
    Warning: Procedure created with compilation errors.
    USERNAME
    NEWUSER
    SQL> show err
    Errors for PROCEDURE DROP_USER_PROC:
    LINE/COL ERROR
    4/3 PL/SQL: SQL Statement ignored
    4/35 PL/SQL: ORA-00942: table or view does not exist

    Role based grants are not available within the stored procedures.
    Only explicit grants are recognized when compiling stored code.
    You need to grant select on that table to the user where you are creating this procedure.

Maybe you are looking for

  • How to set custom size of Close Button e.g. 32x32  of Title Window in Flex 4

    How to set custom size of Close Button e.g. 32x32 of Title Window in Flex 4?

  • It wont turn on - it says nothing to boot

    I bought my Macbook Air in July 2013. It worked perfectly yesterday and when I turned it on today, it said low battery so I connected my charger, and restarted my laptop. When I turned it on, the Apple sound appeared but the screen was all white with

  • How Does One Share Calendar(s)?

    My wife and I each have iPads.  Mine is iPad 1, and hers is iPad 2.  Both use the current iOS 5.1.1.  We each have our own iCloud account and we currently share several calendars, but each have two that are not.  How do we share them all with each ot

  • Hello PA - OM - Time & PM

    Dear Friends if some one has documents relating to SAP - HR please forward it my mail id [email protected] thanks in advance Regards Zuben

  • [EREC - Unregistered candidate] - error verification procedure

    hi, If an unregistered candidate registers or applies for a job a secure e-mail verification procedure should be granted for each external candidate. But the system does not send this verification procedure... Why? The table T77S0 is customizing with