Advertisement

09.01.2008 at 12:38AM PDT, ID: 23693045
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

oracle synonyms

Asked by AlbIT in Oracle 10.x, Oracle Database, PL / SQL

Tags: , ,

i have a problem with my web application in aspx .NET with a oracle 10g xe database. i can create my users from web application  to the database but i cant logged in the web application. the user can log and open the objects of the schema like "select * from schema_name.object_name". i think there is a problem with the synonyms. please help meStart Free Trial
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
create or replace package body USER_MANAGER is
 
 procedure Create_User(userN in varchar2, passwd in varchar2,
 userprofile in varchar2,
 returnValue out integer,
 errormessage out varchar2
) 
 as
 
 UserExists integer:=0;
 profileExists integer:=0;
 dynString varchar2(1000);
 
 begin 
 
 
 begin 
 
 select 1 into UserExists from dual
 where exists(select user_id from sys.all_users U where 
 U.username=userN);
 
 exception when NO_DATA_FOUND then
           UserExists:=0;
 
 
 end;
 
 
 
 if UserExists=0 then
 
 
       dynString:='CREATE USER ' || userN || '  IDENTIFIED BY  ' || passwd;
       
       if userprofile<>''  and userprofile is not null then
          
          select 1 into profileExists from dual
         where exists(select P.profile from SYS.DBA_PROFILES P where P.profile=userprofile);
          
          if profileExists=1 then
       
             dynString:=dynString || ' PROFILE ' || userprofile;
          else
               returnValue:=-1;
                errormessage:='Ky profil nuk egziston!!!';
                --return;
              end if;
       end if;
       
       execute immediate dynString;
       
       dynString:='GRANT CONNECT to  ' || userN;
       
      execute immediate dynString;
       
       returnValue:=0;
 else
     returnValue:=-1;
     errormessage:='Perdorues me kete emer egziston!!!';
 
 
 end if;
 
 
 GrantPermissionsUser('DAP',userN,'VIEW','SELECT',returnValue,errormessage);
  GrantPermissionsUser('DAP',userN,'FUNCTION','EXECUTE',returnValue,errormessage);
   GrantPermissionsUser('DAP',userN,'PROCEDURE','EXECUTE',returnValue,errormessage);
    GrantPermissionsUser('DAP',userN,'PACKAGE','EXECUTE',returnValue,errormessage);
    GrantPermissionsUser('DAP',userN,'TABLE','SELECT',returnValue,errormessage);
    GrantPermissionsUser('DAP',userN,'TYPE','EXECUTE',returnValue,errormessage);
 
 
 
 
 exception when others then 
         returnValue:=SQLCODE;
          errormessage:='Error ne krijimin e perdoruesit: ' || SQLERRM; 
 
 
 
 end Create_User; 
 
 
 
 
 procedure Create_Role(roleName in varchar2, returnValue out integer, errormessage out varchar2)
 as
 
 existsRole integer:=0;
 dynString varchar2(1000);
 begin 
 
 begin
 
 select 1 into existsRole from dual 
        where exists(select role from sys.dba_roles where role=roleName);
    
    
 exception when NO_DATA_FOUND then 
               existsRole:=0;
                  
 
  
 end;
 
 
 
 if existsRole=0 then
 
    dynString:='CREATE ROLE ' || roleName || ' NOT IDENTIFIED';
    
    execute immediate dynString;
    returnValue:=0;
 
 else
       returnValue:=-1;
       errormessage:='Role me kete emer egziston!!!';
     
 
 end if;
  
 
 
 exception when others then 
             returnValue:=SQLCODE;
              errormessage:='Error ka ndodhur ne krijimin e rolit: ' || SQLERRM;
 
 
 
 end Create_Role;
 
 
 procedure CrateSynonyms(userName in varchar2, typeSynonym in varchar2, 
 returnValue out integer, errormessage out varchar2)
 as
 
 dynString varchar2(1000);
 UserExists integer:=0;
 SynExists integer:=0;
 begin 
 
 begin 
 
 select 1 into UserExists from dual
 where exists(select user_id from sys.all_users U where 
 U.username=userName);
 
 exception when NO_DATA_FOUND then
           UserExists:=0;
 
 
 end;
 
 
 
 if UserExists=1 then 
 
 for idx in (select owner,
                    object_name,
                    subobject_name,
                    object_id,
                    data_object_id,
                    object_type,
                    created,
                    last_ddl_time,
                    timestamp,
                    status,
                    temporary,
                    generated,
                    secondary
                    from 
                    sys.all_objects
                    where owner=userName and (object_type='PACKAGE' or  object_type='VIEW'
                    or object_type='FUNCTION' or object_type='TABLE' or
                    object_type='TYPE'or object_type='PROCEDURE' or object_type='PACKAGE BODY'
                    )) loop
 
   begin
   
   select 1 into SynExists  from dual
   where
   exists(select  synonym_name from sys.all_synonyms where  synonym_name=idx.object_name) ;
     
     exception when NO_DATA_FOUND then 
               SynExists:=0;
     
   end;  
   
   if SynExists=0 then
    
     dynString:='CREATE PUBLIC SYNONYM ' || idx.object_name || ' FOR ' || userName || '.' || idx.object_name;
     
     execute immediate dynString;
     
          
                    
   end if;                 
                    
                    
 end loop ;                  
 
    
 
 
 
 end if;
 
 
 
 
 
 
 end CrateSynonyms;
 
 
 procedure GrantPermissionsUser(ownerName in varchar2, userName in varchar2, 
objectType in varchar2, accessType in varchar2,
returnValue out integer, 
errormessage out varchar2)
as
 
 dynString varchar2(1000);
 UserExists integer:=0;
 OwnerExists integer:=0;
 SynExists integer:=0;
 permGranted integer:=0;
 
begin
 
 begin 
 
 select 1 into UserExists from dual
 where exists(select user_id from sys.all_users U where 
 U.username=userName);
 
 exception when NO_DATA_FOUND then
           returnValue:=-1;
           errormessage:='Error. Nuk gjej kete perdorues!!!';
 
 
 end;
 
 
  begin 
 
 select 1 into OwnerExists from dual
 where exists(select user_id from sys.all_users U where 
 U.username=ownerName);
 
 exception when NO_DATA_FOUND then
           returnValue:=-1;
           errormessage:='Error. Nuk gjej kete Owner!!!';
 
 
 end;
 
 
 
 if UserExists=1 and OwnerExists=1 then
 
    for idx in (select owner,
                    object_name,
                    subobject_name,
                    object_id,
                    data_object_id,
                    object_type,
                    created,
                    last_ddl_time,
                    timestamp,
                    status,
                    temporary,
                    generated,
                    secondary
                    from 
                    sys.all_objects
                    where owner=ownerName and object_type=objectType) loop
 
    
    
       begin
   
   select 1 into permGranted  from dual
   where
   exists(select  table_name from SYS.Dba_Tab_Privs where OWNER=ownerName and  table_name=idx.object_name 
   and GRANTEE=userName) ;
     
     exception when NO_DATA_FOUND then 
               permGranted:=0;
     
   end;                
    
    
   if permGranted=0 then 
   
   dynString:='GRANT '|| accessType || ' ON ' || idx.object_name || ' TO ' || userName;
   
   execute immediate dynString;
   
   end if; 
    
    
    
 end loop;
 
 
 end if;
 
 
 
exception when others then 
      returnValue:=SQLCODE;
          errormessage:='Error ne dhenien  permissions  perdoruesit: ' || SQLERRM;       
 
 
 
end  GrantPermissionsUser;
 
 procedure AssignUserInstGroup(SID in integer, grpID in char, userID in integer,
returnValue out integer,
	errorMessage out varchar2 )
  as
  exist integer:=0;
  begin 
   
   begin
      select 1 into exist from dual
       where exists(select G.Code_p_s from  v_user_inst_groups G where G.Code_p_s=grpID); 
       
       exception 
                 when NO_DATA_FOUND then
                      exist:=0;  
  end;
  
  if exist=0 then 
  
     insert into instgroup_managment
     (
     user_id,
     code_p_s,
     date_created,
     created_by
     
     )
     values
     (
      SID,
      grpID,
      CURRENT_DATE,
      userID
     
     );
     
  
  
  
  end if;
  
  errorMessage:='';
	returnValue:=0;
  
   exception 
             when others then
				
			        errorMessage:='Error database!!! Nuk mund lidh perdoruesin me Grupin!!!';
				      returnValue:=-1;
  
  
  end AssignUserInstGroup;
 
end USER_MANAGER;
 
Loading Advertisement...
 
[+][-]09.01.2008 at 08:45AM PDT, ID: 22361182

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Oracle 10.x, Oracle Database, PL / SQL
Tags: oracle, oracle 10g xe, oracle 10g xe
Sign Up Now!
Solution Provided By: dvz
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.01.2008 at 09:05PM PDT, ID: 22364114

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.02.2008 at 12:53AM PDT, ID: 22364896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.06.2008 at 01:35PM PDT, ID: 22408869

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.16.2008 at 06:15AM PDT, ID: 22488015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2008 at 07:10AM PDT, ID: 22511109

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 01:48AM PDT, ID: 22518970

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.23.2008 at 06:04AM PDT, ID: 22548748

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.23.2008 at 08:15PM PDT, ID: 22792983

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10.27.2008 at 06:57PM PDT, ID: 22818610

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628