You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建更新位置的存储过程遇PLS-00103错误,求协助修复

Fixing Your Location Update Stored Procedure

Hey there! No worries, we all start somewhere—let's get that stored procedure working right away. I spotted a couple of syntax issues in your code that are causing the error, plus a small readability tweak that'll make your code easier to maintain later.

The Issues in Your Original Code:

  • Incorrect type reference syntax: You used @ when defining parameter types, but in Oracle (which this looks like), you need to use %TYPE to reference the data type of an existing table column.
  • Confusing parameter name: p_CON_NAME is mapped to the LOCATION column—this name is misleading (it sounds like it's for a consultant's name, not their location). Renaming it will make your code clearer.

Corrected Code:

CREATE OR REPLACE PROCEDURE updateLOCATION(
    p_CON_ID IN LDS_CONSULTANT.CONSULTANT_ID%TYPE,
    p_NEW_LOCATION IN LDS_CONSULTANT.LOCATION%TYPE
) IS
BEGIN
    UPDATE LDS_CONSULTANT
    SET LOCATION = p_NEW_LOCATION
    WHERE CONSULTANT_ID = p_CON_ID;
    
    COMMIT;
END;
/

Quick Notes:

  • The %TYPE keyword ensures your parameters match the exact data type of the columns in LDS_CONSULTANT—if the column type ever changes, your procedure will automatically adapt without needing manual updates.
  • I added line breaks and indentation to make the code easier to read (always a good habit for stored procedures!).
  • If you want to handle cases where no rows are updated (like if the CONSULTANT_ID doesn't exist), you could add an exception block, but that's optional for now since your main goal is to fix the syntax error.

内容的提问来源于stack exchange,提问作者gozzlia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:22:46