我在使用存储过程的时候,使用了下面的语句:
where field1= case 
when @a1='' then field1
else @a1 end
后,在DELPHI中使用存储过程这个数据源来打开数据库时,就会有提示List index out of bounds(1).不知道这里有没有人知道这是怎么回事,关且在括号中的数字可能是如果正确返回时的记录条数!
请帮忙!

解决方案 »

  1.   

    1 你可以直接写field1=IsNUll(@a, field1)
    2 不太懂你的意思,为什么会在where利用这样的语句
    3 语句应该没有语法错误,可能是你其他的地方引用错误,把代码贴出来吧
      

  2.   

    赞同 firetoucher(风焱)的看法
      

  3.   

    存计过程如下:-------------------------------------t4.fdate >=isnull(@BEGDATE,t4.fdate) and t4.fdate <= isnull(@ENDDATE,t4.fdate) 
    --销售单号 
    -- and t4.fbillno >=isnull( @BILLNOS,t4.fbillno) and t4.fbillno <= isnull(@BILLNOE,t4.fbillno) 
    and t4.fbillno >= case 
    when @BILLNOS ='' THEN t4.fbillno 
    when @BILLNOS is null THEN t4.fbillno 
    when @BILLNOS = 'all' THEN '0' else @BILLNOS end 
    and t4.fbillno <= case 
    when @BILLNOE ='' THEN t4.fbillno 
    when @BILLNOE is null THEN t4.fbillno 
    when @BILLNOE = 'all' THEN 'ZZZZZZZZZZ' 
    else @BILLNOE end 
    --客户税纳税号 
    and t1.ftaxnum = case when 
    @SWDJH ='' then t1.ftaxnum 
    when @SWDJH is null then t1.ftaxnum 
    when @SWDJH='all' then t1.ftaxnum 
    else @SWDJH end 
    --客户名称 
    and t1.fname= case when 
    @CLIENTN ='' then t1.fname 
    when @CLIENTN is null then t1.fname 
    when @CLIENTN = 'all' then t1.fname 
    else @CLIENTN end
    还请各位帮忙!----------------------重分答谢!---------------
      

  4.   

    那只是WHERE 字句的后半段,前面的SELECT 子句没有抄下来!
      

  5.   

    赞同 firetoucher(风焱)的看法
      

  6.   

    其实这并不是因为数组从第几个下标开始的问题,下标为[0]的参数其实是一个返回值,我们不用给它赋值,但上面的问题我也有遇过,最后是我自己解觉的,兄弟们不妨试一下!
    在你给参数赋值的时候不要使用数组的下标,而直接使用StoredProc的ParamsByName()这个属性来给参数赋值,这样就不会引起上面的问题!
      

  7.   

    单独执行存储过程,看有没有错;
    我觉得应该是delphi中调用部分的错,从存储过程中看不出有什么问题。
      

  8.   

    好像是越界了。看看是不是SQL语法有问题。