btcq.net
当前位置:首页 >> orAClE存储过程For >>

orAClE存储过程For

首先编写存储过程的整体结构,如下:create or replace procedure test_proc is v_date date; --变量定义 begin select sysdate into v_date from dual; end test_proc;2 定义游标:create or replace procedure test_proc is v_date date; --定义变量

你这段存储过程的其他的部分都是什么啊? 你这几行写法看上去没有太大问题. 下面是一段成功执行的例子 sql> declare 2 type refcursor is ref cursor; 3 v_cursor refcursor; 4 v_sql varchar(200); 5 v_name varchar(10); 6 begin 7 -- 动态sql 8 v_sql :=

一条语句可以解决,用不着for游标循环.create table M_TATTENDANCEDATA(TR_DATE char(8),PAY_CARD_COUNT int);insert into M_TATTENDANCEDATA values(20120922, 324);insert into M_TATTENDANCEDATA values(20120921, 314

SQL> DECLARE 2 testvalue INT; 3 BEGIN 4 5 FOR testvalue IN 1..5 LOOP 6 dbms_output.put_line( TO_CHAR(testvalue) ); 7 END LOOP; 8 9 END; 10 /12345PL/SQL procedure successfully completed.

调用系统函数dbms_output.putline()循环输出varArry(i)的值,例如varArray()=(1,2,3,4,5)输出的结果为:The No.1 record in varArray is :1The No.2 record in varArray is :2The No.3 record in varArray is :3The No.4 record in varArray is :4The No.5 record in varArray is :5

SQL Server 中没有For循环,可以使用while循环代替,另外你写的存储过程还有几处有问题,一并给你改过来了.CREATE PROCEDURE AddStudents AS Begin Declare @n bigint Declare @Sql nvarchar(225) set @n=0while @n<10000begin Set @Sql='Insert into Students Values(''Hamunet'',10,''SianChina'',''123456789123'')' Exec (@Sql) set @n=@n+1End

SQL> DECLARE 2 testvalue INT; 3 BEGIN 4 5 FOR testvalue IN 1..5 LOOP 6 dbms_output.put_line( TO_CHAR(testvalue) ); 7 END LOOP; 8 9 END; 10 /12345PL/SQL procedure successfully completed.

用while吧~例如while i<=100.i=i+2end while

这个就是调用oracle的dbms_output包的putline函数,循环输出一个数组.

Oracle中有三种循环(For、While、Loop):1、loop循环:create or replace procedure pro_test_loop isi number;begini:=0;loop i:=i+1; dbms_output.put_line(i); if i>5 then exit; end if;end loop;end pro_test_loop;2、while循环:create or replace procedure pro_test_loop isi number;begini:=0;while i 评论0 0 0

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