real channelold
real channelnew
char shortaddrold
char shortaddrnew
real msgfmt
real sigtype
real rate
real model
real station
real status
char atdpno
char sno
char opdpno
char opemno
char saledpno
char saleemno
char uno
int month,freemonth
datetime opdate,saledate
long i,j
int count
dw_1.Dataobject="d_shortaddrstatus"//状态表
dw_1.settransobject(sqlca)
j=dw_1.retrieve()
if j>0 then
for i=1 to j
status=dw_1.getitemnumber(i,"status")
if status=5 then
channelold=dw_1.getitemnumber(i,"channel")
shortaddrold=dw_1.getitemstring(i,"shortaddr")
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in(select to_number(shortaddr)+channel*10000000
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in(
select to_number(shortaddr)+channel*10000000
from k_bpmatched
where status=4));
select msgfmat,sigtype,rate,model,sno,saledate,saledpno,saleemno,uno,station
into :msgfmt,:sigtype,:rate,:model,:sno,:saledate,:saledpno,:saleemno,:uno,:station
from b_user
where shortaddr=:shortaddrnew and channel =:channelnew;
select month,freemonth
into :month,:freemonth
from b_userdetail
where uno=:uno;
st_1.text = "加入用户号:" + uno + " " + " 第 " + string(i)
insert into k_bpmatched(net,channel,msgfmt,sigtype,rate,model,atdpno,sno,shortaddr,opdpno,opdate,opemno,status,alcdate,alcdpno,saledate,saleemno,uno,saledpno,station,month,freemonth)
values(:net,:channelnew,:msgfmt,:sigtype,:rate,:model,:atdpno,:sno,:shortaddrnew,:opdpno,:opdate,:opemno,4,:saledate,:saledpno,:saledate,:saleemno,:uno,:saledpno,:station,:month,:freemonth);
if sqlca.sqlcode=-1 then
MessageBOx("连接错误","数据源数据库连接失败,错误代码为:" + sqlca.sqlerrtext)
return
end if
count++
if count>10 then
commit;
count=0
end if
end if
next
end if
messagebox("提示","数据导入成功")
commit;
10 个解决方案
#1
晕了...
程序从表面上看没有问题,那个sql语句太可怕了,想别的办法吧。
程序从表面上看没有问题,那个sql语句太可怕了,想别的办法吧。
#2
你想干嘛,分开不行吗,从来没见人这样写,过几天你自己还能看懂吗?
#3
怎么分开写?我本来想把那些数据存成一个临时表。可是怎么也建不了表
#4
实在不行,你可以用DATASTORE把数据取到本地再处理,也好过这么写。
#5
真不怕麻烦
#6
数据库设计不合理。
#7
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
||
\/
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
||
\/
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
#8
尽量在SQL中不要用 in, not in 等,换成连接运算看看,效率会高些
#9
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
改为:
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
最好你想办法将*10000000去掉
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
改为:
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
最好你想办法将*10000000去掉
#10
拜托,你不要用这么复杂的语句,用个存储过程,分几个临时表速度会有明显的提升,不要告诉我你的数据库不支持存储过程呀
#1
晕了...
程序从表面上看没有问题,那个sql语句太可怕了,想别的办法吧。
程序从表面上看没有问题,那个sql语句太可怕了,想别的办法吧。
#2
你想干嘛,分开不行吗,从来没见人这样写,过几天你自己还能看懂吗?
#3
怎么分开写?我本来想把那些数据存成一个临时表。可是怎么也建不了表
#4
实在不行,你可以用DATASTORE把数据取到本地再处理,也好过这么写。
#5
真不怕麻烦
#6
数据库设计不合理。
#7
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
||
\/
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
||
\/
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
#8
尽量在SQL中不要用 in, not in 等,换成连接运算看看,效率会高些
#9
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
改为:
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
最好你想办法将*10000000去掉
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 in
(select to_number(shortaddr)+channel*10000000 from k_shortaddrstatus where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4));
改为:
select shortaddr,channel,net,opdpno,opdate,opemno
into :shortaddrnew,:channelnew,:net,:opdpno,:opdate,:opemno
from k_shortaddrstatus
where to_number(shortaddr)+channel*10000000 not in
( select to_number(shortaddr)+channel*10000000 from k_bpmatched where status=4);
最好你想办法将*10000000去掉
#10
拜托,你不要用这么复杂的语句,用个存储过程,分几个临时表速度会有明显的提升,不要告诉我你的数据库不支持存储过程呀