EVENT ADJUST_SCN 说明 [30681.1]

 

       在一篇文章中引用了ID 为[30681.1] 的文档,刚才去MOS 上查,居然没有了,原来MOS 有时也靠不住。 在google 上展转了一下,找到了这篇文章。贴过来,备用。

 

DocID:  Note:30681.1

Subject:  EVENT: ADJUST_SCN - Quick Reference

Type:  REFERENCE

Status:  PUBLISHED

 Content Type: TEXT/PLAIN

CreationDate:  20-OCT-1997

LastRevision Date:  04-AUG-2000

Language:  USAENG

 

 

ADJUST_SCNEvent

~~~~~~~~~~~~~~~~

***WARNING ***

   This event should only ever be used underthe guidance

   of an experienced Oracle analyst.

   If an SCN is ahead of the current databaseSCN, this indicates

   some form of database corruption. Thedatabase should be rebuilt

   after bumping the SCN.

****************

 

    The ADJUST_SCN event is useful in somerecovery situations where the

    current SCN needs to be incremented by alarge value to ensure it

    isahead of the highest SCN in the database. This is typically

    required if either:

      a. An ORA-600 [2662] error is signalledagainst database blocks

    or

      b. ORA-1555 errors keep occuring afterforcing the database open

         or ORA-604 / ORA-1555 errors occurduring database open.

         (Note: If startup reports ORA-704& ORA-1555 errors together

                then the ADJUST_SCN eventcannot be used to bump the

                SCN as the error is occuringduring bootstrap.

                Repeated startup/shutdown attemptsmay help if the SCN

                mismatch is small)

    or

      c. If a database has been forced openused _ALLOW_RESETLOGS_CORRUPTION

         (See<Parameter:Allow_Resetlogs_Corruption> )

 

 

    The ADJUST_SCN event acts as describedbelow.

 

  **NOTE: You can check that the ADJUST_SCNevent has fired as it

          should write a message to the alert log inthe form

         "Debugging event used to advance scn to %s".

         If this message is NOT present in the alert log the event

         has probably not fired.

 

 

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  If the database will NOT open:

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Take a backup.

    You can use event 10015 to trigger anADJUST_SCN on database open:

 

        startup mount;

 

        alter session set events '10015 tracename adjust_scn level 1';

 

        (NB: You can only use IMMEDIATE here onan OPEN database. If the

            database is only mounted use the 10015 trigger to adjust SCN,

            otherwise you get ORA 600 [2251], [65535], [4294967295] )

 

        alter database open;

 

        If you get an ORA 600:2256 shutdown, usea higher level and reopen.

 

    Do *NOT* set this event in init.ora or theinstance will crash as soon

    as SMON or PMON try to do any clean up.Always use it with the

    "alter session" command.

 

  ~~~~~~~~~~~~~~~~~~~~~~~~~~

  If the database *IS* OPEN:

  ~~~~~~~~~~~~~~~~~~~~~~~~~~

    You can increase the SCN thus:

 

        alter session set events 'IMMEDIATEtrace name ADJUST_SCN level 1';

 

    LEVEL: Level 1 is usually sufficient - it raises the SCN to 1 billion

                                           (1024*1024*1024)

           Level 2 raises it to 2 billion etc...

 

           If you try to raise the SCN to a level LESS THAN or EQUAL to its

           current setting you will get <OERI:2256>    - See below.

           Ie: The event steps the SCN to known levels. You cannot use

               the same level twice.

 

  Calculating a Level from 600 errors:

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        To get a LEVEL for ADJUST_SCN:

 

        a) Determine the TARGET scn:

            ora-600 [2662]    See <OERI:2662>  Use TARGET >= blocks SCN

           ora-600 [2256]    See<OERI:2256>  Use TARGET >=Current SCN

 

        b)Multiply the TARGET wrap number by 4. This will give you the level

          to use in the adjust_scn to get the correct wrap number.

        c) Next, add the following value to thelevel to get the desired base

          value as well :

 

        Add to Level         Base

        ~~~~~~~~~~~~ ~~~~~~~~~~~~

                   0            0

                   1   1073741824

                   2   2147483648

                   3   3221225472

 

 

 

 

-------------------------------------------------------------------------------------------------------

QQ:492913789

Email:ahdba@qq.com

Blog:  http://www.cndba.cn/dave

Weibo:   http://weibo.com/tianlesoftware

Twitter:  http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware

DBA1 群:62697716(满);   DBA2 群:62697977(满)  DBA3 群:62697850(满)  

DBA 超级群:63306533(满);  DBA4 群: 83829929  DBA5群: 142216823   

DBA6 群:158654907  聊天 群:40132017   聊天2群:69087192

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

 

PROCEDURE PROC_SETT_ADJUST_CHECK(P_ID IN t_Settlement_adjust.Id_t_Settlement_Adjust%TYPE, P_STATUS IN VARCHAR2) IS cursor cur_get_adjust_info is select * from t_settlement_adjust a where a.id_t_settlement_adjust = P_ID; cursor cur_old_charge_info(c_charge_id number) is select * from t_gls_commision_fee a where a.charge_id = c_charge_id; cursor cur_old_fee_info(c_charge_id number) is select * from t_agency_commision_fee a where a.related_id = c_charge_id; r_get_adjust_info cur_get_adjust_info%ROWTYPE; r_charge_info cur_old_charge_info%ROWTYPE; r_fee_info cur_old_fee_info%ROWTYPE; v_charge_id t_gls_commision_fee.charge_id%TYPE; v_old_charge_id t_gls_commision_fee.charge_id%TYPE; v_fee_amount t_gls_commision_fee.fee_amount%TYPE; BEGIN update t_settlement_adjust a set a.status = P_STATUS where a.id_t_settlement_adjust = P_ID; IF P_STATUS = '2' THEN return; else open cur_get_adjust_info; fetch cur_get_adjust_info into r_get_adjust_info; open cur_old_charge_info(r_get_adjust_info.charge_id); fetch cur_old_charge_info into r_charge_info; select S_AGENCY_COMM_CHARGE__ID.NEXTVAL into v_charge_id from dual; --调整需要对冲,追加不需要 if r_get_adjust_info.alter_type = '2' then v_old_charge_id := r_charge_info.charge_id; r_charge_info.charge_id := v_charge_id; r_charge_info.policy_year := r_get_adjust_info.policy_year; r_charge_info.commision_type := r_get_adjust_info.alter_type; v_fee_amount := r_charge_info.fee_amount; r_charge_info.fee_amount := -v_fee_amount; r_charge_info.commision := -r_charge_info.commision; r_charge_info.fee_status := 0; r_charge_info.policy_period := r_get_adjust_info.policy_period; r_charge_info.adjust_charge_id := r_get_adjust_info.charge_id; insert into t_gls_commision_fee values r_charge_info; --处理财务数据 open cur_old_fee_info(v_old_charge_id); fetch cur_old_fee_info into r_fee_info; r_fee_info.agency_fee_id := S_AGENCY_COMM_FEE__ID.NEXTVAL; r_fee_info.money := -r_fee_info.money; r_fee_info.related_id := v_charge_id; r_fee_info.finish_time := sysdate; r_fee_info.insert_time := sysdate; r_fee_info.update_time := sysdate; r_fee_info.posted := 'N'; r_fee_info.policy_year := r_get_adjust_info.policy_year; r_fee_info.policy_period := r_get_adjust_info.policy_period; insert into t_agency_commision_fee values r_fee_info; close cur_old_fee_info; end if; if r_get_adjust_info.adjust_rate != 0 then v_old_charge_id := nvl(v_old_charge_id, r_charge_info.charge_id); select S_AGENCY_COMM_CHARGE__ID.NEXTVAL into v_charge_id from dual; r_charge_info.charge_id := v_charge_id; r_charge_info.policy_year := r_get_adjust_info.policy_year; r_charge_info.commision_type := r_get_adjust_info.alter_type; r_charge_info.rate := r_get_adjust_info.adjust_rate; r_charge_info.fee_amount := nvl(v_fee_amount, r_charge_info.fee_amount); r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate, 2); r_charge_info.fee_status := 0; r_charge_info.policy_period := r_get_adjust_info.policy_period; r_charge_info.adjust_charge_id := r_get_adjust_info.charge_id; insert into t_gls_commision_fee values r_charge_info; open cur_old_fee_info(v_old_charge_id); fetch cur_old_fee_info into r_fee_info; r_fee_info.agency_fee_id := S_AGENCY_COMM_FEE__ID.NEXTVAL; r_fee_info.money := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate, 2); r_fee_info.related_id := v_charge_id; r_fee_info.finish_time := sysdate; r_fee_info.insert_time := sysdate; r_fee_info.update_time := sysdate; r_fee_info.posted := 'N'; r_fee_info.policy_year := r_get_adjust_info.policy_year; r_fee_info.policy_period := r_get_adjust_info.policy_period; insert into t_agency_commision_fee values r_fee_info; close cur_old_fee_info; end if; close cur_old_charge_info; close cur_get_adjust_info; END IF; exception when others then ROLLBACK; update t_settlement_adjust a set a.status = '3' where a.id_t_settlement_adjust = P_ID; END PROC_SETT_ADJUST_CHECK; r_get_adjust_info.adjust_rate是要存rate和计算commision、money的100倍,应该怎么修改代码
最新发布
10-10
<think>好的,我需要帮助用户修改他们的PL/SQL存储过程,使得r_get_adjust_info.adjust_rate存储的是rate和计算commision、money的100倍。首先,我需要理解当前的代码逻辑。 用户提供的存储过程PROC_SETT_ADJUST_CHECK处理结算调整,根据调整类型和调整率来生成新的费用记录。现在的问题是,adjust_rate需要存储的是原来的100倍,并且在计算commision和money时使用这个调整后的值。 首先,我需要找到代码中使用adjust_rate的地方。在第二个if条件块中,当adjust_rate不等于0时,会更新r_charge_info的rate、fee_amount、commision等字段。当前的代码中,rate被直接赋值为r_get_adjust_info.adjust_rate,而commision是基于fee_amount乘以adjust_rate计算的。 用户希望adjust_rate存储的是原来的100倍,所以需要将获取到的adjust_rate乘以100。同时,在计算commision和money时,应该使用原来的adjust_rate,还是调整后的?这里可能需要澄清,但根据问题描述,应该是存储时乘以100,而计算时可能仍然使用原值,或者计算时也使用100倍。需要仔细分析。 例如,当前代码中的r_charge_info.rate := r_get_adjust_info.adjust_rate; 如果需要存储为100倍,那么应该改为r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; 同样,在计算commision时,原来的代码是r_charge_info.commision := round( ... * r_get_adjust_info.adjust_rate, 2); 如果计算时需要使用100倍后的rate,那么应该用调整后的值。但用户的问题描述是“存rate和计算commision、money的100倍”,可能意味着存储时rate是原值*100,而计算commision和money时也用这个100倍的值。或者可能用户希望将adjust_rate本身存储为原值的100倍,但计算时用原来的值?需要确认。 但根据问题描述,“r_get_adjust_info.adjust_rate是要存rate和计算commision、money的100倍”,可能意味着在存储rate时,将其乘以100,同时在计算commision和money时,也使用这个100倍的值。或者可能用户希望将adjust_rate本身存储为原值的100倍,但计算时使用原值?这需要进一步确认,但根据中文问题,可能用户希望将adjust_rate的值存储为原值的100倍,并且在计算时也使用这个100倍的值。 例如,假设原来的adjust_rate是0.05,存储为5,然后计算commision时用这个5来乘以fee_amount。这会导致结果不同,所以可能用户的意思是,在计算commision和money时,使用adjust_rate乘以100,但存储时rate字段保持原值?或者存储时rate字段是原值乘以100? 需要仔细分析问题描述。问题描述是:“r_get_adjust_info.adjust_rate是要存rate和计算commision、money的100倍”,可能意思是,在存储rate时,以及在计算commision和money时,都使用adjust_rate的100倍。例如,假设adjust_rate是0.05,那么存储到rate字段应该是5(即0.05 * 100),然后计算commision时用这个5(即rate字段的值)乘以fee_amount。 但原来的代码中,rate字段被赋值为adjust_rate,而commision是fee_amount乘以adjust_rate。现在用户希望rate存储为adjust_rate的100倍,并且在计算commision时也使用这个100倍后的值。因此,修改点包括: 1. 在设置r_charge_info.rate时,乘以100。 2. 在计算commision时,使用调整后的rate(即已经乘以100后的值)或者原adjust_rate乘以100? 例如,当前的代码是: r_charge_info.rate := r_get_adjust_info.adjust_rate; r_charge_info.commision := round(nvl(v_fee_amount, ...) * r_get_adjust_info.adjust_rate, 2); 修改后应该是: r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; r_charge_info.commision := round(nvl(v_fee_amount, ...) * (r_get_adjust_info.adjust_rate * 100), 2); 或者,因为rate已经被存储为adjust_rate * 100,那么在计算commision时,可能应该用rate字段的值?例如: r_charge_info.commision := round(nvl(v_fee_amount, ...) * r_charge_info.rate / 100, 2); 这取决于业务逻辑。如果rate字段本身已经是百分比形式(比如5%存储为5),那么计算时需要除以100。但用户的问题可能希望将rate存储为adjust_rate的100倍,并且在计算时直接使用这个值。例如,如果原来的adjust_rate是0.05,存储为5,那么计算commision时是fee_amount * 5%(即5/100),或者fee_amount *5?这需要明确。 根据问题描述,“存rate和计算commision、money的100倍”,可能意味着存储到数据库的rate是原来的100倍,同时在计算commision和money时也使用这个100倍的值。例如,如果adjust_rate是0.05,存储为5,那么计算commision时是fee_amount *5%?或者fee_amount *5?这可能需要更多的上下文,但根据问题描述,可能用户希望将adjust_rate的值放大100倍存储到rate字段,并且在计算其他值时也使用这个放大后的值。 因此,在代码中: 在第一个修改点: r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; 在计算commision的地方: r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate * 100, 2); 或者,因为fee_amount可能已经被处理,需要确认v_fee_amount是否正确。或者,可能应该使用调整后的rate字段: r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * (r_charge_info.rate / 100), 2); 但根据用户的问题,可能他们希望直接将adjust_rate乘以100后用于rate字段,并且在计算commision时也直接乘以这个调整后的rate。这可能不符合数学逻辑,比如,如果原来的rate是0.05,调整后存储为5,计算commision时是fee_amount *5,这样结果会是原来的5倍,而不是5%。这可能是一个错误,但根据用户的需求描述,可能他们需要这样的处理。 因此,在代码中,修改rate的赋值,并修改commision的计算方式: 在if adjust_rate !=0 的块中: r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * (r_get_adjust_info.adjust_rate * 100), 2); 同时,在插入t_agency_commision_fee的money字段时,同样的情况: r_fee_info.money := round( ... * r_get_adjust_info.adjust_rate * 100, 2); 需要检查代码中的这些部分: 在if adjust_rate !=0 的块中: 原代码: r_charge_info.rate := r_get_adjust_info.adjust_rate; 修改为: r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; 原代码中的commision计算: r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate, 2); 修改为: r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate * 100, 2); 同样,在插入fee_info的部分: r_fee_info.money := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate, 2); 修改为: r_fee_info.money := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate * 100, 2); 这样,rate存储为adjust_rate的100倍,并且在计算commision和money时也使用这个100倍的值。 需要确认这些修改是否在代码中正确的位置。此外,还要检查是否有其他地方使用到adjust_rate,可能需要进行相应的调整。 总结修改点: 1. 在设置rate字段时,乘以100。 2. 在计算commision和money时,乘以adjust_rate的100倍。 这样修改后,存储的rate值以及计算的commision和money都会是原来的100倍。</think>要实现将`r_get_adjust_info.adjust_rate`存储为`rate`字段的100倍,并在计算`commision`和`money`时也使用该100倍的值,需要对代码进行以下修改: --- ### ✅ 修改点说明 1. **存储`rate`字段**:将`r_charge_info.rate`赋值为`r_get_adjust_info.adjust_rate * 100`。 2. **计算`commision`字段**:使用`adjust_rate * 100`进行计算。 3. **计算`money`字段**:同样使用`adjust_rate * 100`进行计算。 --- ### ✨ 修改后的代码片段 ```sql r_charge_info.rate := r_get_adjust_info.adjust_rate * 100; r_charge_info.commision := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate * 100, 2); ``` ```sql r_fee_info.money := round(nvl(v_fee_amount, r_charge_info.fee_amount) * r_get_adjust_info.adjust_rate * 100, 2); ``` --- ### 📌 注意事项 - 确保`adjust_rate`字段的原始值为小数形式(如0.05),否则需先将其标准化为小数再乘以100。 - 如果后续业务逻辑中仍需使用原始的`adjust_rate`(如显示、日志等),建议保留原始值的引用,避免混淆。 - 修改后应进行充分测试,确保数据逻辑一致性,尤其是涉及百分比计算的场景。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值