如何将数据库里的数据,用存储过程实现将用户的帐单数据文件生到指定的目录下。
要求文本格式:
1.文本格式,文件名格式为:[email protected]帐单(很多用户,文件名是生成动态的)
2.如不用存储过程,如何用程序来实现(JAVA,C++)以下是我写过程CREATE OR REPLACE PROCEDURE p_net_postinfo(
--v_acyid in varchar2,
v_msisdn IN NUMBER,
v_resultcode OUT NUMBER,
v_resultinfo OUT VARCHAR2)
-----------------------------------------------------------------------
-- PROCEDURE : p_net_postinfo
-- Description: 邮寄清单及帐单
-- Author : xiezhibo
-- DATE : 2006/05/15
-- Editor : editplus
-----------------------------------------------------------------------IS
--统计相关资料
iv_date_s DATE; --保存执行起始时间
iv_date_e DATE; --保存执行终止时间
iv_exectime NUMBER(12,2); --保存执行多长时间
iv_msisdn varchar2(12); --保存用户的号码
iv_yy varchar2(5000);
iv_post_content varchar2(10); TYPE t_Cursor IS REF CURSOR;
iv_tcursor t_Cursor;
--iv_tcursor2 t_Cursor;
--iv_tcursor3 t_Cursor;BEGIN
v_resultinfo := '生成邮寄帐单清单完成!';
v_resultcode:=-1; iv_exectime:=0;
iv_date_s:=SYSDATE;
--取到用户的手机号码
open iv_tcursor for select distinct msisdn
from tf_f_postinfo@to_crm1 b,tm_sd_postqdbill a --关联到 @CRM1库上/CRM2上
where b.id=a.user_id
and b.post_tag='1'
and b.post_typeset='2'
and b.end_date> sysdate;
LOOP
fetch iv_tcursor into iv_msisdn;
EXIT WHEN iv_tcursor%NOTFOUND;
begin
select post_content into iv_post_content from tf_f_postinfo@to_crm1 a where a.id=iv_msisdn;
EXCEPTION
WHEN OTHERS THEN
v_resultinfo:='p_net_postinfo执行发生未知异常错误'||SQLERRM;
v_resultcode:=-1;
RETURN;
--语音清单;
SELECT a.other_party || '-' || a.start_time || '-' || a.call_type || '-' || a.long_type || '-' ||
a.call_duration || '-' || a.feesum
FROM tm_sd_postqdbill a
/*WHERE to_date(a.start_time,'yyyymmdd hh24:mi:ss')>=to_date('20060401 00:00:00','yyyymmdd hh24:mi:ss')*/
--and order by a.start_time
where a.msisdn=iv_msisdn;
--insert into post_info values(iv_yy);
--短信清单;
select b.other_party || '-' || b.finish_time || '-' || b.call_type || '-' || b.fee || '-' || b.msisdn
into iv_yy
from tm_sd_postqdbill_sm b
where b.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
--梦网清单;
select c.other_party || '-' || c.finish_time || '-' || c.fee || '-' || c.home_area_code
into iv_yy
from tm_sd_postqdbill_smsmon c
where c.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
--gprs清单;
select d.start_time || '-' ||d.apnni || '-' || d.data_up1 ||'-'|| d.data_down1
into iv_yy
from tm_sd_postqdbill_gprs d
where d.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
else --帐单和清单都有
end if;
END LOOP;
CLOSE iv_tcursor; --增加执行时间;
iv_date_e:=SYSDATE;
iv_exectime:=(iv_date_e-iv_date_s)*60*60*24;
v_resultinfo:=v_resultinfo||'[共耗时:'||iv_exectime||'秒]';
v_resultcode:=0;EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
v_resultinfo:='p_net_postinfo执行发生未知异常错误'||SQLERRM;
v_resultcode:=-1;
RETURN;
END;2.用程序如何实现(JAVA,C++)这个功能。
要求文本格式:
1.文本格式,文件名格式为:[email protected]帐单(很多用户,文件名是生成动态的)
2.如不用存储过程,如何用程序来实现(JAVA,C++)以下是我写过程CREATE OR REPLACE PROCEDURE p_net_postinfo(
--v_acyid in varchar2,
v_msisdn IN NUMBER,
v_resultcode OUT NUMBER,
v_resultinfo OUT VARCHAR2)
-----------------------------------------------------------------------
-- PROCEDURE : p_net_postinfo
-- Description: 邮寄清单及帐单
-- Author : xiezhibo
-- DATE : 2006/05/15
-- Editor : editplus
-----------------------------------------------------------------------IS
--统计相关资料
iv_date_s DATE; --保存执行起始时间
iv_date_e DATE; --保存执行终止时间
iv_exectime NUMBER(12,2); --保存执行多长时间
iv_msisdn varchar2(12); --保存用户的号码
iv_yy varchar2(5000);
iv_post_content varchar2(10); TYPE t_Cursor IS REF CURSOR;
iv_tcursor t_Cursor;
--iv_tcursor2 t_Cursor;
--iv_tcursor3 t_Cursor;BEGIN
v_resultinfo := '生成邮寄帐单清单完成!';
v_resultcode:=-1; iv_exectime:=0;
iv_date_s:=SYSDATE;
--取到用户的手机号码
open iv_tcursor for select distinct msisdn
from tf_f_postinfo@to_crm1 b,tm_sd_postqdbill a --关联到 @CRM1库上/CRM2上
where b.id=a.user_id
and b.post_tag='1'
and b.post_typeset='2'
and b.end_date> sysdate;
LOOP
fetch iv_tcursor into iv_msisdn;
EXIT WHEN iv_tcursor%NOTFOUND;
begin
select post_content into iv_post_content from tf_f_postinfo@to_crm1 a where a.id=iv_msisdn;
EXCEPTION
WHEN OTHERS THEN
v_resultinfo:='p_net_postinfo执行发生未知异常错误'||SQLERRM;
v_resultcode:=-1;
RETURN;
--语音清单;
SELECT a.other_party || '-' || a.start_time || '-' || a.call_type || '-' || a.long_type || '-' ||
a.call_duration || '-' || a.feesum
FROM tm_sd_postqdbill a
/*WHERE to_date(a.start_time,'yyyymmdd hh24:mi:ss')>=to_date('20060401 00:00:00','yyyymmdd hh24:mi:ss')*/
--and order by a.start_time
where a.msisdn=iv_msisdn;
--insert into post_info values(iv_yy);
--短信清单;
select b.other_party || '-' || b.finish_time || '-' || b.call_type || '-' || b.fee || '-' || b.msisdn
into iv_yy
from tm_sd_postqdbill_sm b
where b.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
--梦网清单;
select c.other_party || '-' || c.finish_time || '-' || c.fee || '-' || c.home_area_code
into iv_yy
from tm_sd_postqdbill_smsmon c
where c.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
--gprs清单;
select d.start_time || '-' ||d.apnni || '-' || d.data_up1 ||'-'|| d.data_down1
into iv_yy
from tm_sd_postqdbill_gprs d
where d.msisdn=iv_msisdn;
insert into post_info values(iv_yy);
else --帐单和清单都有
end if;
END LOOP;
CLOSE iv_tcursor; --增加执行时间;
iv_date_e:=SYSDATE;
iv_exectime:=(iv_date_e-iv_date_s)*60*60*24;
v_resultinfo:=v_resultinfo||'[共耗时:'||iv_exectime||'秒]';
v_resultcode:=0;EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
v_resultinfo:='p_net_postinfo执行发生未知异常错误'||SQLERRM;
v_resultcode:=-1;
RETURN;
END;2.用程序如何实现(JAVA,C++)这个功能。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货