刚开始我也不会写Oracle的存储过程,以前顶多用过SQLServer,工作时偶尔要处理上万条的数据,有时候不得不手动处理,有时候,可以想办法使用工具解析导入数据库,虽然存储过程不能很好的处理海量数据,这只是我业余看到就学习总结了一下。由浅入深的实现了几个实例,看完了,就可以简单的掌握Oracle存储过程的些许语法了。
1. 先在库里新建个表
create table new_table_test (num1 int,num2 int,num3 int)
2.简单的不带循环的插入数据到表里
create or replace procedure myproc
is
num integer;
begin
num:=1;
begin
insert into new_table_test values(num,2,3);
end;
end myproc;
注意:变量num类型为Integer;
3.在2的基础上实现变量值赋值时的处理:
create or replace procedure myproc
is
num integer;
begin
num:=1;
begin
num:=num+1;
insert into new_table_test values(num,2,3);
end;
end myproc;
注意:不要多加个set,变量记得加个冒号。
4.使用while循环进行插入1000行数据
知识点:while循环使用loop,最后使用en