在adoquery中用union all联合2个select句子,出错!

chinasea 2005-03-04 03:32:11
出现commandtext does not return a result set
这个select肯定是正确的,已在sqlplus中通过。
我在adoquery的sql属性中写的select,把active设置为true,就出错。
adoquery 是否可以执行union 操作。
急,查过以前的贴子,也没找到办法。
...全文
148 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinasea 2005-03-04
  • 打赏
  • 举报
回复
恩,送分
DebugXP 2005-03-04
  • 打赏
  • 举报
回复
oracle的问题,说不清。
chinasea 2005-03-04
  • 打赏
  • 举报
回复
OK
多谢 DebugXP(NULL)
不过为什么这样就行了呢?
是不是这样adoquery就认为是一条sql了?
DebugXP 2005-03-04
  • 打赏
  • 举报
回复
这样可以不?
select * from (
(select t.decl_no,t.process_id ,t.next_flow_node ,t.x_cert_style_code ,'N' type from xc_proc_active t where t.flow_end_flag='N' and t.next_flow_node='0501' and t.x_cert_style_code='253')
union all
(select t.decl_no ,t.process_id ,t.next_flow_node ,t.x_cert_style_code ,c.print_ver type from xc_proc_active t,t_cert_use c where t.flow_end_flag='N' and (t.next_flow_node='0504' or t.next_flow_node='0505' or t.next_flow_node='0506') and t.x_cert_style_code='253' and t.decl_no=c.print_decl_no and c.print_ver='TT')
) as tempTable
yiyideyi 2005-03-04
  • 打赏
  • 举报
回复
你把那两个字段的别名设成一样试试
chinasea 2005-03-04
  • 打赏
  • 举报
回复
老兄,我不是说了吗,sqlplus下都通过了呀!!!当然是一样的了!!
yiyideyi 2005-03-04
  • 打赏
  • 举报
回复
你的Ntype和print_vertype的数据类型是一样的吗?如果不是的话就没办法union
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
见议用Store Procedure,返回数据集
chinasea 2005-03-04
  • 打赏
  • 举报
回复
晕呀,有没有什么办法呀
chinasea 2005-03-04
  • 打赏
  • 举报
回复

不行呀,我换行了

代码如下:
(select t.decl_no,t.process_id ,t.next_flow_node ,t.x_cert_style_code ,'N' type from xc_proc_active t where t.flow_end_flag='N' and t.next_flow_node='0501' and t.x_cert_style_code='253')
union all
(select t.decl_no ,t.process_id ,t.next_flow_node ,t.x_cert_style_code ,c.print_ver type from xc_proc_active t,t_cert_use c where t.flow_end_flag='N' and (t.next_flow_node='0504' or t.next_flow_node='0505' or t.next_flow_node='0506') and t.x_cert_style_code='253' and t.decl_no=c.print_decl_no and c.print_ver='TT')

sqlplus中执行正常
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
检查一下符号,适当的时候换行
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
请检查一下你的SQL语句
------------------------------------小弟SQL SERVER测试 ok
select * from t_type
union all
select 2,'乐我'
chinasea 2005-03-04
  • 打赏
  • 举报
回复
当然OK呀
开始我没有使用union都是好的
后来加了union all 就不行了
我的adoconnection:

Provider=MSDAORA.1;Password=usrpwd;User ID=usrname;Data Source=jihs;Extended Properties="plRSet=1"
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
你的Adoconnection是否是测试OK.

chinasea 2005-03-04
  • 打赏
  • 举报
回复
是oracle,我已经说了,在sqlplus中执行正常呀

哪你说如何设置adoconnection?
chinaandys 2005-03-04
  • 打赏
  • 举报
回复


如果是SQL SERVER把你的SQL语句放到查询分析器中执行一下就知道了
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
不是adoquery支不支持union 而是你的adoconnection连接的数据源是否支不支持.它只是起到一个传递
SQL串和返回数据集的作用。

检查一下
1.你的连接(adoconnection)
2.SQL角本
zengskywater007 2005-03-04
  • 打赏
  • 举报
回复
不可以这样做的,在sql中建立一个存储过程吧,

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧