with aq3 do
  begin
    close;
    sql.Clear;
    sql.Add('select studentno,studentname into #temp from student where classno=:p1');
    parameters.ParamByName('p1').Value:='2001';
    aq3.ExecSQL;
    showmessage(aq3.SQL.Text);
    close;
    sql.Clear;
    sql.Add('select * from #temp');
    open;
  end;
----------------------------------------------------------
以上是代码;当我没有where字句的时候是可以的.
但是有where字句的时候不能生成局部临时表,能生成全局临时表和不带#的表.
真是弄不懂borand了..到底是什么问题啊

解决方案 »

  1.   

    如果以上代码的 #temp 改成##temp 或者 temp 就是可以的正常运行.
    但是如果是#temp而且没有where 子句也可以..
    这种莫明奇妙的问题产生了..晕啊..
    各位帮我看看啊.
      

  2.   


    var p1:string;.......with aq3 do
      begin
        p1:=inttostr('2001')
        close;
        sql.Clear;
        sql.Add('select studentno,studentname into #temp'+
        ' from student'+
        ' where classno='''+p1+'''');   // p1为string类型;
        aq3.ExecSQL;
        showmessage(aq3.SQL.Text);
        close;
        sql.Clear;
        sql.Add('select * from #temp');
        open;
      end;
      

  3.   

    回复人: metro() ( ) 信誉:99 
    好像还是有问题啊.
    无法建立#temp.........
      

  4.   

    回复人: nhdj(柳柳荷叶清清水) ( ) 信誉:109 
    关键是不行啊.我创建后说无法找到临时表#temp
    报错是在select 语句里面出现.
    我估计是原先的那个生成#temp的语句没有起作用啊.
    我都调试了很久了.
      

  5.   

    {...}
    Parameters.Clear;
    Parameters.AddParameter.Name := 'p1';   //要加参数名定義
    parameters.ParamByName('p1').Value:='2001';
      

  6.   

    回复人: cronuz(cronus) ( ) 信誉:100 
    不行.还是一样的啊.
    还是无法创建表#temp
      

  7.   

    我估计是不是哪个adoquery的属性要设置一下.但是不知道要设置哪一个啊.
      

  8.   

    奇怪就奇怪在如果用##temp或者temp或者没有where字句就可以
      

  9.   

    XDJM帮个忙啊。。
    有没有出现过这种问题啊