c**t 发帖数: 2744 | |
c**t 发帖数: 2744 | 2 the way comes on top of my head is:
declare sql_stmt varchar2(30000);
begin
for i in myCollectionOfObject.First..myCollectionOfObject.LAST
LOOP
sql_stmt := sql_stmt || ConstructSQL( myCollectionOfObject(i) );
END LOOP;
open cursor for sql_stmt;
end;
any better way?
【在 c**t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : in oracle how?
|
B*****g 发帖数: 34098 | 3 没看懂,给个例子。
【在 c**t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : the way comes on top of my head is: : declare sql_stmt varchar2(30000); : begin : for i in myCollectionOfObject.First..myCollectionOfObject.LAST : LOOP : sql_stmt := sql_stmt || ConstructSQL( myCollectionOfObject(i) ); : END LOOP; : open cursor for sql_stmt; : end; : any better way?
|
c**t 发帖数: 2744 | 4
procedure Foo(pResult OUT type_return_cursor)
as
type MyRow is object (
f1 varchar2(10),
f2 NUMBER,
f3 Date);
type MyTbl is VARRAY(10) of MyRow;
myTbl MyTbl;
stmt varchar2(5000) := '';
begin
myTbl := MyTbl();
for i IN 1..10 loop
myTbl(i).f1 := 'string of ' || to_char(i);
myTbl(i).f2 := i;
myTbl(i).f3 := trunc(sysdate, 'HH24') + i / 12;
end loop;
for i in myTbl.First..myTbl.Last
Loop
if i > 1 then stmt := stmt || CHR(10) || 'UNION' || CHR(10); e
【在 B*****g 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 没看懂,给个例子。
|