declare type name_arrary_type is varray(20) of varchar2(10); name_arrary name_arrary_type; cursor emp_cursor is select ename from emp; rowss int:=5; v_count int:=0; begin open emp_cursor; loop fetch emp_cursor bulk collect into name_arrary limit rowss; dbms_output.put_line('雇员名称:'); for i in 1..(emp_cursor%rowcount-v_count) loop dbms_output.put(name_arrary(i)||' '); end loop; dbms_output.new_line; v_count :=emp_cursor%rowcount; exit when emp_cursor%notfound; end loop; close emp_cursor; end; 是这样的取到数组?
declare type T_SDEVICE is table of varchar2(20) index by binary_integer; V_SDEVICE T_SDEVICE; begin select SDEVICE bulk collect into V_SDEVICE from table_name; for i in 1..V_SDEVICE.count loop ... end loop; end;仅供参考
type name_arrary_type is varray(20) of varchar2(10);
name_arrary name_arrary_type;
cursor emp_cursor is select ename from emp;
rowss int:=5;
v_count int:=0;
begin
open emp_cursor;
loop
fetch emp_cursor bulk collect into name_arrary limit rowss;
dbms_output.put_line('雇员名称:');
for i in 1..(emp_cursor%rowcount-v_count) loop
dbms_output.put(name_arrary(i)||' ');
end loop;
dbms_output.new_line;
v_count :=emp_cursor%rowcount;
exit when emp_cursor%notfound;
end loop;
close emp_cursor;
end;
是这样的取到数组?
declare
type T_SDEVICE is table of varchar2(20) index by binary_integer;
V_SDEVICE T_SDEVICE;
begin
select SDEVICE bulk collect into V_SDEVICE
from table_name;
for i in 1..V_SDEVICE.count loop
...
end loop;
end;仅供参考
其中AA是时间,格式是YYYY-MM-DD HH24:MI,时间是每隔一小时有一个数据,也是一天有24组数据, BB是编号,代表不同的车间,CC是产品数量,现在我要根据车间编号,求算出每个星期每个整点的规律。
比如星期一 某车间 8点的产品数量是44,等等。
我现在的想法是把车间编号读入一个数组,然后做一个循环,根据这个数组里的不同编号,按时间进行整理。
进行整理的SQL语句我已经想好了。现在就是不会把BB字段读入数组。
我用的是C #