PLSQL procedures please help

Have put below my query

Hi all,
Sorry for troubling ,again i am requesting your inputs and any possible help.
I am thinking that my the question confusing now also? I very appreciate your suggestions and accordingly i will try so that everyone can understand and help on the query.
Edited by: user_7000011 on 23-Mar-2009 10:52

Similar Messages

  • Configuration of Deffered Tax Procedure, please help?

    Hi Experts,
    I am working on a project.
    please help me to configure Deffered Tax procedure.
    So far I have configured regular Tax codes & replica of the same as target tax code.
    Please advice how to :
    1. what special should i mention to in target tax code to declare it as a target tax code?
    2. how do i link Normal & target tax code
    3. which all sessions to run in SAP, so that a particular Tax is posted upon full / partial / downpayment payment.
    looking forward to hear from you all, soonest.
    Thank you all.

    Hi
    You have to make the following settings:
    Process
    ·     A deferred tax code has to be created for the calculation and the posting of the service tax to the intermediate account.
    ·     Input tax or Output tax type has to be mentioned in the tax code
    ·     The target tax code (actual tax code for the availment of the service tax) has to be entered (FTXP)
    ·     The different rates have to be maintained under the respective tax types
    ·     For the account keys, the GL accounts have to be mentioned in the OB40 settings. In this case the same account has assigned for all the three account keys.
    ·     The GL account (40140) has to be open item managed and the tax category has to be in line with the tax type mentioned in the Tax code.

  • Configure Deffered Tax procedure, please help?

    Hi Experts,
    I am working on a project.
    please help me to configure Deffered Tax procedure.
    So far I have configured regular Tax codes & replica of the same as target tax code.
    Please advice how to :
    1. what special should i mention to in target tax code to declare it as a target tax code?
    2. how do i link Normal & target tax code
    3. which all sessions to run in SAP, so that a particular Tax is posted upon full / partial / downpayment payment.
    looking forward to hear from you all, soonest.
    Thank you all.

    Hi
    You have to make the following settings:
    Process
    ·     A deferred tax code has to be created for the calculation and the posting of the service tax to the intermediate account.
    ·     Input tax or Output tax type has to be mentioned in the tax code
    ·     The target tax code (actual tax code for the availment of the service tax) has to be entered (FTXP)
    ·     The different rates have to be maintained under the respective tax types
    ·     For the account keys, the GL accounts have to be mentioned in the OB40 settings. In this case the same account has assigned for all the three account keys.
    ·     The GL account (40140) has to be open item managed and the tax category has to be in line with the tax type mentioned in the Tax code.

  • Junior PLSQL Developer please help

    hello,
    i am working as PLSQL DEVELOPER
    i have written one procedure for my client, that will insert all the transactions that are done on particular day into a table.my peocedure is completed sucessfully but
    Here my problem is , my procedure should execute everyday
    at 7PM .i don't know how to execute that procedure everyday at 7PM.
    please give suggestions on this urgent
    regards
    vamsi

    You can obviously schedule a job in database using Database Scheduler but you should have a appropriate privilege to do so.
    Best thing is ask your DBA and they will schedule for you. You just have to proivde, what time you want to execute and what you want to execute and they will take care.
    SYS.DBMS_SCHEDULER.CREATE_JOB
    job_name => 'your_job_name'
    ,start_date => TO_TIMESTAMP_TZ('2007/05/21 14:08:13.335383 -04:00','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
    ,repeat_interval => 'FREQ=DAILY;BYHOUR=7;BYMINUTE=00'
    ,end_date => NULL
    ,job_class => 'DEFAULT_JOB_CLASS'
    ,job_type => 'PLSQL_BLOCK'
    ,job_action => 'begin YOUR_JOB_NAME ; end;'
    ,comments => 'ANYCOMMENT'
    );

  • PLSQL Practice-----Please help!!!

    Hi,
    I'm a beginner for the PLSQL. if someone give me some tips, It's really helpful for me.
    There two table.
    Table A (Transaction table : keep coming a rows)
    A_id B
    111 aaa,bbb,ccc
    222 yyy,ss,ccc
    333 sss,yyy,ddd
    Table B (Fixed code table)
    X_id Y
    xxx aaa,bbb,ccc
    yyy ggg,bb,cca
    zzz sss,yyy,ddd
    Table C
    A_id X_id
    1. First of all, I have to compare two table A & B (between B col & Y col). if the two columns match, I want to insert A_id & X_id into Table C.
    2. If the two columns are not match, I want to insert A_id & "OTHER"(Instead of the X_id) into the Table C.
    How can I get below results?
    A_ID X_ID
    111 xxx
    222 OTHER
    333 zzz

    duplicate thread.. and try this...
    SQL> select * from table_a;
    A_ID B
    111 aaa,bbb,ccc
    222 yyy,ss,ccc
    333 sss,yyy,ddd
    SQL> select * from table_b;
    X_ID Y
    xxx aaa,bbb,ccc
    yyy ggg,bb,cca
    zzz sss,yyy,ddd
    SQL> select * from table_c;
    no rows selected
    SQL> Insert into Table_C select table_a.a_id,nvl(table_b.x_id,'Other') From table_a left outer join table_b on table_a.B = table_b.Y;
    3 rows created.
    SQL> select * from table_c;
    A_ID X_ID
    111 xxx
    333 zzz
    222 Other

  • PL/SQL procedure--------------please help----what is it ?? explain brief

    (TO_DATE('&2')-1)
    CREATE OR REPLACE PROCEDURE GAT_SVC_ACTIVITY(REFDATE IN DATE:=SYSDATE-1,
    MSK IN INTEGER:=31)
    AS
    --DECLARE
    V_COUNT NUMBER :=0;
    V_LIMIT NUMBER :=0;
    V_SOURCE_SITE_ID NUMBER :=0;
    V_SOURCE_SITE_ID_N NUMBER := NULL;
    V_CUSSOR INTEGER;
    V_PROCESSED INTEGER;
    V_ERRDESC VARCHAR2(200);
    CURSOR C_TMP_ONSITE IS SELECT
    X.*,
    CLH.DATE_CODE CLH_DATE_CODE,
    CLH.DPS_NBR CLH_DPS_NBR,
    CLH.CASE_NUM CLH_CASE_NUM,
    CLH.FLG_DELLSRV CLH_FLG_DELLSRV,
    2 SVC_ACTIVITY_SRC_ID
    FROM (SELECT
    OS.DPS_NBR,
    OS.ARRIVE_TIMESTAMP,
    OS.COMPL_TIMESTAMP,
    OS.STATUS_CODE,
    OS.PROBLEM_CODE,
    OS.CAUSE_CODE,
    OS.ACTION_CODE,
    JH.DPS_NBR JH_DPS_NBR,
    JH.DPS_TYPE JH_DPS_TYPE,
    NVL2(TRIM(JH.TPM_CODE),TRIM(JH.TPM_CODE),'DELL') JH_TPM_CODE
    FROM (SELECT * FROM TEMP_ONSITE WHERE DPS_NBR IS NOT NULL
    AND ARRIVE_TIMESTAMP IS NOT NULL
    AND COMPL_TIMESTAMP IS NOT NULL
    AND STATUS_CODE IS NOT NULL
    AND STATUS_CODE_DESC IS NOT NULL
    AND PROBLEM_CODE IS NOT NULL
    AND PROBLEM_CODE_DESC IS NOT NULL
    AND CAUSE_CODE IS NOT NULL
    AND CAUSE_CODE_DESC IS NOT NULL
    AND ACTION_CODE IS NOT NULL
    AND ACTION_CODE_DESC IS NOT NULL
    ) OS
    LEFT JOIN JDPS_DBA.JDPS_HEADER JH
    ON OS.DPS_NBR=JH.DPS_NBR
    GROUP BY
    OS.DPS_NBR,
    OS.ARRIVE_TIMESTAMP,
    OS.COMPL_TIMESTAMP,
    OS.STATUS_CODE,
    OS.STATUS_CODE_DESC,
    OS.PROBLEM_CODE,
    OS.PROBLEM_CODE_DESC,
    OS.CAUSE_CODE,
    OS.CAUSE_CODE_DESC,
    OS.ACTION_CODE,
    OS.ACTION_CODE_DESC,
    JH.DPS_NBR,
    JH.DPS_TYPE,
    JH.TPM_CODE
    ) X
    LEFT JOIN GS_CALL_LOG_HEADER CLH
    ON X.DPS_NBR=CLH.DPS_NBR;
    V_TMP_ONSITE C_TMP_ONSITE%ROWTYPE;
    V_TMP_STATUS_FILE C_TMP_STATUS_FILE%ROWTYPE;
    V_TMP_CASE_AUDIT C_TMP_CASE_AUDIT%ROWTYPE;
    V_MER_CASE_HISTORY C_MER_CASE_HISTORY%ROWTYPE;
    V_SVC_STATUS_ID_A SVC_ACTIVITY.SVC_STATUS_ID%TYPE;
    V_SVC_STATUS_ID_C SVC_ACTIVITY.SVC_STATUS_ID%TYPE;
    BEGIN
    SELECT SOURCE_SITE_ID INTO V_SOURCE_SITE_ID FROM SOURCE_SITE;
    DELETE ERR_SVC_ACTIVITY WHERE TO_DATE(ERR_DATE)=TO_DATE(SYSDATE);
    COMMIT;
    IF BITAND(MSK,4)=4 THEN
    UPDATE TABLE_STATUS SET STATUS='WRITING...',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='GS_CASE_HEADER';
    COMMIT;
    V_CUSSOR := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(V_CUSSOR, 'TRUNCATE TABLE GS_CASE_HEADER', DBMS_SQL.V7);
    V_PROCESSED := DBMS_SQL.EXECUTE(V_CUSSOR);
    DBMS_SQL.CLOSE_CURSOR(V_CUSSOR);
    INSERT INTO GS_CASE_HEADER NOLOGGING (
    CASE_NUM,
    SEVERITY_ID,
    USER_ID
    (SELECT
    CH.CASE_NUM,
    CH.SEVERITY_ID,
    CH.USER_ID
    FROM JDPS_DBA.CASE_HEADER CH
    GROUP BY
    CH.CASE_NUM,
    CH.SEVERITY_ID,
    CH.USER_ID
    COMMIT;
    UPDATE TABLE_STATUS SET STATUS='COMPLETED',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='GS_CASE_HEADER';
    COMMIT;
    END IF;
    -- Gather Data. "SVC_ACTIVITY" 1/4
    -- TEMP_ONSITE ---> SVC_ACTIVITY
    IF BITAND(MSK,1)=1 THEN
    UPDATE TABLE_STATUS SET STATUS='WRITING...',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='SVC_ACTIVITY02';
    COMMIT;
    V_CUSSOR := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(V_CUSSOR, 'TRUNCATE TABLE SVC_ACTIVITY02', DBMS_SQL.V7);
    V_PROCESSED := DBMS_SQL.EXECUTE(V_CUSSOR);
    DBMS_SQL.CLOSE_CURSOR(V_CUSSOR);
    SELECT STATUS_ID INTO V_SVC_STATUS_ID_A FROM M_STATUS WHERE STATUS_TYPE_ID_DESC='ONSITE' AND STATUS_CODE='ARRIV';
    SELECT STATUS_ID INTO V_SVC_STATUS_ID_C FROM M_STATUS WHERE STATUS_TYPE_ID_DESC='ONSITE' AND STATUS_CODE='COMPL';
    OPEN C_TMP_ONSITE;
    LOOP
    FETCH C_TMP_ONSITE INTO V_TMP_ONSITE;
    EXIT WHEN C_TMP_ONSITE%NOTFOUND;
    SELECT COUNT(*) INTO V_COUNT FROM MT_ONSITE WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR AND STATUS_DESC='ARRIV' AND TIME_STAMP=V_TMP_ONSITE.ARRIVE_TIMESTAMP;
    IF V_COUNT=0 THEN
    INSERT INTO ERR_SVC_ACTIVITY E (
    E.ACTIVITY_ID,
    E.ACTIVITY_DESC,
    E.ACTIVITY_EFF_DATE,
    E.ACTIVITY_EFF_DTS,
    E.ACTIVITY_END_DATE,
    E.ACTIVITY_END_DTS,
    E.ACTIVITY_REASON_ID,
    E.ACTIVITY_START_DATE,
    E.ACTIVITY_START_DTS,
    E.CASE_ID,
    E.CAUSE_ID,
    E.DELL_PROD_SVC_DESC_ID,
    E.INTERACTION_ID,
    E.SVC_ACTIVITY_SRC_ID,
    E.SVC_EVENT_TYPE_ID,
    E.SVC_INTERACTION_ID,
    E.SVC_PROVIDER_ID,
    E.SVC_RESULT_ID,
    E.SVC_STATUS_ID,
    E.EXTRACT_DATE,
    E.EXTRACT_DTS,
    E.SOURCE_SITE_ID,
    E.LOAD_SEQ_NUM,
    E.ERR_DESC,
    E.ERR_DATE
    VALUES (
    NULL,
    'ARRIV',
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    NULL,
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    NULL,
    NULL,
    NULL,
    NULL,
    V_TMP_ONSITE.SVC_ACTIVITY_SRC_ID,
    NULL,
    NULL,
    NULL,
    NULL,
         NULL,
    SYSDATE,
    SYSTIMESTAMP,
    V_SOURCE_SITE_ID,
    NULL,
    'The MT_ONSITE master doesn''t have the dps number and ARRIV and arrive timestamp.(' || V_TMP_ONSITE.DPS_NBR || ',ARRIV,' || V_TMP_ONSITE.ARRIVE_TIMESTAMP || ')',
    SYSDATE
    UPDATE TABLE_STATUS SET STATUS='UPDATED!!',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='ERR_SVC_ACTIVITY';
    COMMIT;
    ELSE
    INSERT INTO SVC_ACTIVITY02 A (
    A.ACTIVITY_ID,
    A.ACTIVITY_DESC,
    A.ACTIVITY_EFF_DATE,
    A.ACTIVITY_EFF_DTS,
    A.ACTIVITY_END_DATE,
    A.ACTIVITY_END_DTS,
    A.ACTIVITY_REASON_ID,
    A.ACTIVITY_START_DATE,
    A.ACTIVITY_START_DTS,
    A.CASE_ID,
    A.CAUSE_ID,
    A.DELL_PROD_SVC_DESC_ID,
    A.INTERACTION_ID,
    A.SVC_ACTIVITY_SRC_ID,
    A.SVC_EVENT_TYPE_ID,
    A.SVC_INTERACTION_ID,
    A.SVC_PROVIDER_ID,
    A.SVC_RESULT_ID,
    A.SVC_STATUS_ID,
    A.EXTRACT_DATE,
    A.EXTRACT_DTS,
    A.SOURCE_SITE_ID,
    A.LOAD_SEQ_NUM
    VALUES (
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE IX_MT_ONSITE) */ NUMERIC_KEY FROM MT_ONSITE WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR AND STATUS_DESC='ARRIV' AND TIME_STAMP=V_TMP_ONSITE.ARRIVE_TIMESTAMP)),
    'ARRIV',
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_PROBLEM IX_MT_ONSITE_PROBLEM) */ NUMERIC_KEY FROM MT_ONSITE_PROBLEM WHERE PROBLEM_CODE=V_TMP_ONSITE.PROBLEM_CODE)),
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_CASE_HEADER IX_MT_CASE_HEADER) */ NUMERIC_KEY FROM MT_CASE_HEADER WHERE CASE_NUM=V_TMP_ONSITE.CLH_CASE_NUM)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_CAUSE IX_MT_ONSITE_CAUSE) */ NUMERIC_KEY FROM MT_ONSITE_CAUSE WHERE CAUSE_CODE=V_TMP_ONSITE.CAUSE_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT DELL_PROC_SVC_DESC_ID FROM M_PROD_SVC_TYPE WHERE SRC_DESC_DESC_CODE=V_TMP_ONSITE.JH_DPS_TYPE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_CALL_LOG_HEADER IX_MT_CALL_LOG_HEADER) */ NUMERIC_KEY FROM MT_CALL_LOG_HEADER WHERE DATE_CODE=V_TMP_ONSITE.CLH_DATE_CODE AND CASE_NUM=V_TMP_ONSITE.CLH_CASE_NUM AND FLG_DELLSRV=V_TMP_ONSITE.CLH_FLG_DELLSRV)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || V_TMP_ONSITE.SVC_ACTIVITY_SRC_ID),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_ACTION IX_MT_ONSITE_ACTION) */ NUMERIC_KEY FROM MT_ONSITE_ACTION WHERE ACTION_CODE=V_TMP_ONSITE.ACTION_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDDEX(MT_JDPS_HEADER IX_JDPS_HEADER) */ NUMERIC_KEY FROM MT_JDPS_HEADER WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_TPM_CODE IX_MT_TPM_CODE) */ NUMERIC_KEY FROM MT_TPM_CODE WHERE TPM_CODE=V_TMP_ONSITE.JH_TPM_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_STATUS IX_MT_ONSITE_STATUS) */ NUMERIC_KEY FROM MT_ONSITE_STATUS WHERE STATUS_CODE=V_TMP_ONSITE.STATUS_CODE)),
    V_SVC_STATUS_ID_A,
    SYSDATE,
    SYSTIMESTAMP,
    V_SOURCE_SITE_ID,
    NULL
    END IF;
    SELECT COUNT(*) INTO V_COUNT FROM MT_ONSITE WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR AND STATUS_DESC='COMPL' AND TIME_STAMP=V_TMP_ONSITE.COMPL_TIMESTAMP;
    IF V_COUNT=0 THEN
    INSERT INTO ERR_SVC_ACTIVITY E (
    E.ACTIVITY_ID,
    -- E.SOURCE_SYS_CREATE_DTS,
    E.ACTIVITY_DESC,
    -- E.ACTIVITY_DURACTION,
    E.ACTIVITY_EFF_DATE,
    E.ACTIVITY_EFF_DTS,
    E.ACTIVITY_END_DATE,
    E.ACTIVITY_END_DTS,
    -- E.ACTIVITY_NOTIFICATION_DATE,
    -- E.ACTIVITY_NOTIFICATION_DTS,
    E.ACTIVITY_REASON_ID,
    E.ACTIVITY_START_DATE,
    E.ACTIVITY_START_DTS,
    -- E.ALT_CONTACT_PHONE,
    E.CASE_ID,
    E.CAUSE_ID,
    -- E.CUSTOMER_GMT_OFFSET,
    E.DELL_PROD_SVC_DESC_ID,
    E.INTERACTION_ID,
    -- E.SECONDARY_CONTACT_NAME,
    -- E.SECONDARY_CONTACT_PHONE,
    -- E.SRC_ACTIVITY_CODE,
    E.SVC_ACTIVITY_SRC_ID,
    E.SVC_EVENT_TYPE_ID,
    E.SVC_INTERACTION_ID,
    -- E.SVC_ORG_GROUP_ID,
    E.SVC_PROVIDER_ID,
    -- E.SVC_QUEUE_ID,
    E.SVC_RESULT_ID,
    -- E.SVC_SEVERITY_ID,
    E.SVC_STATUS_ID,
    -- E.SVC_URGENCY_ID,
    E.EXTRACT_DATE,
    E.EXTRACT_DTS,
    E.SOURCE_SITE_ID,
    -- E.SOURCE_SYS_CREATE_BY,
    -- E.SOURCE_SYS_CREATE_DATE,
    -- E.SOURCE_SYS_UPDATE_BY,
    -- E.SOURCE_SYS_UPDATE_DATE,
    -- E.SOURCE_SYS_UPDATE_DTS,
    E.LOAD_SEQ_NUM,
    E.ERR_DESC,
    E.ERR_DATE
    VALUES (
    NULL, --V_TMP_ONSITE.DPS_NBR || 'COMPL' || V_TMP_ONSITE.COMPL_TIMESTAMP,
    'COMPL',
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    NULL, --V_TMP_ONSITE.PROBLEM_CODE,
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    NULL, --V_TMP_ONSITE.CLH_CASE_NUM,
    NULL, --V_TMP_ONSITE.CAUSE_CODE,
    NULL, --V_TMP_ONSITE.JH_DPS_TYPE,
    NULL, --V_TMP_ONSITE.CLH_DATE_CODE || V_TMP_ONSITE.CLH_CASE_NUM || V_TMP_ONSITE.CLH_FLG_DELLSRV,
    V_TMP_ONSITE.SVC_ACTIVITY_SRC_ID,
    NULL, --V_TMP_ONSITE.ACTION_CODE,
    NULL, --V_TMP_ONSITE.DPS_NBR,
    NULL, --V_TMP_ONSITE.JH_TPM_CODE,
    NULL, --V_TMP_ONSITE.STATUS_CODE,
    NULL, --V_SVC_STATUS_ID_C,
    SYSDATE,
    SYSTIMESTAMP,
    V_SOURCE_SITE_ID,
    NULL,
    'The MT_ONSITE master doesn''t have the dps number and COMPL and compl timestamp.(' || V_TMP_ONSITE.DPS_NBR || ',COMPL,' || V_TMP_ONSITE.COMPL_TIMESTAMP || ')',
    SYSDATE
    UPDATE TABLE_STATUS SET STATUS='UPDATED!!',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='ERR_SVC_ACTIVITY';
    COMMIT;
    ELSE
    INSERT INTO SVC_ACTIVITY02 A (
    A.ACTIVITY_ID,
    -- A.SOURCE_SYS_CREATE_DTS,
    A.ACTIVITY_DESC,
    -- A.ACTIVITY_DURACTION,
    A.ACTIVITY_EFF_DATE,
    A.ACTIVITY_EFF_DTS,
    A.ACTIVITY_END_DATE,
    A.ACTIVITY_END_DTS,
    -- A.ACTIVITY_NOTIFICATION_DATE,
    -- A.ACTIVITY_NOTIFICATION_DTS,
    A.ACTIVITY_REASON_ID,
    A.ACTIVITY_START_DATE,
    A.ACTIVITY_START_DTS,
    -- A.ALT_CONTACT_PHONE,
    A.CASE_ID,
    A.CAUSE_ID,
    -- A.CUSTOMER_GMT_OFFSET,
    A.DELL_PROD_SVC_DESC_ID,
    A.INTERACTION_ID,
    -- A.SECONDARY_CONTACT_NAME,
    -- A.SECONDARY_CONTACT_PHONE,
    -- A.SRC_ACTIVITY_CODE,
    A.SVC_ACTIVITY_SRC_ID,
    A.SVC_EVENT_TYPE_ID,
    A.SVC_INTERACTION_ID,
    -- A.SVC_ORG_GROUP_ID,
    A.SVC_PROVIDER_ID,
    -- A.SVC_QUEUE_ID,
    A.SVC_RESULT_ID,
    -- A.SVC_SEVERITY_ID,
    A.SVC_STATUS_ID,
    -- A.SVC_URGENCY_ID,
    A.EXTRACT_DATE,
    A.EXTRACT_DTS,
    A.SOURCE_SITE_ID,
    -- A.SOURCE_SYS_CREATE_BY,
    -- A.SOURCE_SYS_CREATE_DATE,
    -- A.SOURCE_SYS_UPDATE_BY,
    -- A.SOURCE_SYS_UPDATE_DATE,
    -- A.SOURCE_SYS_UPDATE_DTS,
    A.LOAD_SEQ_NUM
    VALUES (
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE IX_MT_ONSITE) */ NUMERIC_KEY FROM MT_ONSITE WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR AND STATUS_DESC='COMPL' AND TIME_STAMP=V_TMP_ONSITE.COMPL_TIMESTAMP)),
    'COMPL',
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    V_TMP_ONSITE.COMPL_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.COMPL_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_PROBLEM IX_MT_ONSITE_PROBLEM) */ NUMERIC_KEY FROM MT_ONSITE_PROBLEM WHERE PROBLEM_CODE=V_TMP_ONSITE.PROBLEM_CODE)),
    V_TMP_ONSITE.ARRIVE_TIMESTAMP,
    TO_TIMESTAMP(TO_CHAR(V_TMP_ONSITE.ARRIVE_TIMESTAMP,'yyyy-mm-dd hh24:mi:ss')),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_CASE_HEADER IX_MT_CASE_HEADER) */ NUMERIC_KEY FROM MT_CASE_HEADER WHERE CASE_NUM=V_TMP_ONSITE.CLH_CASE_NUM)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_CAUSE IX_MT_ONSITE_CAUSE) */ NUMERIC_KEY FROM MT_ONSITE_CAUSE WHERE CAUSE_CODE=V_TMP_ONSITE.CAUSE_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT DELL_PROC_SVC_DESC_ID FROM M_PROD_SVC_TYPE WHERE SRC_DESC_DESC_CODE=V_TMP_ONSITE.JH_DPS_TYPE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_CALL_LOG_HEADER IX_MT_CALL_LOG_HEADER) */ NUMERIC_KEY FROM MT_CALL_LOG_HEADER WHERE DATE_CODE=V_TMP_ONSITE.CLH_DATE_CODE AND CASE_NUM=V_TMP_ONSITE.CLH_CASE_NUM AND FLG_DELLSRV=V_TMP_ONSITE.CLH_FLG_DELLSRV)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || V_TMP_ONSITE.SVC_ACTIVITY_SRC_ID),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_ACTION IX_MT_ONSITE_ACTION) */ NUMERIC_KEY FROM MT_ONSITE_ACTION WHERE ACTION_CODE=V_TMP_ONSITE.ACTION_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDDEX(MT_JDPS_HEADER IX_JDPS_HEADER) */ NUMERIC_KEY FROM MT_JDPS_HEADER WHERE DPS_NBR=V_TMP_ONSITE.DPS_NBR)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_TPM_CODE IX_MT_TPM_CODE) */ NUMERIC_KEY FROM MT_TPM_CODE WHERE TPM_CODE=V_TMP_ONSITE.JH_TPM_CODE)),
    TO_NUMBER(V_SOURCE_SITE_ID_N || (SELECT /*+ INDEX(MT_ONSITE_STATUS IX_MT_ONSITE_STATUS) */ NUMERIC_KEY FROM MT_ONSITE_STATUS WHERE STATUS_CODE=V_TMP_ONSITE.STATUS_CODE)),
    V_SVC_STATUS_ID_C,
    SYSDATE,
    SYSTIMESTAMP,
    V_SOURCE_SITE_ID,
    NULL
    END IF;
    V_LIMIT := V_LIMIT + 1;
    IF V_LIMIT > 10000 THEN
    COMMIT;
    V_LIMIT :=0;
    END IF;
    END LOOP;
    -- カーソルのクローズ
    CLOSE C_TMP_ONSITE;
    COMMIT;
    V_LIMIT :=0;
    UPDATE TABLE_STATUS SET STATUS='COMPLETED',UPDATE_DATE=SYSDATE WHERE TABLE_NAME='SVC_ACTIVITY02';
    COMMIT;
    END IF;

    The procedure takes two optional parameters, a date, which defaults to sysdate if not passed, and an integer which defaults to 31 if not passed.
    The BITAND function does a bitwise and on msk and the constants. A bitwise and works like this. It takes the binary representation of the two numbers and compares each bit. If both are the same, then it sets the corresponding bit in the output to 1, if they are different, then the corresponding bit is 0. So
    31 binary is: 11111
    2 binary is 10
    So to do a bitand, you pad the shorter number on the left with zeroes and compare each bit so:
    11111
    00010
    00010so BITAND(31, 2) = 2
    I'm not really sure how your application is determining the value for msk to pass to the procedure, and don't have the time to decipher the posted code to see how it is really using it, but one common use for bit masks is to store several yes/no or on/off flags in a very compact form.
    For example, one application I worked with several years ago had a security model that determined for each user for each screen what they could do with that screen. The permissions were stored in a single number similar to the file permissions in UNIX. So, reading from the right:
    Bit 1 Set = Read permission
    Bit 2 Set = Insert permission
    Bit 3 set = Update Permission
    Bit 4 set = Delete permissionSo, a user who could read and update but not insert or delete would have bits set as 0101 or 5. To determine if the user could insert a record, the application would do something like:
    IF BITAND(permission_no, 2) = 1 THEN
       allow update
    ELSE
       deny update
    END IF;HTH
    John

  • Plsql query please help out

    Hi ,
    I have table with columns
    item,product,class1,class2,item_path,category
    How can I query the table to find out
    same item_path with differnt categories.I want to update those rows.
    Thanks.

    If you're just trying to identify the paths with more than one category then something like...
    select item_path, count(category) cnt
    from mytable
    group by item_path
    having count(category) > 1may do it.

  • Please help-PLSQL complex procedure writing

    Hi all,
    I am back again and requesting your help on this.I want your help to properly write the below code because now i feel-that its very confusing and not easily readable and following the program is tough.
    I want to replace the same looping done below in many places using a function/or any other approaches.Then,need all your important suggestions in any other ways,approach...i can do the same which would be good for performance and best practices here.
    Please help me as i am very stuck with this and struggling so much.
    For any suggested things-please help me with the new code which will be very helping
    CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" (
       p_strtplanid    test_training_plan.tplan_id%TYPE,
       p_strpersonid   test_person.person_id%TYPE,
       p_strorg_id     test_org.org_id%TYPE
    IS
      /*Here declarartion of variables */
    BEGIN
       /*Since TP is presently in LR,verify if its completed or not*/
       SELECT COUNT (learning_record_id)
         INTO v_inttpcompltd
         FROM test_learning_record lr
        WHERE lr.catalog_item_type = 'training-plan'
          AND lr.status IN ('PASSED', 'WAIVED', 'TESTED_OUT')
          AND lr.lr_catalog_history_id = p_strtplanid
          AND lr.lr_person_id = p_strpersonid
          AND lr.lr_org_id = p_strorg_id;
       /*Credit based */
       SELECT is_credit_based
         INTO v_intcreditbased
         FROM test_training_plan
        WHERE tplan_id = p_strtplanid;
       IF (v_inttpcompltd > 0)
       THEN
          IF (v_intcreditbased = 1)
          THEN
             DBMS_OUTPUT.put_line ('Starting Credit based ');
             v_inttotreqactcompltd :=
                fn_tp_get_cmpltd_act_cnt (p_strtplanid,
                                          p_strpersonid,
                                          p_strorg_id
             SELECT NVL (EXTRACT (tplan_xml_data, '//numberOfCredits/text()').getstringval
                         0
                    NVL (EXTRACT (tplan_xml_data, '//accreditingOrg/text()').getstringval
                         0
               INTO v_intrequiredcredits,
                    v_straccreditingorg
               FROM test_training_plan
              WHERE tplan_id = p_strtplanid;
             SELECT accred_org_id
               INTO v_straccreditingorg
               FROM test_tp_acc_org
              WHERE tplan_id = p_strtplanid;
             IF (v_intrequiredcredits > v_inttotreqactcompltd)
             THEN
                DBMS_OUTPUT.put_line ('test_tp_acc_org ');
                FOR obj IN (SELECT t_objective_id,
                                   NVL (required_credits, 0) required_credits
                              FROM test_tp_objective
                             WHERE tplan_id = p_strtplanid)
                LOOP
                   DBMS_OUTPUT.put_line
                      (   ' Looping each Objective******************************'
                       || obj.t_objective_id
                   SELECT NVL (SUM (lcdt.credit_hours), 0)
                     INTO v_inttotreqacttobecompltd
                     FROM test_train_obj_activity toa,
                          test_tp_objective tpobj,
                          test_learningactivity_credits lcdt,
                          test_tp_acc_org acc_org
                    WHERE lcdt.learning_activity_id = toa.activity_id
                      AND lcdt.acc_org_id = v_straccreditingorg
                      AND toa.t_objective_id = tpobj.t_objective_id
                      AND tpobj.tplan_id = acc_org.tplan_id
                      AND toa.t_objective_id = obj.t_objective_id
                      AND tpobj.tplan_id = p_strtplanid
                      AND tpobj.t_objective_id = obj.t_objective_id
                      AND toa.is_required = 1;
                   DBMS_OUTPUT.put_line
                                   (   'Total credits for required activities****'
                                    || v_inttotreqacttobecompltd
                   --get credits for non event activities
                   SELECT NVL (SUM (credit_hours), 0)
                     INTO v_intnoneventbasedactcredit
                     FROM test_tp_objective tobj,
                          test_train_obj_activity toa,
                          test_learningactivity_credits lac,
                          test_learning_record lr,
                          test_tp_learning_activity tplplr,
                          test_learning_record tplr
                    WHERE tobj.t_objective_id = obj.t_objective_id
                      AND toa.t_objective_id = tobj.t_objective_id
                      AND toa.activity_id = lac.learning_activity_id
                      AND toa.activity_id = lr.lr_catalog_history_id
                      AND toa.is_required = 1
                      AND lr.learning_record_id = tplplr.activity_lp_lr_id
                      AND tplplr.tp_lp_lr_id = tplr.learning_record_id
                      AND tobj.tplan_id = p_strtplanid
                      AND tplr.lr_catalog_history_id = p_strtplanid
                      AND acc_org_id = v_straccreditingorg
                      AND lr.lr_person_id = p_strpersonid
                      AND tplr.lr_person_id = p_strpersonid
                      AND lr.status IN ('PASSED', 'WAIVED', 'TESTED_OUT');
                   --Get credits for events
                   SELECT NVL (SUM (credit_hours), 0)
                     INTO v_inteventbasedactcredit
                     FROM test_learningactivity_credits lac
                    WHERE lac.learning_activity_id IN (
                             SELECT event_id
                               FROM test_tp_objective tobj,
                                    test_train_obj_activity toa,
                                    test_learning_record lr,
                                    test_event_sessions sessions,
                                    test_tp_learning_activity tplplr,
                                    test_learning_record tplr
                              WHERE tobj.t_objective_id = obj.t_objective_id
                                AND tobj.t_objective_id = toa.t_objective_id
                                AND toa.activity_id = sessions.event_id
                                AND toa.is_required = 1
                                AND sessions.event_session_id =
                                                          lr.lr_catalog_history_id
                                AND lr.learning_record_id =
                                                          tplplr.activity_lp_lr_id
                                AND tplplr.tp_lp_lr_id = tplr.learning_record_id
                                AND tplr.lr_catalog_history_id = p_strtplanid
                                AND tobj.tplan_id = p_strtplanid
                                AND tplr.lr_person_id = p_strpersonid
                                AND lr.lr_person_id = p_strpersonid
                                AND lr.status IN
                                               ('PASSED', 'WAIVED', 'TESTED_OUT'))
                      AND acc_org_id = v_straccreditingorg;
                   v_inttotreqactcompltd :=
                            v_intnoneventbasedactcredit + v_inteventbasedactcredit;
                   DBMS_OUTPUT.put_line
                                (   ' Total credits of reqd. completed activities'
                                 || v_inttotreqactcompltd
                   IF (v_inttotreqacttobecompltd <= v_inttotreqactcompltd)
                   THEN
                      DBMS_OUTPUT.put_line
                         (   '****** START INSIDE OBJ-COUNT COMPLETED************** '
                          || obj.required_credits
                      v_strreturnval :=
                         fn_tp_obj_comp_act_cdt (p_strpersonid,
                                                 p_strtplanid,
                                                 obj.t_objective_id,
                                                 v_intcreditbased
                      DBMS_OUTPUT.put_line (   'FN_TP_GET_CMPLTD_ACT_CNT'
                                            || v_strreturnval
                      IF (obj.required_credits > v_strreturnval)
                      THEN
                         DBMS_OUTPUT.put_line
                                   || obj.required_credits
    *I want to write a function/or any other approaches to do the below looping and SELECT functionality and also read the return certain values selected.*
    *Most importantly- this query being run in several places throughout the whole main program and everytime I have to put this SQL there and*
    *which has increased the code by huge amount.*
    **Another thing is-I want to remove the NOT IN below and use a different approach.
                         /*Start processing of new activity */
                         FOR activity IN
                            (SELECT objact.activity_id, objact.activity_type,
                                    objact.is_required
                               FROM test_training_plan tp,
                                    test_tp_objective tp_obj,
                                    test_train_obj_activity objact
                              WHERE tp.tplan_id = tp_obj.tplan_id
                                AND tp.tplan_id = p_strtplanid
                                AND tp_obj.t_objective_id = obj.t_objective_id
                                AND tp_obj.t_objective_id = objact.t_objective_id
                                AND objact.activity_id NOT IN (
                                       SELECT tplplr.activity_id
                                         FROM test_learning_record lr,
                                              test_learning_record lr1,
                                              test_tp_learning_activity tplplr
                                        WHERE lr.lr_catalog_history_id =
                                                                tplplr.activity_id
                                          AND lr.learning_record_id =
                                                          tplplr.activity_lp_lr_id
                                          AND tplplr.tp_lp_lr_id =
                                                            lr1.learning_record_id
                                          AND lr1.lr_catalog_history_id =
                                                                      p_strtplanid
                                          AND lr.lr_person_id = p_strpersonid
                                          AND lr1.lr_person_id = p_strpersonid
                                          AND lr.status IN
                                                 ('PASSED', 'WAIVED',
                                                  'TESTED_OUT'))
                                AND objact.activity_id NOT IN (
                                       SELECT event_id
                                         FROM test_train_obj_activity toa,
                                              test_event_sessions sessions,
                                              test_learning_record lr1,
                                              test_tp_learning_activity tplearnact,
                                              test_learning_record tplr
                                        WHERE toa.activity_id = sessions.event_id
                                          AND sessions.event_session_id =
                                                         lr1.lr_catalog_history_id
                                          AND lr1.learning_record_id =
                                                      tplearnact.activity_lp_lr_id
                                          AND tplearnact.tp_lp_lr_id =
                                                           tplr.learning_record_id
                                          AND tplr.lr_catalog_history_id =
                                                                      p_strtplanid
                                          ---AND toa.is_required = 1
                                          AND toa.t_objective_id =
                                                                obj.t_objective_id
                                          AND tplr.lr_person_id = p_strpersonid
                                          AND lr1.lr_person_id = p_strpersonid
                                          AND lr1.status IN
                                                 ('PASSED', 'WAIVED',
                                                  'TESTED_OUT')))
                         LOOP
                            /*The function should return data so that i can validate them as the below ones*/
                            IF (activity.activity_type = 'Course')
                            THEN
                               sp_test_assign_coursetp (p_strpersonid,
                                                   activity.activity_id,
                                                   p_strpersonid,
                                                   activity.activity_type,
                                                   activity.is_required,
                                                   p_strtplanid,
                                                   v_straccreditingorg,
                                                   obj.t_objective_id,
                                                   v_strlpid
                            ELSIF (activity.activity_type = 'Test')
                            THEN
                               sp_assign_testtp (p_strpersonid,
                                                 activity.activity_id,
                                                 p_strpersonid,
                                                 activity.activity_type,
                                                 activity.is_required,
                                                 p_strtplanid,
                                                 v_straccreditingorg,
                                                 obj.t_objective_id
                            END IF;
                         END LOOP;
                         DBMS_OUTPUT.put_line ('Case of Optional Activity');
                      ELSE
                         /*Start processing of new activity */
                         FOR activity IN
                            (SELECT objact.activity_id, objact.activity_type,
                                    objact.is_required
                               FROM test_training_plan tp,
                                    test_tp_objective tp_obj,
                                    test_train_obj_activity objact
                              WHERE tp.tplan_id = tp_obj.tplan_id
                                AND tp.tplan_id = p_strtplanid
                                AND tp_obj.t_objective_id = obj.t_objective_id
                                AND objact.is_required = 1
                                AND tp_obj.t_objective_id = objact.t_objective_id
                                AND objact.activity_id NOT IN (
                                       SELECT tplplr.activity_id
                                         FROM test_learning_record lr,
                                              test_learning_record lr1,
                                              test_tp_learning_activity tplplr
                                        WHERE lr.lr_catalog_history_id =
                                                                tplplr.activity_id
                                          AND lr.learning_record_id =
                                                          tplplr.activity_lp_lr_id
                                          AND tplplr.tp_lp_lr_id =
                                                            lr1.learning_record_id
                                          AND lr1.lr_catalog_history_id =
                                                                      p_strtplanid
                                          AND lr.lr_person_id = p_strpersonid
                                          AND lr1.lr_person_id = p_strpersonid
                                          AND lr.status IN
                                                 ('PASSED', 'WAIVED',
                                                  'TESTED_OUT'))
                                AND objact.activity_id NOT IN (
                                       SELECT event_id
                                         FROM test_train_obj_activity toa,
                                              test_event_sessions sessions,
                                              test_learning_record lr1,
                                              test_tp_learning_activity tplearnact,
                                              test_learning_record tplr
                                        WHERE toa.activity_id = sessions.event_id
                                          AND sessions.event_session_id =
                                                         lr1.lr_catalog_history_id
                                          AND lr1.learning_record_id =
                                                      tplearnact.activity_lp_lr_id
                                          AND tplearnact.tp_lp_lr_id =
                                                           tplr.learning_record_id
                                          AND tplr.lr_catalog_history_id =
                                                                      p_strtplanid
                                          AND toa.is_required = 1
                                          AND toa.t_objective_id =
                                                                obj.t_objective_id
                                          AND tplr.lr_person_id = p_strpersonid
                                          AND lr1.lr_person_id = p_strpersonid
                                          AND lr1.status IN
                                                 ('PASSED', 'WAIVED',
                                                  'TESTED_OUT'))
                         LOOP
                            /*Move the TP only for required ids */
                            IF (activity.activity_type = 'Course')
                            THEN
                               SP_TEST_ASSIGN_COURSETP (p_strpersonid,
                                                   activity.activity_id,
                                                   p_strpersonid,
                                                   activity.activity_type,
                                                   activity.is_required,
                                                   p_strtplanid,
                                                   v_straccreditingorg,
                                                   obj.t_objective_id,
                                                   v_strlpid
                            ELSIF (activity.activity_type = 'Test')
                            THEN
                               sp_assign_testtp (p_strpersonid,
                                                 activity.activity_id,
                                                 p_strpersonid,
                                                 activity.activity_type,
                                                 activity.is_required,
                                                 p_strtplanid,
                                                 v_straccreditingorg,
                                                 obj.t_objective_id
                            END IF;
                         END LOOP;
                      END IF;
                   ELSE
                      DBMS_OUTPUT.put_line
                         ('*********/*No of required credits is more then completed
                                ******Start processing of new activity */'
                      /*Start processing of new activity */
                      FOR activity IN
                         (SELECT objact.activity_id, objact.activity_type,
                                 objact.is_required
                            FROM test_training_plan tp,
                                 test_tp_objective tp_obj,
                                 test_train_obj_activity objact
                           WHERE tp.tplan_id = tp_obj.tplan_id
                             AND tp.tplan_id = p_strtplanid
                             AND tp_obj.t_objective_id = obj.t_objective_id
                             AND objact.is_required = 1
                             AND objact.t_objective_id = tp_obj.t_objective_id
                             AND objact.activity_id NOT IN (
                                    SELECT tplplr.activity_id
                                      FROM test_learning_record lr,
                                           test_learning_record lr1,
                                           test_tp_learning_activity tplplr
                                     WHERE lr.lr_catalog_history_id =
                                                                tplplr.activity_id
                                       AND lr.learning_record_id =
                                                          tplplr.activity_lp_lr_id
                                       AND tplplr.tp_lp_lr_id =
                                                            lr1.learning_record_id
                                       AND lr1.lr_catalog_history_id =
                                                                      p_strtplanid
                                       AND lr.lr_person_id = p_strpersonid
                                       AND lr1.lr_person_id = p_strpersonid
                                       AND lr.status IN
                                               ('PASSED', 'WAIVED', 'TESTED_OUT'))
                             AND objact.activity_id NOT IN (
                                    SELECT event_id
                                      FROM test_train_obj_activity toa,
                                           test_event_sessions sessions,
                                           test_learning_record lr1,
                                           test_tp_learning_activity tplearnact,
                                           test_learning_record tplr
                                     WHERE toa.activity_id = sessions.event_id
                                       AND sessions.event_session_id =
                                                         lr1.lr_catalog_history_id
                                       AND lr1.learning_record_id =
                                                      tplearnact.activity_lp_lr_id
                                       AND tplearnact.tp_lp_lr_id =
                                                           tplr.learning_record_id
                                       AND tplr.lr_catalog_history_id =
                                                                      p_strtplanid
                                       AND toa.is_required = 1
                                       AND toa.t_objective_id = obj.t_objective_id
                                       AND tplr.lr_person_id = p_strpersonid
                                       AND lr1.lr_person_id = p_strpersonid
                                       AND lr1.status IN
                                               ('PASSED', 'WAIVED', 'TESTED_OUT')))
                      LOOP
                         /*Move the TP only for required ids */
                         IF (activity.activity_type = 'Course')
                         THEN
                            sp_assign_coursetp (p_strpersonid,
                                                activity.activity_id,
                                                p_strpersonid,
                                                activity.activity_type,
                                                activity.is_required,
                                                p_strtplanid,
                                                v_straccreditingorg,
                                                obj.t_objective_id,
                                                v_strlpid
                         ELSIF (activity.activity_type = 'Test')
                         THEN
                            sp_assign_testtp (p_strpersonid,
                                              activity.activity_id,
                                              p_strpersonid,
                                              activity.activity_type,
                                              activity.is_required,
                                              p_strtplanid,
                                              v_straccreditingorg,
                                              obj.t_objective_id
                         END IF;
                      END LOOP;
                   END IF;
                   FOR lr_lp_act IN (SELECT tplplr.activity_id,
                                            tplplr.tp_lp_lr_id
                                       FROM test_tp_objective tp_obj,
                                            test_train_obj_activity toa,
                                            test_learning_record lr,
                                            test_tp_learning_activity tplplr,
                                            test_learning_record tplr
                                      WHERE tplplr.activity_lp_lr_id =
                                                             lr.learning_record_id
                                        AND lr.lr_catalog_history_id =
                                                                   toa.activity_id
                                        AND tplplr.tp_lp_lr_id =
                                                           tplr.learning_record_id
                                        AND tp_obj.t_objective_id =
                                                                toa.t_objective_id
                                        AND tp_obj.tplan_id = p_strtplanid
                                        AND tplplr.lp_lr_flag = 'LR'
                                        AND tp_obj.t_objective_id =
                                                                obj.t_objective_id
                                        AND lr.status IN
                                               ('PASSED', 'WAIVED', 'TESTED_OUT')
                                        AND lr.lr_person_id = p_strpersonid
                                        AND tplr.lr_person_id = p_strpersonid)
                   LOOP
                      DBMS_OUTPUT.put_line
                          (   'Get data for the activity to update TPs LP id****'
                           || v_strlpid
                      DBMS_OUTPUT.put_line
                         (   'Values which I am updating----lr_lp_act.activity_id---'
                          || obj.t_objective_id
                      DBMS_OUTPUT.put_line
                         (   'Values which I am updating----lr_lp_act.activity_id---'
                          || lr_lp_act.activity_id
                      DBMS_OUTPUT.put_line
                         (   'Values which I am updating----lr_lp_act.tp_lp_lr_id---'
                          || lr_lp_act.tp_lp_lr_id
                      UPDATE test_tp_learning_activity
                         SET tp_lp_lr_id = v_strlpid
                       WHERE activity_id = lr_lp_act.activity_id
                         AND tp_lp_lr_id = lr_lp_act.tp_lp_lr_id;
                      UPDATE test_learning_record
                         SET is_for_training_plan = 'NO'
                       WHERE learning_record_id IN (
                                         SELECT activity_lp_lr_id
                                           FROM test_tp_learning_activity
                                          WHERE tp_lp_lr_id =
                                                             lr_lp_act.tp_lp_lr_id);
                   END LOOP;
                END LOOP;
                DELETE FROM test_learning_record_details
                      WHERE learning_record_id =
                               (SELECT learning_record_id
                                  FROM test_learning_record
                                 WHERE lr_catalog_history_id = p_strtplanid
                                   AND lr_person_id = p_strpersonid
                                   AND status = 'PASSED');
                DBMS_OUTPUT.put_line
                   ('UPDATE
                                        test_learning_record_details'
                DELETE FROM test_learning_record
                      WHERE learning_record_id =
                               (SELECT learning_record_id
                                  FROM test_learning_record
                                 WHERE lr_catalog_history_id = p_strtplanid
                                   AND lr_person_id = p_strpersonid
                                   AND status = 'PASSED');
             END IF;

    Hello, as I mentioned on the other thread, views are the way to go here, not functions (they can be expensive from a performance perspective).
    Therefore, for each group of repeated SELECTs, can you create a view based on that SELECT, and then substitute the view for the SELECTs in this code, and repost it (you know the code best) -- it will be easier then to rationalise it, and it would seem very likely that the LOOPs could be minimised if not eliminated altogether.
    Edit
    For example, you could try something like:
    CREATE OR REPLACE VIEW TEST_EVENT_V
    AS
      SELECT event_id
                                         FROM test_train_obj_activity toa,
                                              test_event_sessions sessions,
                                              test_learning_record lr1,
                                              test_tp_learning_activity tplearnact,
                                              test_learning_record tplr
                                        WHERE toa.activity_id = sessions.event_id
                                          AND sessions.event_session_id =
                                                         lr1.lr_catalog_history_id
                                          AND lr1.learning_record_id =
                                                      tplearnact.activity_lp_lr_id
                                          AND tplearnact.tp_lp_lr_id =
                                                           tplr.learning_record_id
                                          AND tplr.lr_catalog_history_id =
                                                                      p_strtplanid
                                          ---AND toa.is_required = 1
                                          AND toa.t_objective_id =
                                                                obj.t_objective_id
                                          AND tplr.lr_person_id = p_strpersonid
                                          AND lr1.lr_person_id = p_strpersonid
                                          AND lr1.status IN
                                                 ('PASSED', 'WAIVED',
                                                  'TESTED_OUT'))And then replace all the NOT INs associate with that SQL with:
    AND objact.activity_id NOT IN (
    SELECT event_id
       FROM TEST_EVENT_V)

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Oracle8i and Oas 4081 - PLSQL TOOLKIT - Urgent Please help.

    Hi ,
    I installed Oracle 8i and Oas4081 on different ORACLE_HOME on the Linux 6.1 . When I tried to install the PLSQL toolkit it giving me an Oracle Database error 63744.
    But I am enabled the sql_trace and I found OAS is successfully connecting to Oralce8i database, but it failing for some reason.
    Do we need to do anything special on Oracle 8i side to install the PLSQL toolkit ..??
    .Please help ...
    Thanks in advance ..
    kkumar

    Is this what you're looking for?
    Usage Notes
    If the input data or key given to the DES3DECRYPT procedure is empty, then the procedure raises the error ORA-28231 "Invalid input to Obfuscation toolkit."
    If the input data given to the DES3DECRYPT procedure is not a multiple of 8 bytes, the procedure raises the error ORA-28232 "Invalid input size for Obfuscation toolkit." ORA-28233 is NOT applicable for the DES3DECRYPT function.
    If the key length is missing or is less than 8 bytes, then the procedure raises the error ORA-28234 "Key length too short." Note that if larger keys are used, extra bytes are ignored. So a 9-byte key will not generate an exception.
    C.

  • HT2534 when i create the apple ID with the above procedure, i dont see "none" options under credit card selection, please help.

    When i create the apple ID with the above procedure, i dont see "none" options under credit card selection, please help.

    Apple needs people like you.

  • Can you please help me in creating a stored procedure which can create a tablesapce in a specified location ?

    Hello ...
    Can you please help me in writing a procedure which can create tablespace. like i have a requirement that
    through sql query i need to get the location of where the data file of the newly created tablespace need to be stored.
    I need to store the location of the datafiles in a variable and i need to use that variable for specifying the location of the data file in newly created data file.
    please help me writing this procedure.....
    Regards vinay raj.
    Thanks in advance..

    select distinct substr(file_name,1,instr(file_name,'/',-1)) from dba_data_files;
    Run this in a few of your databases and see how often you ONLY get one row returned.
    Normally there is no "default" file system for data files (read about the DB_CREATE_FILE_DEST parameter and Oracle Managed Files for the exception to that).
    You could pick the same file system as an existing tablespace, but even then there is no guarantee that the file system has sufficient space for the new tablespace - you have to check that OUTSIDE the database.
    Given the query at the top it is pretty simple to create a SQL script that generates a SQL script.  This can be run in any database via sqlplus, and then the generated script can be edited as needed and run immediately, under human control, avoiding surprises.
    set echo off
    set feedback off
    set heading off
    set lines 100
    spool myts.sql
    select distinct 'create tablespace MYTS DATAFILE '''||substr(file_name,1,instr(file_name,'/',-1))||'myts01.dbf'' size 40M ONLINE;' stmt
    from dba_data_files;
    spool off
    For example, if you find there are multiple filesystems to choose from, run this then delete the filesystems you don't want from the generated script.  If you find there is only one file system but it is too full, work with your SA or storage to to add space or allocate a new file system, then modify the generated script accordingly.
    This example assumes a traditional file system, on a UNIX-style OS, not using Oracle-Managed files.  ASM or RAW will have a different format for the data file location, of course.

  • While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
    Hope this helps.

  • The procedure is not running no compilatin error please help

    Dear Sir,
    I have this procedure, when I am trying to execute it, it shows me busy cursor nothing happens i was trying for 6 hours nothing happening.
    I am not able to trace out what is happening
    please help
    regards
    sanat
    CREATE OR REPLACE procedure rate_Calc is
    --declare
    sdate date := to_date('01-04-2004','dd-mm-yyyy');
    edate date := sysdate;
    p_amt number;
    d_amt number;
    i_qty number;
    r_qty number;
    d_qty number;
    d_rate number;
    aa number;
    begin
    delete from avg_rate;
    commit;
    insert into avg_rate(select to_date('31-03-2004','dd-mm-yyyy'), item_mast.item_code, item_mast.curr_rate from item_mast);
    for rec1 in (select item_code from item_mast
    ) loop
    sdate := to_date('01-04-2004','dd-mm-yyyy');
    while (sdate < edate ) loop
    begin
    select nvl(sum(qty_accepted),0) into r_qty from rece_mast a, rece_det b where a.tran_no = b.tran_no and
    a.tran_date < sdate and item_code = rec1.item_code;
    exception when no_data_found then r_qty := 0;
    when others then r_qty := 0;
    end;
    begin
    select nvl(sum(issue_qty),0) into i_qty
    from issu_mast a, issu_det b where a.tran_no = b.tran_no and
    a.tran_date < sdate and item_code = rec1.item_code;
    exception when no_data_found then i_qty := 0;
    when others then i_qty := 0;
    end;
    begin
    select nvl(item_rate * (r_qty - i_qty),0) into p_amt from avg_rate
    where item_code = rec1.item_code and avg_date = sdate -1 ;
    exception when no_data_found then p_amt := 0;
    when others then p_amt := 0;
    end;
    begin
    select nvl(sum(qty_accepted * item_rate),0), nvl(SUM(qty_accepted),0) into d_amt, d_qty
    from rece_mast a, rece_det b where a.tran_no = b.tran_no and
    a.tran_date = sdate and item_code = rec1.item_code;
    exception when no_data_found then d_amt := 0;d_qty:=0;
    when others then d_amt := 0;d_qty:=0;
    end;
    begin
    d_rate := (p_amt + d_amt) / (r_qty + d_qty - i_qty);
    exception when value_error then
    d_rate := 0;
    when others then
    d_rate:=0;
    end;
    insert into avg_rate (avg_date, item_code, item_rate) values (sdate, rec1.item_code,d_rate);
    sdate := sdate +1;
    end loop;
    end loop;
    commit;
    end;
    /

    Two possibilities:
    1. Some other process is using the avg_rate table and the delete statement is having to wait until that other process is finished.
    2. There is so much to do that it will take several hours to finish. How many rows are in item_mast? Because for every row in item_mast you are inserting over 2000 rows into avg_rate. Also do rece_mast and issu_mast have an index on item_code? If not you're doing a full table scan on those tables for every row you insert into avg_rate. Do rece_det and issu_det have indexes on tran_no? If not then you're doing a full table scan on those for every row you insert.
    So if there are 1 million rows in item_mast, you're inserting 2 billion rows into avg_rate. And if this is not the first time it's been run you're also deleting 2 billion rows. That could take a lot longer than 6 hours.

Maybe you are looking for

  • Exporting Address Book to .csv file

    I am trying to export my contacts from Address Book to a ".csv" file. The only export options I am seeing are "Export vCard file..." and "Back-up Address Book". I find it very hard to believe that there isn't a way for me to extract my contacts and v

  • My site desappeared from IWeb

    Hello, I am new to iWeb. I have created a website and published it at http://web.me.com/ few months ago. Everythig was OK The problem is that now (maybe after same updates, I don't know) I can not see this site in the "IWeb". It doesn't appear in thi

  • After 180 days in subcontracting ??

    hi How we can do the subcontracting cycles after 180 days with excisable materials . For example , i have sent 100 no's to subcontractor , i have received 50 no's before 180 days . Balance 50 no's how i can receive from subcontractor ?? Thanks SAP-MM

  • Is it safe to convert vivado generated Kintex 7 .bit file into SVF file with ISE14.7 Impact?

    Hi, I need to configure Kintex 7 chips in our system with SVF files (they will be accessible via SVF capable hardware only). Unfortunately Vivado doesn't support generation of SVF files (yet?). It seems, that I can convert the .bit file generated by

  • Default Intercompany rule

    Hi Guys I have few IC accounts and all have the same PlugAcct. I have the balances of these accounts from TB. Is there any default rule for the eliminations? If yes then can you please let me know? Thanks!