SQL column name same as PL/SQL variable name - How can this be done in a select statement?

后端 未结 5 1398
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 20:10

Suppose I have a table:

create table foo (
  col_1     number;
  col_2     number;
);

Then I have the following code

declar         


        
5条回答
  •  被撕碎了的回忆
    2020-12-19 20:36

    For future reference and carrying one from @user272735 answer - the following also works

    create table foo (a number, b number);
    
    insert into foo values(1, 10);
    insert into foo values(2, 20);
    insert into foo values(3, 30);
    /
    
    create procedure bar
    as
      a number;
      b number;
    begin
      a := 2;
      select b into bar.b from foo where a = bar.a;
      dbms_output.put_line(b);
    end;
    /
    

提交回复
热议问题