本帖最后由 rgshh1990 于 2018-4-24 12:48 编辑
今天同事测试一个存过,先不说逻辑对不对发现一个问题,我做了个简易的declare
v_vcsvccode inas.tneticket_cdma.vcsvccode%type := null;
begin
select a.vcsvccode
into v_vcsvccode
from inas.tneticket_cdma a
where a.vccustomer = '18971414162';
dbms_output.put_line('first get value:' || v_vcsvccode);
exception
when too_many_rows then
--是否取到第一个值
dbms_output.put_line('exception first get value:' || v_vcsvccode);
dbms_output.put_line('Too many rows are returned');
select a.vcsvccode
into v_vcsvccode
from inas.tneticket_cdma a
where a.vccustomer = '18971414162'
and a.vcsvccodev_vcsvccode;
dbms_output.put_line('secend get value:' || v_vcsvccode);
end;
输出如下
exception first get value:602303
Too many rows are returned
secend get value:602304