我是将Oracle的数据上传到SQLserver,看有没有对你有帮助。
SET SAFETY OFF
release ALL
CLOSE ALL
SET DATE TO long
SET CENTURY on
SET HOURS TO 24
CLOSE DATABASES
OPEN DATABASE main.dbc
SET SAFETY OFF
SET CENTURY on
SET DATE
SHORT
IF USED('PAA1')
SELECT paa1
USE
ENDIF
IF USED('PAA')
SELECT paa
USE
ENDIF
IF USED('PAA2')
SELECT paa2
USE
ENDIF
IF USED('PAA3')
SELECT paa3
USE
ENDIF
IF USED('PAA5')
SELECT paa5
USE
ENDIF
IF USED('PAA6')
SELECT paa6
USE
ENDIF
IF USED('PAA7')
SELECT paa7
USE
ENDIF
DATE1=ALLTRIM(dtoc((THISFORM.TEXT1.Value)))
DATE2=ALLTRIM(dtoc((THISFORM.TEXT1.Value-1)))
CmessageText='正在处理数据,请耐心等待!'
h1=SQLCONNECT("orcl1")
IF h1<0
MESSAGEBOX('网络连接orcl未通,请检查线路!',0+64,'提示')
RETURN
ENDIF
h2=SQLCONNECT("yun")
IF h2<0
MESSAGEBOX('网络连接yun未通,请检查线路!',0+64,'提示')
RETURN
ENDIF
Pgh="select t.reg_number,t.reg_yb,t.reg_ybcardno,t.reg_id,sii_idcard,sii_sickman_code,sii_name,sii_birthday,sii_sex "
Pgh1=" from ad_sickman_info a right join ad_register t on sii_sickman_code = t.reg_id "
Pgh2=" where t.reg_number in (select distinct prm_number from ad_prescription_memo where to_char(prm_getmoney_date,'yyyy-mm-dd')='&date1' "
Pgh3=" and (prm_getmoney_date is not null) and (scrq is null))"
Zgh="&Pgh"+" "+"&Pgh1"+" "+"&Pgh2"+" "+"&Pgh3"
abb=SQLEXE(h1,Zgh,'hhh1')
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO paa7
SELECT 0
USE PAA7 ALIAS PAA7
SELECT paa7
IF RECCOUNT()=0
SQLDISCONNECT(h1)
SQLDISCONNECT(h2)
CLOSE ALL
CLOSE DATABASES
Release ALL
DELETE FILE paa7.dbf
RETURN
ELSE
GO top
DO WHILE NOT EOF()
IF reg_yb='0'
pkh=''
ELSE
IF reg_yb='1' AND NOT ISNULL(reg_ybcard)
pcd=LEN(ALLTRIM(reg_ybcard))
IF pcd <15
pkh=SUBSTR(reg_ybcard,1,5)
ELSE
IF (pcd >15) and (pcd <=22)
pkh=SUBSTR(reg_ybcard,1,15)
ELSE
pkh=SUBSTR(reg_ybcard,1,18)
ENDIF
endif
REPLACE
sii_idcard WITH '',reg_ybcard WITH pkh
ENDIF
ENDIF
SKIP
enddo
SELECT paa7
INDEX on sii_sickma to sy
**科室库**
abb=SQLEXEC(h1,"select t.*, t.rowid from as_department t",'hhh2')
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO PAA2
SELECT 0
USE PAA2 ALIAS PAA2
INDEX on dep_code TO sy3
**医生库**
abb=SQLEXEC(h1,"select t.*, t.rowid from as_employee t",'hhh3')
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO PAA3
SELECT 0
USE PAA3 ALIAS PAA3
*yaopin*
abb=SQLEXEC(h1,"select t.med_code,t.med_yl from as_med_dict t",'hhh10')
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO Paa10
SELECT 0
USE paa10 ALIAS paa10
***是否输液口服
abb=SQLEXEC(h1,"select t.aek_code,t.aek_name from as_advice_exe_kind t ",'hhh11')
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO Paa11
SELECT 0
USE paa11 ALIAS paa11
YU1="select prm_jl,prm_pres_num,prm_mecode,prm_id,prm_medname,prm_model,prm_getmoney_date,prm_number,prm_sell_price,prm_countnum-prm_exitnum,prm_if_medexa,bs,prm_dep2,prm_doccode,scrq,prm_aday_degree,prm_adegree_num,prm_zyyf,prm_memo,prm_sunit
"
YU2=",prm_money_kind from ad_prescription_memo where to_char(prm_getmoney_date,'yyyy-mm-dd')='&date1' "
YU3=" and (prm_getmoney_date is not null) and (scrq is null)"
YU="&yu1"+" "+"&Yu2"+" "+"&Yu3"
abb=SQLEXEC(h1,yu)
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
COPY TO paa1
SELECT 0
USE paa1
ALIAS paa1
SELECT paa1
SET FILTER TO subs(alltrim(prm_money_),1,4)='0114'
REPLACE ALL prm_if_med WITH '1'
SET FILTER to
SELECT a.prm_jl,a.prm_pres_n,a.prm_sunit,a.prm_id,a.prm_mednam,a.prm_model,a.prm_number,a.prm_getmon,a.prm_sell_p,a.prm_countn,b.dep_name,c.emp_name,a.prm_if_med,a.bs,a.scrq,a.prm_aday_d,a.prm_adegre,a.prm_zyyf,d.reg_yb,d.reg_ybcard,d.sii_idcard,d.sii_name,e.med_yl,f.aek_name FROM paa1 a
INNER JOIN
paa2 b ON a.prm_dep2=b.dep_code INNER JOIN paa3 c ON
a.prm_doccod =c.emp_code left JOIN paa7 d ON
a.prm_number=d.reg_number LEFT JOIN paa10 e ON a.prm_mecode=e.med_code LEFT JOIN paa11 f ON a.prm_memo=f.aek_code
INTO TABLE paa5
SELECT paa5
GO top
SET FILTER TO ISNULL(scrq) AND (prm_countn <>0)
DO WHILE NOT EOF()
Pcfh=prm_number
Pmc=prm_mednam
pys=emp_name
psl=prm_countn
pjl=prm_jl
pdw=prm_sunit
pxm1=sii_name
psfrq=TTOC(prm_getmon)
DO CASE
CASE
ALLTRIM(prm_if_med)='0'
pcflb='3'
case ALLTRIM(prm_if_med)='1'
pcflb='1'
otherwise
pcflb=''
ENDCASE
IF reg_yb='0'
ppkh=''
ELSE
IF ISNULL(reg_ybcard)
ppkh=ALLTRIM(sii_idcard)
ELSE
ppkh=ALLTRIM(REG_YBCARD)
ENDIF
ENDIF
IF ISNULL(pdw)
pzs='数量:'+ALLTRIM(str(psl))
ELSE
pzs='数量:'+ALLTRIM(str(psl))+ALLTRIM(pdw)
endif
pnr='用法:'+ALLTRIM(prm_adegre)+' '+ALLTRIM(med_yl)+' '+ALLTRIM(aek_name)
pnr2='每天'+ALLTRIM(prm_aday_d)+'次'
pnr3=ALLTRIM(prm_zyyf)
IF prm_if_med ='2'
pznr=pzs
ELSE
IF prm_if_med ='0'
IF ISNULL(prm_zyyf)
pznr=pzs+', '+pnr+','+pnr2+''
ELSE
pznr='数量:'+ALLTRIM(pjl)+'× '+ALLTRIM(STR(prm_pres_n))+'剂,'+pnr3
endif
ELSE
pznr=''
ENDIF
endif
prq=DTOC(DATE())
pzf="insert into Health_Data([Inspect_ID] ,[UserID] ,[InTheDate],[Inspect_category] ,[Inspect_name] ,[Inspect_part],[Inspect_content],[Chronic_mark] ,[Docter] ,cardid,name)"
pzf2="values('&pcfh','','&psfrq','&pcflb',"
pzf3="'&pmc','',"
pzf4="'&pznr',"
pzf5="0,'&pys','&ppkh','&pxm1')"
zzf="&pzf"+" "+"&pzf2"+"&pzf3"+"&pzf4"+"&pzf5"
SQLEXEC(h2,zzf)
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
SQLEXEC(h1,"update ad_prescription_memo set scrq='&prq' where prm_number='&pcfh'")
wait window CmessageText at srow()/2,(scols()-len(CmessageText))/2
nowait
SKIP
enddo
ENDIF
SQLDISCONNECT(h1)
SQLDISCONNECT(h2)
CLOSE ALL
CLOSE DATABASES
release ALL
DELETE FILE paa1.dbf
DELETE FILE paa2.dbf
DELETE FILE paa7.dbf
DELETE FILE paa5.dbf
DELETE FILE paa10.dbf
DELETE FILE paa11.dbf
DELETE FILE paa3.dbf
DELETE FILE paa3.fpt
DELETE FILE paa2.fpt
DELETE FILE sy3.idx
DELETE FILE sy.idx
[此贴子已经被作者于2016-10-24 11:17编辑过]