query.sql.add('select * from bsn where areacode="G" and status="1" and rownum<=10')提示说列不合法,改成query.sql.add('select * from bsn where areacode=G and status=1 and rownum<=10')
不提示错误!但是areacode,status 是字符型的啊,各位大虾,能告诉我怎么解决吗?

解决方案 »

  1.   

    query.sql.add('select * from bsn where areacode="G" and status="1" and rownum<=10') 这种用双引号的语句我使作时有时会合法有时不会合法改为这样吧
    query.sql.add('select * from bsn where areacode='+''''+'G'+''''+' and status='+''''+'1'+''''+' and rownum<=10')
      

  2.   

    Query1.SQL.Add('select * from bsn where areacode=''G'' and status=''1'' and rownum<=10')
      

  3.   

    谢谢各位,但是有没有其他方法了,当然这种方法我执行是正确的!
    你看
       Sql.Add('select msisdn,cusid,usrid');
       Sql.Add('from bsn_user_cdma');
       Sql.Add('where areacode='+''''+'G'+''''+'and status='+''''+'1'+'''');
       Sql.Add('and usertype='+''''+'0'+'''');
       Sql.Add('and bsn_saleset not in ('+''''+'ZC01'+''''+','+''''+'ZC02'+''''+')');
       Sql.Add('and areacode='+''''+'G'+'''');在not in 里如果还有2、3个,那实在太长了啊,呵呵!
      

  4.   

    你可以先定义一string 变量
    把这个变量赋值 如:var sqlst:string
    sqlst:='select * from bsn where areacode=''G'' and status=''1'' and rownum<=10';
    Sql.Add(sqlst);
      

  5.   

    可用QuotedStr函数转换成字符串