Chinaunix首页 | 论坛 | 博客
  • 博客访问: 570007
  • 博文数量: 63
  • 博客积分: 533
  • 博客等级: 中士
  • 技术积分: 1146
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-24 17:56
文章分类

全部博文(63)

文章存档

2016年(1)

2014年(23)

2013年(17)

2012年(22)

分类: Windows平台

2014-05-14 09:17:06


点击(此处)折叠或打开

  1. CREATE OR REPLACE PACKAGE xxfin_xml_print_pub IS
  2.   /*================================================================*
  3.   -- Description:
  4.   -- XML 报表打印通用程序
  5.   --
  6.   -- Reference:
  7.   -- 参考文档
  8.   -- Modification History:
  9.   -- Date Author Description
  10.   -- ------------ ----------------- ---------------------------------------
  11.   --
  12.   -- 2014-2-24 rojian Created
  13.   *================================================================*/
  14.   FUNCTION get_string_xml(p_string IN VARCHAR2) RETURN VARCHAR2;
  15.   
  16.   PROCEDURE write_raw_data
  17.   (
  18.     p_in_chr_item IN VARCHAR2
  19.    ,p_in_chr_value IN VARCHAR2
  20.   );

  21.   PROCEDURE write_str_data
  22.   (
  23.     p_in_chr_item IN VARCHAR2
  24.    ,p_in_chr_value IN VARCHAR2
  25.   );

  26.   PROCEDURE write_num_data
  27.   (
  28.     p_in_chr_item IN VARCHAR2
  29.    ,p_in_num_value IN NUMBER
  30.   );

  31.   PROCEDURE write_money_data
  32.   (
  33.     p_in_chr_item IN VARCHAR2
  34.    ,p_in_num_value IN NUMBER
  35.   );

  36.   PROCEDURE write_date_data
  37.   (
  38.     p_in_chr_item IN VARCHAR2
  39.    ,p_in_date_value IN DATE
  40.   );

  41.   PROCEDURE write_pecent_data
  42.   (
  43.     p_in_chr_item IN VARCHAR2
  44.    ,p_in_num_value IN NUMBER
  45.   );

  46.   PROCEDURE print_head;
  47.   PROCEDURE print_end;
  48.   PROCEDURE print_data(p_data varchar2);
  49. END xxfin_xml_print_pub;
  50. /
  51. CREATE OR REPLACE PACKAGE BODY xxfin_xml_print_pub IS

  52.   /*================================================================*
  53.   -- Description:
  54.   -- XML 报表打印通用程序
  55.   --
  56.   -- Reference:
  57.   -- 参考文档
  58.   -- Modification History:
  59.   -- Date Author Description
  60.   -- ------------ ----------------- ---------------------------------------
  61.   --
  62.   -- 2014-2-24 rojian Created
  63.   *================================================================*/
  64.   FUNCTION get_string_xml(p_string IN VARCHAR2) RETURN VARCHAR2 IS
  65.     l_temp VARCHAR2(30000);
  66.   BEGIN
  67.     l_temp := p_string;
  68.     l_temp := REPLACE(l_temp, '&', '&');
  69.     l_temp := REPLACE(l_temp, '<', '<');
  70.     l_temp := REPLACE(l_temp, '>', '>');
  71.     l_temp := REPLACE(l_temp, '‘', ''');
  72.     l_temp := REPLACE(l_temp, '’', ''');
  73.     l_temp := REPLACE(l_temp, '“', '"');
  74.     l_temp := REPLACE(l_temp, '”', '"');
  75.     RETURN l_temp;
  76.   END get_string_xml;
  77.   
  78.   PROCEDURE write_raw_data
  79.   (
  80.     p_in_chr_item IN VARCHAR2
  81.    ,p_in_chr_value IN VARCHAR2
  82.   ) IS
  83.     v_line VARCHAR2(4000);
  84.   BEGIN
  85.     v_line := '<' || p_in_chr_item || '> || p_in_chr_value || ']]> || p_in_chr_item || '>';
  86.     fnd_file.put_line(fnd_file.output, v_line);
  87.     --dbms_output.put_line(v_line);
  88.   END write_raw_data;

  89.   PROCEDURE write_str_data
  90.   (
  91.     p_in_chr_item IN VARCHAR2
  92.    ,p_in_chr_value IN VARCHAR2
  93.   ) IS
  94.     v_line VARCHAR2(4000);
  95.   BEGIN
  96.     v_line := '<' || p_in_chr_item || '>' || get_string_xml(p_in_chr_value) || ' || p_in_chr_item || '>';
  97.     fnd_file.put_line(fnd_file.output, v_line);
  98.     --dbms_output.put_line(v_line);
  99.   END write_str_data;

  100.   PROCEDURE write_num_data
  101.   (
  102.     p_in_chr_item IN VARCHAR2
  103.    ,p_in_num_value IN NUMBER
  104.   ) IS
  105.     v_line VARCHAR2(4000);
  106.   BEGIN
  107.     v_line := '<' || p_in_chr_item || '>' || ROUND(p_in_num_value, 6) || ' || p_in_chr_item || '>';
  108.     fnd_file.put_line(fnd_file.output, v_line);
  109.     --dbms_output.put_line(v_line);
  110.   END write_num_data;

  111.   PROCEDURE write_money_data
  112.   (
  113.     p_in_chr_item IN VARCHAR2
  114.    ,p_in_num_value IN NUMBER
  115.   ) IS
  116.     v_line VARCHAR2(4000);
  117.   BEGIN
  118.     v_line := '<' || p_in_chr_item || '>' || TO_CHAR(p_in_num_value, 'FM999,999,999,999,999,999,999,999,999.00') || ' ||
  119.               p_in_chr_item || '>';
  120.     fnd_file.put_line(fnd_file.output, v_line);
  121.     --dbms_output.put_line(v_line);
  122.   END write_money_data;

  123.   PROCEDURE write_date_data
  124.   (
  125.     p_in_chr_item IN VARCHAR2
  126.    ,p_in_date_value IN DATE
  127.   ) IS
  128.     v_line VARCHAR2(255);
  129.   BEGIN
  130.     v_line := '<' || p_in_chr_item || '>' || TO_CHAR(p_in_date_value, 'YYYY-MM-DD') || ' || p_in_chr_item || '>';
  131.   
  132.     fnd_file.put_line(fnd_file.output, v_line);
  133.     --dbms_output.put_line(v_line);
  134.   END write_date_data;

  135.   PROCEDURE write_pecent_data
  136.   (
  137.     p_in_chr_item IN VARCHAR2
  138.    ,p_in_num_value IN NUMBER
  139.   ) IS
  140.     v_line VARCHAR2(4000);
  141.   BEGIN
  142.     v_line := '<' || p_in_chr_item || '>' || p_in_num_value * 100 || '% || p_in_chr_item || '>';
  143.     fnd_file.put_line(fnd_file.output, v_line);
  144.     --dbms_output.put_line(v_line);
  145.   END write_pecent_data;

  146.   PROCEDURE print_head IS
  147.   BEGIN
  148.     fnd_file.put_line(fnd_file.output, '');
  149.     fnd_file.put_line(fnd_file.output, '');
  150.   END;

  151.   PROCEDURE print_end IS
  152.   BEGIN
  153.     fnd_file.put_line(fnd_file.output, '');
  154.   END;
  155.   
  156.   PROCEDURE print_data(p_data varchar2) IS
  157.   BEGIN
  158.     fnd_file.put_line(fnd_file.output, get_string_xml(p_data));
  159.   END print_data;
  160. END xxfin_xml_print_pub;
  161. /
 FUNCTION get_string_xml(p_string IN VARCHAR2) RETURN VARCHAR2;这个函数是处理XML中出现特殊字符写的函数。

阅读(1573) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~