AdoQuery控件为何不能使用递归查询? 在线等!(100)

  • 主题发起人 longerhe
  • 开始时间
L

longerhe

Unregistered / Unconfirmed
GUEST, unregistred user!
with AdoQuery1do begin close; sql.clear; sql.text:='with www (work_order,lot_no,Pick_date,user_id,create_time,status) as '+ '( '+ 'select work_order,lot_no,Pick_date,user_id,create_time,status '+ 'from set_pick '+ 'where 1=1 '; if sLotNO<>'' then sql.text:=sql.text+ 'and lot_no='+Quotedstr(sLotNO); if sWO<>'' then sql.text:=sql.text+ 'and work_order='+Quotedstr(sWo); sql.text:=sql.text+ 'union all '+ 'select b.work_order,b.lot_no,b.Pick_date,b.user_id,b.create_time,b.status '+ 'from set_pick b join www on b.work_order=left(www.lot_no,13) '+ ') '+ 'select * from www group by work_order,lot_no,Pick_date,user_id,create_time,status '; open; end;
 
L

longerhe

Unregistered / Unconfirmed
GUEST, unregistred user!
递归查询语句在查询分析器中执行OK,但是在程序中显示with 附近有语法错误.
 
C

cnhotel

Unregistered / Unconfirmed
GUEST, unregistred user!
楼主这样还不如写个存储过程,调用方便。
 
L

longerhe

Unregistered / Unconfirmed
GUEST, unregistred user!
我也考虑这样过,但是写个procedure,在Procedure中实现递归查询,程序中还是得不到我需要的结果.
 
Y

yeskert1

Unregistered / Unconfirmed
GUEST, unregistred user!
楼主确定你的adoquery使用的引擎和你的查询分析器使用的引擎是一样的吗?delphi的BDE套件使用了本地语法解析,其他的都没有使用本地语法解析,这就是说,ado控件,负责解析语法的是背后的引擎。
 
顶部