Oracle之select into var1

    xiaoxiao2021-04-11  37

    前几天同事写存储过程遇到这么一个问题:

    select t1.a into t_code from table1 t1 ----t_code是定义的varchar2紧接着

    select count(1) from table2 t2 where t2.t_code = t_code 他就发现查询的结果是table2的全量,where条件没起作用。

    本来我以为是select into 语法有作用域的限制。因为

    select t1.a into t_code from table1 t1 之后,又跟着一个insert commit;

    但是去掉insert commit,where条件还是不起作用。 所以就怀疑变量名t_code和table2表的t_code字段名是一样的。 结果换了变量名后,就可以了。

    转载请注明原文地址: https://ju.6miu.com/read-666464.html

    最新回复(0)