| Procedure Doubt [message #569225] |
Tue, 23 October 2012 04:08  |
 |
rishwinger
Messages: 101 Registered: November 2011
|
Senior Member |
|
|
Please explain the below error
User Scott having DBA privilege
create or replace procedure pt is
l_count integer:=0;
v_sid varchar2(1000);
begin
SELECT name
INTO v_sid
FROM v$database;
dbms_output.put_line('SID='||v_sid);
end pt;
/
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE PT:
LINE/COL ERROR
-------- -----------------------------------------------------------
5/1 PL/SQL: SQL Statement ignored
7/9 PL/SQL: ORA-00942: table or view does not exist
SQL>
SQL> select name from v$database;
NAME
---------
ORCL
I can't access v$parameter,or v$database from a procedure?
|
|
|
|
| Re: Procedure Doubt [message #569226 is a reply to message #569225] |
Tue, 23 October 2012 04:13   |
 |
ramoradba
Messages: 2427 Registered: January 2009 Location: AndhraPradesh,Hyderabad,I...
|
Senior Member |
|
|
"DBA" is a Pre_defined role in Oracle DB.
To Access such objects ,Privileges must be granted directly ,but not through roles in case of Procedure.
It is not advisable to use Pre-defined roles.
create your roles.
Edit:Typo
-ROD
[Updated on: Tue, 23 October 2012 04:24] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: Procedure Doubt [message #569329 is a reply to message #569228] |
Wed, 24 October 2012 15:17   |
Bill B
Messages: 986 Registered: December 2004
|
Senior Member |
|
|
You can also use a way to get the sid that doesn't need priviledges
create or replace procedure pt is
l_count integer:=0;
v_sid varchar2(50);
begin
SELECT sys_context('USERENV','DB_NAME')
INTO v_sid
FROM dual;
dbms_output.put_line('SID='||v_sid);
end pt;
/
|
|
|
|
| Re: Procedure Doubt [message #569338 is a reply to message #569329] |
Wed, 24 October 2012 23:46  |
 |
Michel Cadot
Messages: 54178 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
In addition, you should NOT use dbms_output for such thing.
Convert your procedure to a funtion and return the result via it.
dbms_output has no real usage than debugging.
PL/SQL is NOT intend to display anything but to compute, the caller, the final application, is the one that has the work to display.
And, actually dbms_output does not display anything, it just fill a buffer.
Regards
Michel
|
|
|
|