DBA Data[Home] [Help]

PACKAGE BODY: APPS.QP_NUMBER

Source


1 PACKAGE BODY QP_NUMBER as
2 /* $Header: QPNUMBRB.pls 120.0 2005/06/02 00:22:55 appldev noship $ */
3 
4 
5 
6 --
7 --  Canonical functions
8 --
9 
10   function canonical_to_number(
11     canonical varchar2)
12   return number is
13   begin
14     return to_number(canonical, canonical_mask);
15   end canonical_to_number;
16 
17   function number_to_canonical(
18     numberval number)
19   return varchar2 is
20   begin
21     return rtrim(to_char(numberval, canonical_mask),'.');
22   end number_to_canonical;
23 
24 --  use 'set serverout on;' to see the output from this test program
25 
26   procedure test is
27     pi number := 3.1415;
28     my_char varchar2(20);
29   begin
30 /*
31     DBMS_OUTPUT.PUT_LINE('Decimal separator is '||qp_number.decimal_char);
32     DBMS_OUTPUT.PUT_LINE('Group separator is '||qp_number.group_separator);
33     DBMS_OUTPUT.PUT_LINE('Canonical mask is '||qp_number.canonical_mask);
34 
35     DBMS_OUTPUT.PUT_LINE('Canon number is '||qp_number.number_to_canonical(pi));
36     DBMS_OUTPUT.PUT_LINE('and back is '||to_char(qp_number.canonical_to_number('3.14')));
37     DBMS_OUTPUT.PUT_LINE('Canon integer is '||qp_number.number_to_canonical(4));
38     select qp_number.number_to_canonical(pi)
39     into my_char
40     from dual;
41 
42     DBMS_OUTPUT.PUT_LINE('Canon number from SQL is '||my_char);
43 
44 */
45     NULL;
46   end;
47 
48 
49   procedure initialize is
50 
51   begin
52    canonical_mask  := 'FM999999999999999999999.99999999999999999999';
53    decimal_char    := substr(ltrim(to_char(.3,'0D0')),2,1);
54    group_separator := substr(ltrim(to_char(1032,'0G999')),2,1);
55   end ;
56 
57 
58 begin
59   canonical_mask := 'FM999999999999999999999.99999999999999999999';
60 
61 -- OK, this is a bit kludgey, but I can't seem to find any way to access
62 --XS the numeric characters directly.
63   decimal_char := substr(ltrim(to_char(.3,'0D0')),2,1);
64   group_separator := substr(ltrim(to_char(1032,'0G999')),2,1);
65 end QP_NUMBER;