2005年07月30日 星期六 23:09
Skipped content of type multipart/alternative-------------- next part -------------- #! /usr/local/bin/python # -*- coding: iso-8859-15 -*- import sys import smtplib import codecs from email.MIMEText import MIMEText from types import * sys.path.append('/home/logix/DCOracle2') import DCOracle2 db = DCOracle2.connect("lmusr/future2 at TMSPROD_PROD") c = db.cursor() sqlstr = "select \ decode(grouping(group_cd),1,'总',decode(grouping(dc_nm),1,group_cd,' ')) group_cd, \ decode(grouping(group_cd),1, '合计',decode(grouping(dc_nm),1,'小计',to_char(dc_nm))) dc_cd, \ to_char(sum(cur_qty_bd_ctv),'FM999,999,999') cur_qty_bd_ctv, \ to_char(sum(cur_qty_sb_ctv),'FM999,999,999') cur_qty_sb_ctv, \ to_char(sum(cur_qty_bd_rac),'FM999,999,999') cur_qty_bd_rac, \ to_char(sum(cur_qty_sb_rac),'FM999,999,999') cur_qty_sb_rac, \ to_char(sum(cur_qty_BD_mwo),'FM999,999,999') cur_qty_BD_mwo, \ to_char(sum(cur_qty_sb_mwo),'FM999,999,999') cur_qty_sb_mwo, \ to_char(sum(cur_qty_bd_wm),'FM999,999,999') cur_qty_bd_wm, \ to_char(sum(cur_qty_sb_wm),'FM999,999,999') cur_qty_sb_wm, \ to_char(sum(cur_qty_bd_ref),'FM999,999,999') cur_qty_bd_ref, \ to_char(sum(cur_qty_sb_ref),'FM999,999,999') cur_qty_sb_ref, \ to_char(sum(cur_qty_bd_dvd),'FM999,999,999') cur_qty_bd_dvd, \ to_char(sum(cur_qty_sb_dvd),'FM999,999,999') cur_qty_sb_dvd, \ to_char(sum(cur_qty_bd_dva),'FM999,999,999') cur_qty_bd_dva, \ to_char(sum(cur_qty_sb_dva),'FM999,999,999') cur_qty_sb_dva, \ to_char(sum(cur_qty_bd_vc),'FM999,999,999') cur_qty_bd_vc, \ to_char(sum(cur_qty_sb_vc),'FM999,999,999') cur_qty_sb_vc, \ to_char(sum(cur_qty_bd_etc),'FM999,999,999') cur_qty_bd_etc, \ to_char(sum(cur_qty_sb_etc),'FM999,999,999') cur_qty_sb_etc, \ to_char(sum(cur_qty_bd_ctv)+sum(cur_qty_bd_rac)+sum(cur_qty_BD_mwo)+ \ sum(cur_qty_bd_wm)+sum(cur_qty_bd_ref)+sum(cur_qty_bd_dvd)+ \ sum(cur_qty_bd_dva)+sum(cur_qty_bd_etc)+sum(cur_qty_bd_vc),'FM999,999,999') toatal_bd, \ to_char(sum(cur_qty_sb_ctv)+sum(cur_qty_sb_rac)+sum(cur_qty_sb_mwo)+ \ sum(cur_qty_sb_wm)+sum(cur_qty_sb_ref)+sum(cur_qty_sb_dvd)+ \ sum(cur_qty_sb_dva)+sum(cur_qty_sb_etc)+sum(cur_qty_sb_vc),'FM999,999,999') toatal_sb \ from \ ( \ select \ CASE WHEN xyz.dc_cd in ('BJZ','XAZ','SYZ','HEZ','JNZ','TJZ') then '华北' \ WHEN xyz.dc_cd in ('SHZ','NJZ','HZZ') then '华东' \ ELSE '华南' end group_cd, \ xyz.dc_cd, \ uvw.dc_nm, \ to_char(sum(cur_qty_bd_ctv),'FM999,999,999') cur_qty_bd_ctv, \ sum(cur_qty_sb_ctv) cur_qty_sb_ctv, \ sum(cur_qty_bd_rac) cur_qty_bd_rac, \ sum(cur_qty_sb_rac) cur_qty_sb_rac, \ sum(cur_qty_BD_mwo) cur_qty_BD_mwo, \ sum(cur_qty_sb_mwo) cur_qty_sb_mwo, \ sum(cur_qty_bd_wm) cur_qty_bd_wm, \ sum(cur_qty_sb_wm) cur_qty_sb_wm, \ sum(cur_qty_bd_ref) cur_qty_bd_ref, \ sum(cur_qty_sb_ref) cur_qty_sb_ref, \ sum(cur_qty_bd_dvd) cur_qty_bd_dvd, \ sum(cur_qty_sb_dvd) cur_qty_sb_dvd, \ sum(cur_qty_bd_dva) cur_qty_bd_dva, \ sum(cur_qty_sb_dva) cur_qty_sb_dva, \ sum(cur_qty_bd_vc) cur_qty_bd_vc, \ sum(cur_qty_sb_vc) cur_qty_sb_vc, \ sum(cur_qty_bd_etc) cur_qty_bd_etc, \ sum(cur_qty_sb_etc) cur_qty_sb_etc \ from \ ( \ select \ zz.dc_cd, \ decode(zz.l_class_cd,'CTV',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_ctv, \ decode(zz.l_class_cd,'CTV',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_ctv, \ decode(zz.l_class_cd,'RAC',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_rac, \ decode(zz.l_class_cd,'RAC',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_rac, \ decode(zz.l_class_cd,'MWO',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_BD_mwo, \ decode(zz.l_class_cd,'MWO',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_mwo, \ decode(zz.l_class_cd,'W/M',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_wm, \ decode(zz.l_class_cd,'W/M',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_wm, \ decode(zz.l_class_cd,'REF',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_ref, \ decode(zz.l_class_cd,'REF',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_ref, \ decode(zz.l_class_cd,'DVD',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_dvd, \ decode(zz.l_class_cd,'DVD',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_dvd, \ decode(zz.l_class_cd,'DVA',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_dva, \ decode(zz.l_class_cd,'DVA',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_dva, \ decode(zz.l_class_cd,'V/C',decode(zz.stock_grade_type,'BD',zz.present_qty,0),0) cur_qty_bd_vc, \ decode(zz.l_class_cd,'V/C',decode(zz.stock_grade_type,'SB',zz.present_qty,0),0) cur_qty_sb_vc , \ case when zz.l_class_cd not in ('CTV','RAC','MWO','W/M','REF','DVD','DVA','V/C') \ then decode(zz.stock_grade_type,'BD',zz.present_qty,0) else 0 end cur_qty_bd_etc, \ case when zz.l_class_cd not in ('CTV','RAC','MWO','W/M','REF','DVD','DVA','V/C') \ then decode(zz.stock_grade_type,'SB',zz.present_qty,0) else 0 end cur_qty_sb_etc \ from ( \ select xx.dc_cd, \ yy.l_class_cd, \ xx.stock_grade_type, \ sum(xx.present_qty) present_qty \ from \ ( \ select mm.dc_cd, \ mm.corp_type, \ mm.stock_owner_type, \ mm.MODEL_CD, \ mm.stock_grade_type, \ mm.sum_begin_mm_qty+nvl(dd.inout_qty,0) present_qty, \ mm.sum_begin_avail_qty_sb + nvl(dd.day_avail_qty_sb,0) avail_qty_sb \ from \ (select a.dc_cd dc_cd, \ a.corp_type corp_type, \ a.stock_owner_type stock_owner_type, \ a.MODEL_CD model_cd, \ a.stock_grade_type, \ sum(a.begin_mm_qty) sum_begin_mm_qty, \ sum(a.begin_mm_qty - a.lm_norm_ord_not_shp_qty - \ a.lm_transfer_ord_not_shp_qty - a.lm_fact_rtn_ord_not_shp_qty - \ nvl(a.lm_svc_rtn_ord_not_shp_qty,0) ) sum_begin_avail_qty_sb \ from tb_ld_monstock a \ where a.STOCK_YM=to_char(sysdate,'YYYYMM') \ group by a.dc_cd , \ a.corp_type , \ a.stock_owner_TYPE , \ a.MODEL_CD, \ a.stock_grade_type \ ) mm, \ (select B.dc_cd dc_cd, \ B.corp_type corp_type, \ B.stock_owner_type stock_owner_type, \ B.MODEL_CD model_cd, \ b.stock_grade_type, \ sum(nvl(b.in_qty,0) - nvl(b.out_qty,0)) inout_qty, \ sum(nvl(b.in_qty,0) - nvl(b.ex_out_qty,0) -nvl(b.ord_qty,0)) day_avail_qty_sb \ from vi_ld_daystock b \ where b.stock_ymd between to_char(sysdate,'YYYYMM')||'01' and to_char(sysdate,'YYYYMMDD') \ group by b.dc_cd , \ b.corp_type , \ b.stock_owner_TYPE , \ b.MODEL_CD, \ b.stock_grade_type \ ) dd \ where mm.dc_cd = dd.dc_cd(+) \ and mm.corp_type = dd.corp_type(+) \ and mm.stock_owner_type = dd.stock_owner_type(+) \ and mm.MODEL_CD=dd.MODEL_CD(+) \ and mm.stock_grade_type = dd.stock_grade_type(+) \ ) xx, \ tb_lm_model yy \ where xx.corp_type = yy.corp_type \ and xx.model_cd = yy.model_cd \ and xx.stock_grade_type in ('BD','SB') \ group by xx.dc_cd, \ yy.l_class_cd , \ xx.stock_grade_type \ ) zz \ ) xyz , \ tb_lm_dc uvw \ where xyz.dc_cd = uvw.dc_cd \ group by xyz.dc_cd ,uvw.dc_nm \ ) wokao \ group by rollup(group_cd,dc_nm)" print "start query" #print sqlstr c.execute(sqlstr) print "Describing test" #print list(c.description) c.arraysize = 20 print "start fetch" r = c.fetchall() #print r mailbody = "
Gr. | 中心 | CTV_BD | CTV_SB | RAC_BD | RAC_SB | " mailbody = mailbody + "WMO_BD | WMO_SB | W/M_BD | W/M_SB | REF_BD | REF_SB | " mailbody = mailbody + "DVD_BD | DVD_SB | DVA_BD | DVA_SB | V/C_SB | V/C_SB | " mailbody = mailbody + "ETC_BD | ETC_SB | TOTAL_BD | TOTAL_SB | " #print r i = 1 print "******************************" print "start outer loop" for x in r: j = 0 if i == 1 : i =0 mailbody = mailbody + "
"+y+" | " else: mailbody = mailbody+""+str(y)+" | " else: if j in (): mailbody = mailbody+ ""+y+" | " else: mailbody = mailbody+""+str(y)+" | " mailbody = mailbody + "
2005年07月30日 星期六 23:15
在 05-7-30,Schopendauer Nietzsche<mosquitoxh at yahoo.com.cn> 写道: > > > hello everyone: > > I write a program using dco2 by python,when i call this program by > shell > > command,it's ok ,when I call this program by cron ,It errs.error > message > > as flows: > > Traceback (most recent call last): > File "/home/logix/batch/sendMail.py", line 14, in ? > db = DCOracle2.connect("lmusr/future2 at TMSPROD_PROD") > File "/home/logix/DCOracle2/DCOracle2/DCOracle2.py", line > 189, in > connect > db = dco2.connect(u, p, dbname) > dco2.DatabaseError: (12154, 'Error while trying to retrieve text for > error ORA-12154') 没有用过oracle,不过感觉是数据库访问错,它已经给出了错误码是"12154",建议你查一查错误码看一看是什么错误。会不会是程序的执行权限的问题。 > > can anyone help me solve this problem? 3ks > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年07月31日 星期日 10:55
another possible reason might be when running script with cron, the environment variable isn't correct set by the cron shell, and it might use another python such the one installed at /usr/bin 在 05-7-30,limodou<limodou at gmail.com> 写道: > 在 05-7-30,Schopendauer Nietzsche<mosquitoxh at yahoo.com.cn> 写道: > > > > > > hello everyone: > > > > I write a program using dco2 by python,when i call this program by > > shell > > > > command,it's ok ,when I call this program by cron ,It errs.error > > message > > > > as flows: > > > > Traceback (most recent call last): > > File "/home/logix/batch/sendMail.py", line 14, in ? > > db = DCOracle2.connect("lmusr/future2 at TMSPROD_PROD") > > File "/home/logix/DCOracle2/DCOracle2/DCOracle2.py", line > > 189, in > > connect > > db = dco2.connect(u, p, dbname) > > dco2.DatabaseError: (12154, 'Error while trying to retrieve text for > > error ORA-12154') > > 没有用过oracle,不过感觉是数据库访问错,它已经给出了错误码是"12154",建议你查一查错误码看一看是什么错误。会不会是程序的执行权限的问题。 > > > > can anyone help me solve this problem? 3ks > > > > > > -- > I like python! > My Donews Blog: http://www.donews.net/limodou > New Google Maillist: http://groups-beta.google.com/group/python-cn > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > >
Zeuux © 2025
京ICP备05028076号