wdjh.net
当前位置:首页 >> orAClE sql怎么写循环语句 >>

orAClE sql怎么写循环语句

declare sql_tem Varchar2(4000); a number; b number; i number; begin a := 1; for i in 1 .. 3 loop b := a + 4; sql_tem := 'insert into A2 (ID,NAME) (select ID,NAME from A1 WHERE ROWNUM between :1 and :2)'; EXECUTE IMMEDIATE sql_t...

declare j number := 4; k number := 0; cursor cur_get_data is select a1 from TableA; begin for i in cur_get_data loop update TableB set TableB.b2 = i.a1 where TableB.b1 = k; k := j; j := j+ 5; end loop; end ;

写个过程如下: create or replace procedure test is n number; begin n:=0; for i in 1 .. 100 loop n:=n+i; end loop; dbms_output.put_line(n); end; 最终显示结果如下图:

declare sql_tem Varchar2(4000); a number; b number; i number; begin a := 1; for i in 1 .. 3 loop b := a + 4; sql_tem := 'insert into A2 (ID,NAME) (select ID,NAME from A1 WHERE ROWNUM between :1 and :2)'; EXECUTE IMMEDIATE sql_t...

ORACLE循环语句 1、 Exit When 循环: www.2cto.com Sql代码 declare -- Local variables here i integer; begin i:=0; LOOP Exit When(i>5); Dbms_Output.put_line(i); i:=i+1; END LOOP; end; 2、 Loop 循环 Java代码 declare -- Local variab...

咦,刚有回答你一个问题。你这个是只判断table1.number>table2.number情况下才update。其他情况不考虑。 update table1 t3 set t3.number = (select number from (select t1.id, t1.number - t2.number number from table1 t1, table2 t2 where ...

select t.sid,t.hobby from (select row_number() over (partition by sid order by hobby desc ) as num,sid,hobby from info) t where t.num

只能 select * from dd_20140101 union all select * from dd_20140102 ..... 这种了。 你简单点,也只能对日期进行循环,然后拼SQL语句。变成字符串再执行。

你的需求不需要使用存储过程的,一个简单的聚合函数就能实现吧。 用存储过程反而麻烦,你想用的话,可以学习一下pl/sql相关的内容。

CREATE OR REPLACE PACKAGE BODY PKG_A_TESTPACKAGE IS PROCEDURE PKG_A_TESTPROCEDURE(PRM_参数 IN VARCHAR2, PRM_返回值 OUT NUMBER, PRM_错误信息 OUT VARCHAR2) IS TYPE CURSOR_TYPE IS REF CURSOR; CUR_SQL CURSOR_TYPE; TYPE TYP_REC_INFO...

网站首页 | 网站地图
All rights reserved Powered by www.wdjh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com