当前位置:首页 » 存储配置 » oracle存储过程while

oracle存储过程while

发布时间: 2022-12-11 09:35:57

1. oracle存储过程怎样批量插入新数据

需要生成的sql
insert into TMP_UPSTATE_CASEKEY values('TMP0000001', 1, sysdate);

存储过程实现
create or replace procere proc_casekey_upstate
as
casekey char(14);
begin
for i in 1..10000000 loop
casekey := 'TMP'||lpad(i,7,0); -- TMP0000001
insert into TMP_UPSTATE_CASEKEY values(casekey, 1, sysdate);
end loop;
commit;
end;

begin
proc_casekey_upstate();
end;

测试发现生成一千万条数据用了14分钟左右,性能还是可以了,如果先去掉TMP_NUM_STATUS_ID的外键估计更快。
或者:
insert into TMP_UPSTATE_CASEKEY select 'TMP'||LPAD(rownum,7,0),1,sysdate from al connect by level <= 1000000;

2. oracle存储过程循环插数据

有以下几个步骤。
在表account中循环插入数据,id从1001到1005。createor
replace
procere
test
is--存储过程,名称为test。v_id
int;
--声明变量。begin。v_id
:=1001;
--ACCOUNT_ID从1001插到1005。while
v_id
<=1005--设置插入的次数。loop。

3. Oracle 定义存储过程 不能执行,处于无效状态。

无效状态有两种可能,一种是你的存储过程编辑没有成功,创建了,但里面有语法错误。
还有一种是存储过程使用的表有结构上的改变,需要重新编译一下。
你重新编译一下,如果不成功,就是有语法问题,你需要修改存储过程。

4. oracle存储过程问题,执行之后如截图显示叉叉。

写法有问题,编译有错误

CREATEORREPLACEPROCEDUREp_test(bgnINVARCHAR2,--开始时间
edINVARCHAR2--结束时间
)IS
vsqlVARCHAR2(20000);
tnameVARCHAR2(20);--动态表名
begindateVARCHAR2(20);
enddateVARCHAR2(20);
BEGIN
tname:='动态表名固定部分';
vsql:='';
begindate:=bgn;
enddate:=ed;
WHILE(substr(begindate,1,7)<substr(enddate,1,7))LOOP
vsql:=vsql||'unionall'||chr(10)||
'selectsubstr(记账时间,1,7),公司名称,sum(金额)from'||tname||
substr(begindate,1,4)||substr(begindate,6,2)||
'whererptdate=(selectmax(记账时间)from'||tname||
substr(begindate,1,4)||substr(begindate,6,2)||
')groupbysubstr(记账时间,1,7),公司名称'||chr(10);
begindate:=to_char(add_months(to_date(begindate,'yyyy-mm-dd'),1),
'yyyy-mm-dd');
ENDLOOP;
vsql:=vsql||'unionall'||chr(10)||
'selectsubstr(记账时间,1,7),公司名称,sum(金额)from'||tname||
substr(enddate,1,4)||substr(enddate,6,2)||
'whererptdate='''||enddate||
'''groupbysubstr(记账时间,1,7),公司名称'||chr(10);
vsql:=substr(vsql,12);
--dbms_output.put_line(vsql);
EXECUTEIMMEDIATE(vsql);
ENDp_test;

5. Oracle存储过程,更新大量数据,如何循环分批次提交

可通过以下方法:

以100条数据为例,如果海量数据可参考。

如test表中有如下数据:

declare
iint;--定义变量
v_countint;--定义变量
v_loopint;--定义变量
begin
selectcount(*)intov_countfromtest;--计算表内数据总数
selectceil(v_count/10)intov_loopfromal;--计算需要循环次数
i:=1;--为i赋值
whilei<=v_looploop--循环退出条件
updatetestsetbegintime=<=10;--执行更新
commit;--提交
i:=i+1;--i依次加1
endloop;--结束循环
end;

6. oracle存储过程问题

可能是这个存储过程编译没成功。
create or replace procere proc_kaoqin
as
v_id int;
v_id1 int;
v_inprout varchar2(20);
v_inprout1 varchar2(20);
begin
v_id:=1;
loop
exit when (v_id+1)>(select max(id) from kaoqin_temp);
v_id1:=v_id+1;
select in_or_out into v_inprout from kaoqin_temp where id=v_id;
select in_or_out into v_inprout1 from kaoqin_temp where id=v_id1;
if v_inprout=v_inprout1 then
delete from kaoqin_temp where door='部门门' and id in(v_id,v_id1);
end if;
vid:=vid+1;
end loop;
end proc_kaoqin;
重新编译再试一下。

7. oracle存储过程中如何对一个变量累加赋值 最好有个例子

1、首先打开oracle数据库,如下图所示。

8. 执行oracle存储过程的时候,提示在①那个地方报命令未正确结束

select * from B where city_code =upp; //这句话有什么用?貌似没有用到么


insertintoBvalues((=(=addCode)),------------------①

oracle里面没有这种语法,有两种方式你可以尝试

  • select xxx into 到变量里。如select xxx into A,然后insert into B values(A);

  • select xxx from xxx。如:

    insert into B

    select (select a from A),(select b from A) from al;

9. oracle存储过程怎么写循环

写循环的操作方法和步骤如下:

1、第一步,编写存储过程的整体结构,然后定义变量,见下图。

10. oracle存储过程如何输出信息

可用DBMS_OUTPUT.PUT_LINE()对存储过程的进行输出。

编写存储过程:

create or replace procere test_pro(in_num number)

as

M number;

begin

M := in_num;

if 0 < M then

dbms_output.put_line('输出SQL语句1');

elsif M < 3 then

dbms_output.put_line('输出SQL语句2');

else

dbms_output.put_line('nothing');

end if;

end;

(10)oracle存储过程while扩展阅读;

存储在数据库的数据字典中,存储在当前的应用中安全性由数据库提供安全保证,必须通过授权才能使用存储子程序,安全性靠应用程序来保证,如果能执行应用程序,就能执行该子程序。模式描述IN参数用来从调用环境中向存储过程传递值,不能给IN参数赋值,给此参数传递的值可以是常量、有值的变量、表达式等。

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:600
制作脚本网站 发布:2025-10-20 08:17:34 浏览:892
python中的init方法 发布:2025-10-20 08:17:33 浏览:586
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:771
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:690
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1017
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:261
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:120
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:810
python股票数据获取 发布:2025-10-20 07:39:44 浏览:719