DBA Data[Home] [Help]

PACKAGE BODY: APPS.BISM_UTILS

Source


1 PACKAGE BODY bism_utils AS
2 /* $Header: bibutilb.pls 120.2 2006/04/03 05:24:05 akbansal noship $ */
3 function get_guid
4 return raw
5 is
6 oid raw(16);
7 begin
8 select sys_guid() into oid from dual;
9 return oid;
10 end;
11 
12 function get_database_user return varchar2
13 is
14 user varchar2(64);
15 begin
16 select sys_context('userenv','session_user') into user from dual;
17 return user;
18 end;
19 
20 function get_current_user_id return raw
21 is
22 id raw(16);
23 begin
24 -- select sys_context('bism_session','current_user_id') into id from dual;
25 return id;
26 end;
27 
28 function init_user(user varchar2) return raw
29 is
30 sub_id raw(16);
31 oid raw(16);
32 priv bism_permissions.privilege%type;
33 begin
34 
35 --make sure there is a root folder
36 begin
37 select object_id into oid from bism_objects where folder_id = '30' and object_name = 'ROOT' and user_visible = 'Y';
38 exception
39 when no_data_found then
40 raise_application_error(BISM_ERRORCODES.ROOT_NOT_FOUND,'Root folder not found');
41 end;
42 
43 -- make sure that the user is internally identified (we need SUBJECT_ID)
44 begin
45 select subject_id into sub_id from bism_subjects where subject_name = user ;
46 -- bism_context.set_user(sub_id);
47 -- select sys_context('bism_session','current_user_id') into sub_id from dual;
48 exception
49 when no_data_found then
50 -- renumber the error messages later..
51 raise_application_error(BISM_ERRORCODES.USER_NOT_IDENTIFIED,'User could not be identified',true);
52 when too_many_rows then
53 raise_application_error(BISM_ERRORCODES.USER_EXISTS_MULTIPLE_TIMES,'User exists more than once',true);
54 
55 end;
56 
57 --lastly make sure that the user has atleat list privilege on the root
58 begin
59 select privilege into priv from bism_permissions where subject_id=sub_id and object_id='31';
60 exception
61 when no_data_found then
62 raise_application_error(BISM_ERRORCODES.NO_PRIVILEGES,'User has no privileges for root folder');
63 end;
64 
65 if priv < 10 then
66 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIVILEGES,'User does not have enough privileges for root folder');
67 else
68 return sub_id;
69 end if;
70 
71 end;
72 
73 
74 function get_object_ids_and_time(num number,current_time out nocopy date)
75 return bism_object_ids
76 is
77 oid raw(16);
78 ids bism_object_ids := bism_object_ids();
79 begin
80 for i in 1..num loop
81 select sys_guid() into oid from dual;
82 ids.extend();
83 ids(i) := oid;
84 end loop;
85 select sysdate into current_time from dual;
86 return ids;
87 end;
88 
89 function get_object_ids_and_time_30(num number,current_time out nocopy date)
90 return RAW
91 is
92 oid raw(16);
93 ids raw(32000);
94 begin
95 -- the caller shouldn't ask for more than 2000 ids at a time
96 select sysdate into current_time from dual;
97 if num > 2000 then
98    return null;
99 end if;
100 for i in 1..num loop
101 select sys_guid() into oid from dual;
102 ids := ids || oid;
103 end loop;
104 return ids;
105 end;
106 
107 function get_time_in_hundredth_sec
108 return varchar2
109 is
110 begin
111 return to_char(dbms_utility.get_time());
112 end;
113 
114 end bism_utils;