linux中oracle的存储过程批量插入数据怎么写,怎么运行,我的写法提示错误,附图
高洛峰
高洛峰 2017-04-17 14:20:33
[Linux讨论组]

linux中oracle的存储过程批量插入数据怎么写,怎么执行

    SQL> create procedure rong
      2  is
      3  begin
      4  declare i integer;
      5  i=1;
      6  loop
      7  insert into student_info(id,name,gender,describe,blogsite)values(i,'cuihuanhuan','girl','dddd','baidu.com');
      8  i=i+1;
      9  exit when i>100;
     10  end loop;
     11  end;
     12  /
    
    Warning: Procedure created with compilation errors.
    
    SQL> show errors
    Errors for PROCEDURE RONG:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    5/2     PLS-00103: Encountered the symbol "=" when expecting one of the
         following:
         constant exception <an identifier>
         <a double-quoted delimited-identifier> table long double ref
         char time timestamp interval date binary national character
         nchar
    
    SQL> 
    
    
    SQL> create procedure hui 
  2  is
  3  begin
  4  declare i integer;
  5  i:=1;
  6  loop
  7  insert into student_info(id,name,gender,describe,blogsite)values(i,'cuihuanhuan','girl','dddd','baidu.com');
  8  i:=i+1;
  9  EXIT when i>100;
 10  end loop;
 11  end;
 12  /

Warning: Procedure created with compilation errors.

SQL> show errors
Errors for PROCEDURE HUI:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/2     PLS-00103: Encountered the symbol "=" when expecting one of the
     following:
     constant exception <an identifier>
     <a double-quoted delimited-identifier> table long double ref
     char time timestamp interval date binary national character
     nchar

SQL> 




这个错误提示到底是什么意思?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(1)
PHP中文网

在oracle命令行可以使用show errors显示出错的详细信息。

源代码最好不要截图,而是把文本贴上来(编辑区域的工具栏的第5个按钮就是让写源代码的),方便大家看。
上面代码明的错误有几点:
1、j变量没有定义
2、第7行的退出循环语句书写错误,应该是EXIT when j > 100
3、逻辑错误,j变量没有递增赋值,会导致死循环

正确的版本大概是:

create or replace procedure rong
is
  i integer;
begin
  i := 1;
  loop
    insert into student_info(id,name,gender,describe,blogsite)values(i,'cuihuanhuan','girl','dddd','baidu.com');
    i := i + 1;
    exit when i > 100;
  end loop;
end;
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号