包中没有错误的过程不会更新数据库中的表

时间:2013-12-04 10:16:20

标签: sql oracle stored-procedures

我有一个包含四个程序的包,工作正常。我在现有包中添加了另一个(第五个)过程。当我执行包含五个程序的新包时,我收到信息:“创建包体”。当我检查数据库中应该更新的表时没有变化,当我检查应用程序时也没有变化。

要在Toad中测试/执行包,请按“执行脚本”。我已经单独检查了select语句和只更新语句,它工作正常(以我期望的方式)。看起来更新语句不起作用,但它可能是其他的。

我试图解决它很长一段时间,但我不知道问题出在哪里。

请参阅以下我想添加的程序:

PROCEDURE procedure_name_test (errbuf OUT VARCHAR2, retcode OUT NUMBER)
IS
    CURSOR c_headers
    IS
        SELECT I.INVOICE_ID, SUM(D.AMOUNT) AS HOLD_VALUE
        FROM APD D,
             API I,
             APH H
        WHERE D.LINE_TYPE_LOOKUP_CODE = 'ITEM'
        AND D.BASE_AMOUNT IS NULL
        AND D.PO_DISTRIBUTION_ID IS NULL
        AND D.UNIT_PRICE IS NULL
        AND I.PAY_GROUP_LOOKUP_CODE = 'RESALE'
        AND H.hold_lookup_code = 'ITEM NOT ON PO'
        AND H.RELEASE_LOOKUP_CODE IS NULL
        AND H.RELEASE_REASON IS NULL
        AND I.INVOICE_ID = D.INVOICE_ID
        AND D.INVOICE_ID = H.INVOICE_ID  
        GROUP BY I.INVOICE_ID
        HAVING SUM(AMOUNT) < 100
        AND ( SUM(AMOUNT) < 50
            OR ( MAX(AMOUNT) < 50 AND MIN(AMOUNT) < 50) );

    v_rec_count NUMBER := 0;
    COUNT1 NUMBER := 0;

BEGIN

    FOR c_headers_r IN c_headers
    LOOP
        v_rec_count := v_rec_count + 1;
        fnd_file.put_line (fnd_file.output,
            'No Of Invoices with Immaterial ITEM NOT ON PO Hold : '
                || v_rec_count );
        UPDATE APH
        SET last_update_date = SYSDATE,
            last_updated_by = fnd_profile.VALUE ('USER_ID'),
            release_lookup_code = 'Immaterial Matching Rel',
            release_reason = 'Immaterial matching difference TEST '
                || TRIM (TO_CHAR (c_headers_r.HOLD_VALUE,'L999G999G999G990D99'))
                || ' (system)',   
            last_update_login = (SELECT MAX (submitted_login_id)
                                 FROM applsys.fnd_logins
                                 WHERE user_id = fnd_profile.VALUE ('USER_ID')),
            responsibility_id = fnd_profile.VALUE ('RESP_ID')

        WHERE RELEASE_LOOKUP_CODE IS NULL
        AND HOLD_LOOKUP_CODE = 'ITEM NOT ON PO';

        commit;

        COUNT1 := COUNT1 + 1;

    END LOOP;

    fnd_file.put_line (FND_FILE.output,
        'No Of Invoices where Immaterial Hold released : '|| COUNT1);

EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
        fnd_file.put_line (FND_FILE.output,'No data Found');

    WHEN OTHERS
    THEN
        fnd_file.put_line (fnd_file.LOG,'Immaterial hold is not Released:'
            ||SQLERRM);    
END;

1 个答案:

答案 0 :(得分:0)

消息“Package body created”表示您已成功编译数据库中的新代码。下一步是实际运行您的代码。

这样的事情:

declare
  l_error_buffer varchar2(32767);
  l_retcode number;
begin
  package_name.procedure_name_test (l_error_buffer, l_retcode);
end;
/