TO:goaha兄
首先让我再一次感谢你;
你的方法在SQL SERVER中能用,但到了DELPHI中就有一个问题了:
var
podjname:string;
sysobjectsQuery.close;
sysobjectsQuery.sql.clear;
sysobjectsQuery.sql.add('select name from sysobjects ');
sysobjectsQuery.sql.add('where (type=''u'')and(substring(name,1,4)=''PODJ'') ');
sysobjectsQuery.prepare;
sysobjectsQuery.open;
podjname:='';
sysobjectsQuery.first;
podjname:=sysobjectsQuery.fieldByName('name').asstring; //**** 在这从错了(下面的代码还不知对不对),说'name'找不到;
//**** 是不是这个字段在DELPHI里是不可见的,要怎样解决呢?
sysobjectsQuery.sql.add('select aa.* into #dj from ( select po号,型号,规格,单价 from '+''+podjname+''+' ( ');
while not(sysobjectsQuery.eof) do
begin
sysobjectsQuery.next;
sysobjectsQuery.sql.add('union select po号,型号,规格,单价 from '+''+podjname+''+' ');
end;
sysobjectsQuery.sql.add(' )aa ');
sysobjectsQuery.sql.add('select a1.po号,a1型号,a1规格,b1.单价,(a1.数量*b1.单价) as 合计 ');
sysobjectsQuery.sql.add('from [kf_hcgl].[dbo].ckdj200011 a1 inner join #dj b1');
sysobjectsQuery.sql.add('drop table #dj');
sysobjectsQuery.open;
请求帮忙解决出错处,感谢不尽!