无法打印dbms_output

时间:2013-12-04 17:43:39

标签: sql oracle plsql

当我说c1_list不是游标时,我试图打印下面的sql块的输出。谁能告诉我我可能缺少的东西。

  Declare
  Cursor c1 is 
  select store_id ,geometry from TMCS.TMCS_All_Stores_TA  where CLIENT_ID= 1 and rownum <1;

  Type C1_TAB_TYPE is table of c1%ROWTYPE;      
  c1_list c1_TAB_TYPE;

    --   DBMS_OUTPUT.PUT_LINE('2012 Population--> '||c1_list(1).store_id); 

  Begin     
            For r1 in c1 
               Loop

               select  store_id ,geometry 
                BULK COLLECT INTO c1_list from
               (
                  select 
                  store_id, store_number ,geometry 
                  from TMCS.TMCS_ALL_STORES_TA
                  where client_id=1
                  and   SDO_RELATE(Geometry, r1.geometry,'mask=anyinteract') = 'TRUE'
                  and store_id != r1.store_id
               );


                     For r1 in c1_list
                     Loop
                     DBMS_OUTPUT.PUT_LINE('2012 Population--> '||r1.store_id);  
                      End Loop;
            End Loop;

  End;

1 个答案:

答案 0 :(得分:2)

c1_list不是游标,它是一个变量。你可以这样做:

For i in c1_list.First..c1_list.Last loop
   DBMS_OUTPUT.PUT_LINE('2012 Population--> '||c1_list(i).store_id); 
end loop;