接下来我的最后一个问题(
Table Variables in Oracle PL/SQL?)…
一旦你在数组/表中有值,你又怎么把它们重新出来呢?最好使用select语句或类似的东西?
这是我到目前为止
declare type array is table of number index by binary_integer; pidms array; begin for i in ( select distinct sgbstdn_pidm from sgbstdn where sgbstdn_majr_code_1 = 'HS04' and sgbstdn_program_1 = 'HSCOMPH' ) loop pidms(pidms.count+1) := i.sgbstdn_pidm; end loop; select * from pidms; --ORACLE DOESN'T LIKE THIS BIT!!! end;
我知道我可以使用dbms_output.putline()输出它们,但我希望从任何其他表中选择一个结果集.
提前致谢,
马特
您可能需要一个GLOBAL TEMPORARY TABLE.
在Oracle中,这些被创建一次,然后被调用时,数据对你的会话是私有的.
尝试这样的东西…
CREATE GLOBAL TEMPORARY TABLE temp_number ( number_column NUMBER( 10,0 ) ) ON COMMIT DELETE ROWS; BEGIN INSERT INTO temp_number ( number_column ) ( select distinct sgbstdn_pidm from sgbstdn where sgbstdn_majr_code_1 = 'HS04' and sgbstdn_program_1 = 'HSCOMPH' ); FOR pidms_rec IN ( SELECT number_column FROM temp_number ) LOOP -- Do something here NULL; END LOOP; END; /