zoukankan      html  css  js  c++  java
  • Oracle-常见的错误

    1、见下面的例子

    create or replace procedure p_qr_stu_cid(s_id in number, c_id out number) 
    as
    begin
      select t.class_id into c_id from student t where t.s_id = s_id;
    end;

       上面的存储过程,我们可以编译通过,也比较简单,看着没有什么问题,了入参s_id与数据库表student的s_id相同之外,其他没有什么特殊的了,我们进行调试:

    ORA-01422: 实际返回的行数超出请求的行数
    ORA-06512: 在 "SCOTT.P_QR_STU_CID", line 4
    ORA-06512: 在 line 7
    
    View program sources of error stack?

       提示的错误信息是与预期的返回单行不匹配,检查数据库:结果确确实实只能返回一条啊。但确实,问题就出在入参s_id与表字段同名的问题上。

        我们对入参做一些修改:

    create or replace procedure p_qr_stu_cid(i_s_id in number, c_id out number) 
    as
    begin
      select t.class_id into c_id from student t where t.s_id = i_s_id;
    end;

        再次调试程序

  • 相关阅读:
    code3728 联合权值
    Codevs 4600 [NOI2015]程序自动分析
    code1540 银河英雄传说
    code1074 食物链
    堆排序
    哈夫曼树与哈夫曼码
    优先队列用法
    code1154 能量项链
    code1225 八数码Bfs
    javascript5
  • 原文地址:https://www.cnblogs.com/ZeroMZ/p/11352241.html
Copyright © 2011-2022 走看看