江湖救急,在线等候!!
我用System.Data.OracleClient接口,写如下语句:
strsum ="select dl,tzdbh,jye,jyf,dzqk,fcrq,jfjg_mc from ";
strsum+=" ( ";
strsum+=" (select distinct substr(dlbm,1,2) dl, mp.tzdbh,mp.jye,mp.jyf,mp.dzqk,mp.fcrq,mp.jfjg_mc,mp.remark from vinfo_tradesum mp,marketplace ";
strsum+=" where exists (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd from marketplace group by tzdbh having count(distinct substr(dlbm,1,2))=1) ";
strsum+=" where tzdbh=mp.tzdbh) and mp.tzdbh=marketplace.tzdbh) ";
strsum+=" union ";
strsum+=" (select distinct 'xx' dl, mp.tzdbh,mp.jye,mp.jyf,mp.dzqk,mp.fcrq,mp.jfjg_mc,mp.remark from vinfo_tradesum mp ";
strsum+=" where exists (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd from marketplace group by tzdbh having count(distinct substr(dlbm,1,2))>1) ";
strsum+=" where tzdbh=mp.tzdbh) ";
strsum+=" ) ";
strsum+=" union ";
strsum+=" (select distinct substr(dlbm,1,2) dl, buy.tzdbh,buy.jye,buy.jyf ,buy.dzqk,buy.fcrq,buy.jfjg_mc,buy.remark from vinfo_tradesum buy,buyer ";
strsum+=" where exists (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd from buyer group by tzdbh having count(distinct substr(dlbm,1,2))=1) ";
strsum+=" where tzdbh=buy.tzdbh) and buy.tzdbh=buyer.tzdbh) ";
strsum+=" union ";
strsum+=" (select distinct 'xx' dl, buy.tzdbh,buy.jye,buy.jyf ,buy.dzqk,buy.fcrq,buy.jfjg_mc ,buy.remark from vinfo_tradesum buy ";
strsum+=" where exists (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd from buyer group by tzdbh having count(distinct substr(dlbm,1,2))>1) ";
strsum+=" where tzdbh=buy.tzdbh)";
strsum+=" ) ";
strsum+=" ) ";
strsum+=" where (dl between '01' and '25')";
在asp.net(c#)中却没有得到一条记录,又没报错,而在sql_plus经过换行断句等编辑工整后通过,得到很多结果记录,这是为何?请高人指点!!
小弟在此多谢了!!!
问题点数:0、回复次数:5Top
1 楼acewang(龍芯*Inside!)回复于 2003-11-03 15:00:48 得分 0
Reponse.Write()出来看看是不是和你sql_plus中的一致Top
2 楼Kanderliu(卖男孩的小女孩)回复于 2003-11-03 15:05:14 得分 0
这样的问题很难查起;可以给你个建议:
就是在sql_plus中通过之后,拷贝SQL语句到你的程序中,然后在两头加"",注意,要流出空格.
例如:
string = "" +
"SELECT * " +
"FROM tb_projects " +
"WHERE (ProjID = 12) " +
"ORDER BY ProjCode ";
Top
3 楼killu(深闺幽香)回复于 2003-11-03 15:06:49 得分 0
这么复杂的SQL,佩服Top
4 楼nper()回复于 2003-11-03 15:14:18 得分 0
语句一样,只是没有换行回车,我特意在程序加入"\n\r"后,仍是如此。粘到sqlplus后为如下情形:
SQL> select dl,tzdbh,jye,jyf,dzqk,fcrq,jfjg_mc from ( ( select distinct substr(dlbm,1,2) dl, mp.tzd
bh,mp.jye,mp.jyf,mp.dzqk,mp.fcrq,mp.jfjg_mc,mp.remark from vinfo_tradesum mp,marketplace where exist
s (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd from marketplace group by tzd
bh having count(distinct substr(dlbm,1,2))=1) where tzdbh=mp.tzdbh) and mp.tzdbh=marketplace.tzdbh)
union (select distinct 'xx' dl, mp.tzdbh,mp.jye,mp.jyf,mp.dzqk,mp.fcrq,mp.jfjg_mc,mp.remark from vin
fo_tradesum mp where exists (select tzdbh from (select tzdbh,count(distinct substr(dlbm,1,2)) dd fro
m marketplace group by tzdbh having count(distinct substr(dlbm,1,2))>1) where tzdbh=mp.tzdbh)) union
(select distinct substr(dlbm,1,2) dl, buy.tzdbh,buy.jye,buy.jyf ,buy.dzqk,buy.fcrq,buy.jfjg_mc,buy.
remark from vinfo_tradesum buy,buyer where exists (select tzdbh from (select tzdbh,count(distinct su
bstr(dlbm,1,2)) dd from buyer group by tzdbh having count(distinct substr(dlbm,1,2))=1) where tzdbh=
buy.tzdbh) and buy.tzdbh=buyer.tzdbh) union (select distinct 'xx' dl, buy.tzdbh,buy.jye,buy.jyf ,buy
.dzqk,buy.fcrq,buy.jfjg_mc ,buy.remark from vinfo_tradesum buy where exists (select tzdbh from (sele
ct tzdbh,count(distinct substr(dlbm,1,2)) dd from buyer group by tzdbh having count(distinct substr(
dlbm,1,2))>1) where tzdbh=buy.tzdbh)) ) ;
2Top
5 楼nper()回复于 2003-11-03 15:27:06 得分 0
按Kanderliu(凯影)兄试过,还是如此。咳......Top




