1,先定义一个游标  
  CURSOR cur_Main (
        in_vch  IN VARCHAR2  
      , in_num IN NUMBER
    ) IS
  select
         a,b,c,d,e
   form  temp
   where
        a = vch  
      and b = in_num;
游标变量
    curGetRecord cur_Main%ROWTYPE;
2在定义了一个Record
    TYPE TY_REC IS RECORD(
          out_a   temp.a%type
        , out_b   temp.b%type
        , out_c   temp.c%type
        , out_d   temp.d%type
        , out_e   temp.e%type
    );
record变量
    tempRecord  TT_REC;
3,main函数
        FOR curGetRecord
        IN cur_Main( inPrm.vch
                  , inPrm.num)
        LOOP            GET_DATA(tempRecord  );
            
        END LOOP;
4在GET_DATA(tempRecord)这个方法中:
    PROCEDURE GET_DATA(tempRecord IN OUT TT_REC)
IS
BEGIN
     tempRecord.out_a := curGetRecord.a;(这里的游标有值,但是取不出来,为什么?)
END GET_DATA;在上面代码中:如果定义一个a类型的变量temp,
如   a是number型,
temp    NUMBER(8) : = null;
temp :=    curGetRecord.a; 这样也得不到值,但是鼠标点击curGetRecord.a这里是有数据的,为什么很奇怪!!
请高人指点!!!!!!!!!!!!!!

解决方案 »

  1.   

    我感觉逻辑有点问题
    在GET_DATA这个存储过程里,怎么会有curGetRecord出现呢?它是全局变量吗?4 GET_DATA(tempRecord)这个方法中:
        PROCEDURE GET_DATA(tempRecord IN OUT TT_REC)
    IS
    BEGIN
         tempRecord.out_a := curGetRecord.a;(这里的游标有值,但是取不出来,为什么?)
    END GET_DATA;
      

  2.   

    “在上面代码中:如果定义一个a类型的变量temp, 
    如   a是number型, 
    temp    NUMBER(8) : = null; 
    temp :=    curGetRecord.a; 这样也得不到值,但是鼠标点击curGetRecord.a这里是有数据的,为什么很奇怪!!

    =====================================================
    你的curGetRecord.a是VARCHAR2,temp是number型,是不是这有问题?
      

  3.   

    ls的,for loop就是打开游标main 中,你没有给结构体付值
    fetch l_cur_Main( inPrm.vch 
                      , inPrm.num) bulk collect into tempRecord ;
      

  4.   

    或者 
    for...
      tempRecord  := curGetRecord;
    end...
      

  5.   

    真的逻辑很混乱,
    不过,总算看明白了。
    你的TT_REC没有赋值(没有在任何地方赋值)。
    所以不会得到任何信息并且程序不会报错误。
      

  6.   

    上述问题解决方法,如下:
    3,main函数 
            FOR curGetRecord 
            IN cur_Main( inPrm.vch 
                      , inPrm.num) 
            LOOP 
                tempRecord  = curGetRecord; 
                GET_DATA(tempRecord  ); 
                 
            END LOOP;