http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/devdays2012/mod2_sqldev/mod2_sqldev.html?cid=6267&ssid=108791759479565

解决方案 »

  1.   


    DECLARE
      PI_SERIALNO VARCHAR2(200);
      MY_CUR sys_refcursor;
    BEGIN
      PI_SERIALNO := '2003004495';  USP_CA_GETAORHCAMPAIGNS(
        PI_SERIALNO => PI_SERIALNO,
        MY_CUR => MY_CUR
      );
      /* Legacy output: 
    DBMS_OUTPUT.PUT_LINE('MY_CUR = ' || MY_CUR);
    */ 
      :MY_CUR := MY_CUR; --<-- Cursor
    --rollback; 
    END;但是执行结果是
    Bind Variable "MY_CUR" is NOT DECLARED
    anonymous block completed请问问题出在哪里?
      

  2.   


    DECLARE
      PI_SERIALNO VARCHAR2(200);
      MY_CUR sys_refcursor;
    BEGIN
      PI_SERIALNO := '2003004495';  USP_CA_GETAORHCAMPAIGNS(
        PI_SERIALNO => PI_SERIALNO,
        MY_CUR => MY_CUR
      );
      /* Legacy output: 
    DBMS_OUTPUT.PUT_LINE('MY_CUR = ' || MY_CUR);
    */ 
      --:MY_CUR := MY_CUR; --<-- Cursor
    /**do something using MY_CUR*/
    --rollback; 
    END;
      

  3.   

    my_cur 是作为输出的,并不是输入。在没有定义的情况下用,肯定是报错了。必须先声明,再打开才行。
      

  4.   


    刚刚接触PLSQL,不怎么熟悉。USP_CA_GETAORHCAMPAIGNS这个存储过程的作用是,向CAMPAIGN表按一定条件取出数据。我怎么循环呢?下边的代码总是报错。
    DECLARE
      PI_SERIALNO VARCHAR2(200);
      MY_CUR sys_refcursor;
      temp vp_campaign%rowtype;
    BEGIN
      PI_SERIALNO := '2003004495';  USP_CA_GETAORHCAMPAIGNS(
        PI_SERIALNO => PI_SERIALNO,
        MY_CUR => MY_CUR
      );
      OPEN MY_CUR;
      LOOP
        fetch MY_CUR into temp;  
        exit when MY_CUR%notfound;  
        DBMS_OUTPUT.PUT_LINE('MY_CUR = ' || temp.analystno);
      END LOOP;
    END;
      

  5.   


    那个在开头不是declare了吗,我又忘了什么吗?
      

  6.   

    DECLARE
      PI_SERIALNO VARCHAR2(200);
      MY_CUR sys_refcursor;
      temp vp_campaign%rowtype;
    BEGIN
      PI_SERIALNO := '2003004495';
     
      USP_CA_GETAORHCAMPAIGNS(
        PI_SERIALNO => PI_SERIALNO,
        MY_CUR => MY_CUR
      );
      --OPEN MY_CUR;已经打开了
      LOOP
        fetch MY_CUR into temp;  
        exit when MY_CUR%notfound;  
        DBMS_OUTPUT.PUT_LINE('MY_CUR = ' || temp.analystno);
      END LOOP;
    END;
      

  7.   


    Error report -
    ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
    ORA-06512: at line 14
    06504. 00000 -  "PL/SQL: Return types of Result Set variables or query do not match"
    *Cause:    Number and/or types of columns in a query does not match declared
               return type of a result set  variable, or declared types of two Result
               Set variables do not match.
    *Action:   Change the program statement or declaration. Verify what query the variable
               actually refers to during execution.请问,这个是什么原因造成的???
      

  8.   


    Error report -
    ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
    ORA-06512: at line 14
    06504. 00000 -  "PL/SQL: Return types of Result Set variables or query do not match"
    *Cause:    Number and/or types of columns in a query does not match declared
               return type of a result set  variable, or declared types of two Result
               Set variables do not match.
    *Action:   Change the program statement or declaration. Verify what query the variable
               actually refers to during execution.请问,这个是什么原因造成的???能不能把你的存储过程贴出来?