操作描述:excel2007 中使用vba 操纵oracle 
sql = "select max(operatorid)+1 newoper from ac_operatorrole"
rs.Open sql, conn
newOper = rs("newoper")环境描述1:excel 2010,oracle10g,客户端oralce10g,单数据库
          此环境执行无错误
环境描述2:excel2007 ,oracle10g,客户端oracle9i,集群数据库错误描述:rs("newoper")报错,错误是由于没有执行 sql,也就没有了结果集错误分析:1. 不包含max的sql可以正常执行,原因不是集群导致
          2. 怀疑是excel版本,或者oracle客户端版本导致,还未测试
请有过类似问题经验的高手不吝赐教,有自己想法的兄弟姐妹也发表下意见,相信集体的力量,谢过先

解决方案 »

  1.   

    你是说如果你的sql里面不包含max函数就可以在指定环境下运行通过?这个会不会是你的版本支持有关系呢?
      

  2.   

    有 max 的sql 就执行不了,我也怀疑是环境问题,现在还没有验证
      

  3.   

    你把客户端改成10g看看环境描述2:excel2007 ,oracle10g,客户端oracle9i,集群数据库因为你变了excle和oracle的版本不方便测试,你把数据库这头统一然后再说
      

  4.   

    sql = "select max(operatorid)+1 newoper from ac_operatorrole"
    改成
    sql = "select max(operatorid)+1,newoper from ac_operatorrole"
      

  5.   

    '要ac_operatorrole考虑没有记录的情况
    sql = "select max(operatorid) as newoper from ac_operatorrole"
    rs.Open sql, conn
    if rs.recordount=0 then
        newOper=1
    else
        if not isnull(rs!newoper) then
            newOper=rs!newoper + 1
        else
            newOper=1
        end if
    end if
      

  6.   

    '要ac_operatorrole考虑没有记录的情况
    sql = "select max(operatorid) as newoper from ac_operatorrole"
    rs.Open sql, conn
    if rs.recordount=0 then
        newOper=1
    else
        if not isnull(rs!newoper) then
            newOper=rs!newoper + 1
        else
            newOper=1
        end if
    end if
      

  7.   

    '要ac_operatorrole考虑没有记录的情况
    sql = "select max(operatorid) as newoper from ac_operatorrole"
    rs.Open sql, conn
    if rs.recordount=0 then
        newOper=1
    else
        if not isnull(rs!newoper) then
            newOper=rs!newoper + 1
        else
            newOper=1
        end if
    end if
      

  8.   

    谢谢各位回答,问题已解决。
    解决描述:环境问题,客户端改成oracle10g ,问题解决