pl/sql stored procedure: parameter name same as column name

后端 未结 4 1508
面向向阳花
面向向阳花 2021-02-02 09:44

I have a Stored Procedure like this

procedure P_IssueUpdate
(
    Id in integer,
    ModifiedDate in date,
    Solution in varchar2
) AS
BEGIN
update T_Issue
Set         


        
4条回答
  •  礼貌的吻别
    2021-02-02 10:06

    RE Vincent's answer about prepending a prefix--that solution works until somebody modifies the table and adds a column whose name happens to collide with the parameter name. Not everybody goes through every line of code to make sure their table modifications won't conflict with variable or parameter names. Oracle's recommendation is to qualify every parameter or variable name in a SQL query.

    If you're working with an anonymous block (outside a procedure), you can name the block and qualify variables that way:

    <>
    declare
       X   sys.USER_TABLES%rowtype;
       Y   sys.USER_TABLES.TABLE_NAME%type := 'some_table_name';
    begin
       select UT.*
       into   MY_BLOCK.X
       from   sys.USER_TABLES UT
       where  UT.TABLE_NAME = MY_BLOCK.Y;
    end MY_BLOCK;
    

提交回复
热议问题