Cause: In a host language program, a FETCH call was issued out of sequence. A successful parse-and-execute call must be issued before a fetch. This can occur if an attempt was made to FETCH from an active set after all records have been fetched. This may be caused by fetching from a SELECT FOR UPDATE cursor after a commit. A PL/SQL cursor loop implicitly does fetches and may also cause this error. Action: Parse and execute a SQL statement before attempting to fetch the data. 

解决方案 »

  1.   

    各位高手,代码如下:在fetch时,出现了错误,进行回滚!!谢谢!!

    exec sql declare REDEM_ORDER_CUROSR cursor for 
    select 
    r.rowid,
    r.fund_id,
    r.org_id,
    nvl(r.SALE_REBATE1,1),
    nvl(MAN_REBATE1,1),
    nvl(MAN_REBATE2,1),
    substr(o.SELL_CUSTOMIZE_FLAG,4,1),
    nvl(f.sale_divide,-9),
    nvl(f.reg_divide,-9),
    nvl(f.fund_divide,-9),
    nvl(f.sale_rebate,-9),
    nvl(f.reg_rebate,-9),
    nvl(f.fund_rebate,-9),
    nvl(f.sale_min,-9),
    nvl(f.reg_min,-9),
    nvl(f.fund_min,-9),
    nvl(f.sale_max,-9),
    nvl(f.reg_max,-9),
    nvl(f.fund_max,-9)
    from redem_order r,
    (
    select fund_id,org_id,acct_type,max(a) sale_divide,max(b) reg_divide ,max(c) fund_divide,max(d) sale_rebate,
            max(e) reg_rebate,max(f) fund_rebate,max(g) sale_min,max(h) reg_min,max(i) fund_min,max(j) sale_max,
            max(k) reg_max,max(l) fund_max
    from
    (
      select fund_id,org_id,acct_type,ITEM_PERCENT a,-9 b ,-9 c,UNIFORM_REBATE d,-9 e,-9 f,
           MIN_REBATE g,-9 h,-9 i,MAX_REBATE j ,-9 k,-9 l
      FROM fund_rebate2
      where business_id=:szredemBusinessId
      and ITEM_CODE=:szsaleDivide
      union all
      select fund_id,org_id,acct_type,-9,ITEM_PERCENT ,-9,-9,UNIFORM_REBATE,-9,-9,
           MIN_REBATE,-9,-9,MAX_REBATE,-9
      FROM fund_rebate2
      where business_id=:szredemBusinessId
      and ITEM_CODE=:szregDivide
      union all
      select fund_id,org_id,acct_type,-9,-9,ITEM_PERCENT ,-9,-9,UNIFORM_REBATE,-9,-9,
           MIN_REBATE,-9,-9,MAX_REBATE
      FROM fund_rebate2
      where business_id=:szredemBusinessId
      and ITEM_CODE=:szfundDivide
    )group  by fund_id,org_id,acct_type
    ) f,org_code o
    where r.fund_id=f.fund_id(+)
    and r.org_id=f.org_id(+)
    and DECODE(SIGN(SUBSTR(r.acct_id,3,1)-5),1,'1','0')=f.acct_type(+)
    and r.org_id=o.org_id
    and r.error_id='0000'
    and r.business_id=:szredemBusinessId;

    exec sql open REDEM_ORDER_CUROSR;
    for(;;)
    {
    exec sql fetch REDEM_ORDER_CUROSR into :stredemOrder;
    if (sqlca.sqlcode==1403) 
    {
    userlog("fetch over!!!");
    break;
    }

    if (sqlca.sqlcode!=0) 
    {
    userlog("fetch error is:[%s]",sqlca.sqlerrm.sqlerrmc);
    exec sql rollback work;
    return;
    }
      

  2.   

    是不是sequence的值溢出了,你把sequence的最大值设定的大一点式式
      

  3.   

    应该不是 sequece 溢出 溢出错误 ora-08004
      

  4.   

    应该不是sequece的问题吧?在这里也没有使用到sequece?还有我的cursor参数已经设置的较大了。
      

  5.   

    用1403判断应该没有错。
    1002错误的原因
    1) Fetching from a cursor after the last row has been retrieved
    and the ORA-1403 error returned.
    2) If the cursor has been opened with the FOR UPDATE clause,
    fetching after a COMMIT has been issued will return the error.
    3) Rebinding any placeholders in the SQL statement, then issuing
    a fetch before reexecuting the statement.
    看前两个都不象,是否第三个原因?