成名男子专栏Welcome to weijsh's Blog
utl_file来生成文件
01月09日(星期二)

用utl_file来生成文件
procedure sp_organization
is
cursor c1 is
select * from pb_organization;
v_rowvalue1 c1%rowtype;
v_id pb_organization.id%type;
v_organizationcode pb_organization.organizationcode%type;
v_shortname pb_organization.shortname%type;
v_appellation pb_organization.appellation%type;
v_postcode pb_organization.postcode%type;
begin
open c1;
l_output:=utl_file.fopen( 'd:oracleoradatasync', 'YT_PB_ORGANIZATION_'||to_char(sysdate-1,'YYYYMMDD')||'.dat', 'w' );
loop
fetch c1 into v_rowvalue1;
exit when c1%notfound;
v_ID:=v_rowvalue1.id;
v_organizationcode:=v_rowvalue1.organizationcode;
v_shortname:=v_rowvalue1.shortname;
v_appellation:=v_rowvalue1.appellation;
v_postcode:=v_rowvalue1.postcode;
utl_file.putf(l_output,v_id||'|'||v_organizationcode||'|'||v_shortname||'|'||v_appellation||'|'||v_postcode||'|'||'n');
end loop;
close c1;
utl_file.fclose( l_output );
delete from t_syncdata_log
where to_char(export_date,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd')
and table_name='pb_organization';
insert into t_syncdata_log(id,table_name,export_date,sign)
values(seq_syncdata_log.nextval,'pb_organization',sysdate,1);
commit;
v_sign:=1;
exception
when others then
delete from t_syncdata_log
where to_char(export_date,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd')
and table_name='pb_organization' and sign=0;
insert into t_syncdata_log(id,table_name,export_date,sign)
values(seq_syncdata_log.nextval,'pb_organization',sysdate,0);
commit;
l_output:=utl_file.fopen( 'd:oracleoradatasync', 'pb_organization_error.txt', 'w' );
utl_file.put(l_output,to_char(sysdate,'yyyy-mm-dd')||'error');
utl_file.fclose(l_output);
v_sign:=0;
end sp_organization;

文章分类: ORACLE开发
前篇(07-01-09): 生成CVS文件的过程
后篇(07-01-09): 利用Instant Client ,不安装oracle客户端使用sqlplus连接远程数据库的步骤

发表评论
标题:
称呼:
内容:

引用链接
您可以按照以下步骤引用本文.本站收到您的引用通知后, 将自动链接您的文章, 以方便别人阅览 .
1. 启动您自己的博客管理页面, 并进入发表新文章的画面, 输入文章的内容. (如果您是ITPUB的博客请点这里.)
2. 复制下面虚线框里的连接字串, 把它们粘贴到您的文章中, 按照您的喜好修改一下表示文字.
3. 确认您选择了"发送引用通知"的选项.
4. 发表您的文章.
好啦, 您的文章就可以被自动链接到本站啦.

« 八月 2008 »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

ORACLE分类
  • 虎口脱险
  • 辰风的专栏
  • 人生就是如此
  • eygle's life
  • piner的专栏
  • 左岸年华(ocp8i)

  • 名人分类
  • 咖啡小驻--系分


  • Creative Commons License 本站全部著作均采用CC授权. Plog 1.0 is powered by: plogworld.net.
    Itpub BLOG is provided by: itpub.net.
    This temlate(named Happy-Life's SunShine) is designed by lodge@itpub(肥猫猫).