[Home] [Help]
PACKAGE BODY: APPS.APP_UTILS
Source
1 package body app_utils as
2 /* $Header: AFUTILSB.pls 115.1 99/07/16 23:32:27 porting sh $ */
3
4
5 --
6 -- PUBLIC FUNCTIONS
7 --
8
9 -- SET_CHAR: STRING[POSITION] := RCHAR;
10 procedure set_char(string in out varchar2,
11 position number,
12 rchar varchar2) is
13 begin
14
15 -- Check for valid arguments
16 if ((position is null) or (position < 1)) then
17 app_exception.invalid_argument('app_exceptions.set_char',
18 'position', to_char(position));
19 elsif (rchar is null) then
20 app_exception.invalid_argument('app_exceptions.set_char', 'rchar', null);
21 end if;
22
23 -- Init string if necessary
24 if (string is null) then
25 string := ' ';
26 end if;
27
28 -- Pad string if necessary
29 if (position > length(string)) then
30 string := string||rpad(' ',position-length(string),' ');
31 end if;
32
33 -- Set char
34 -- Handles the boundary cases automatically:
35 -- If position=1, then position-1=0 and substr=null
36 -- If position=length, then position+1>length and substr=null
37 string := substr(string, 1, position-1) || rchar ||
38 substr(string, position+1);
39 end set_char;
40
41 -- Behavior of substr:
42 --
43 -- start length substr('karen', start, length)
44 -- ----- ------ ------------------------------
45 -- 0 or 1 null karen
46 -- 0 or 1 >= 6 karen
47 -- 0 or 1 <= 0 null
48 -- >= 6 null null
49 -- -1...-5 null n...k
50 -- -6 null null
51
52 end app_utils;