创建更新位置的存储过程遇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%TYPEto reference the data type of an existing table column. - Confusing parameter name:
p_CON_NAMEis mapped to theLOCATIONcolumn—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
%TYPEkeyword ensures your parameters match the exact data type of the columns inLDS_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_IDdoesn'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
相关产品推荐
相关产品推荐

