oracle/plsql: ora-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 3977208
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2007-01-30 15:47:05

i create a test procedure:
create or replace procedure proce_0(
    ival in osm_tab_proce.col_0%type:=10,
    ocnt in out number)
as
    a osm_tab_proce.col_0%type;
    r osm_tab_proce%rowtype;  
    i number := 0;  
    cursor c1(ct0 number) is select col_0 from osm_dml_2sp.osm_tab_proce where col_0>ct0;begin  
  if c1%isopen=false then
    open c1(196);
  end if;

  loop
    fetch c1 into a;
    exit when c1%notfound;

    select col_0,col_1,col_2 into r from osm_dml_2sp.osm_tab_proce
      where col_0=a and rownum<2; -- if rownum < 2 delete then ora-01422

    r.col_0 := a ival;
    r.col_2 := to_char(a) || to_char(sysdate);
    insert into osm_dml_2sp.osm_tab_proce values r;
    i := i 1;
  end loop;

  close c1;
  ocnt := i;
end;

error message:

error:     ora-01422: exact fetch returns more than requested number of rows
cause:     you tried to execute a select into statement and more than one row was returned.
action: the options to resolve this oracle error are:

   1. rewrite your select into statement so that only one row is returned.
   2. replace your select into statement with a cursor.

for example, if you tried to execute the following sql statement:

    select supplier_id
    into cnumber
    from suppliers
    where supplier_name = 'ibm';

and there was more than one record in the suppliers table with the supplier_name of ibm, you would receive the ora-01422 error message.

in this case, it might be more prudent to create a cursor and retrieve each row if you are unsure of how many records you might retrieve.

error message ref:
阅读(2915) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图