如何在pl / sql中使用循环(不在游标中使用)连续插入多于no_of的记录 [英] how do insert more than no_of record continuosly using loop(not use in cursor) in pl/sql

查看:103
本文介绍了如何在pl / sql中使用循环(不在游标中使用)连续插入多于no_of的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

create table SITABLE5(prin_amt number(10,2),no_year number(10,2),rate_in number(10,2),si number(10,2),ci number(10,2));
desc SITABLE5;
SELECT * FROM SITABLE5;
 
DECLARE
p number(10,2);
n number(10,2);
r number(10,2);
a number(10,2);
b number(10,2);
i number(2);
n1 number(10);
c number(10,2);
s number(10,2);
FUNCTION sif(p2 in number,n2 in number,r2 in number)
RETURN number
is
c number;
begin
c:=p2*n2*r2/100;
RETURN C;
end sif;
 
FUNCTION cif(p3 in number,n3 in number,r3 in number)
RETURN number
is
d number;
begin
d:=p3*(1+r/100)*n;
RETURN D;
end cif;
 
BEGIN
n1:=&no_of_records;
i:=1;
LOOP
if i<=n1 then
p:=&p;
n:=&n;
r:=&r;
insert into SITABLE5(prin_amt,no_year,rate_in) VALUES(p,n,r);
a:=sif(p,n,r);
b:=cif(p,n,r);
update SITABLE5 set si=a;
update SITABLE5 set ci=b;
i:=i+1; 
end if;
end loop;
END;



从SITABLE5中选择*;


select * from SITABLE5;

推荐答案

你可以使用..

在Sql中循环



ref。

http:// stackoverflow.com/questions/6069024/syntax-of-for-loop-in-sql-server [ ^ ]

https://msdn.microsoft.com/en-IN/library/ms178642.aspx [ ^ ]

http://stackoverflow.com/questions/4487546/do-while-loop-in-sql-server-2008 [ ^ ]
You can use..
While Loop in Sql.

ref.
http://stackoverflow.com/questions/6069024/syntax-of-for-loop-in-sql-server[^]
https://msdn.microsoft.com/en-IN/library/ms178642.aspx[^]
http://stackoverflow.com/questions/4487546/do-while-loop-in-sql-server-2008[^]


这篇关于如何在pl / sql中使用循环(不在游标中使用)连续插入多于no_of的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆