If being called under owner account, the following syntax works just fine:
SELECT "MY_OWNER"."MY_PACKAGE".Convert(t.Value) FROM My_Table t
but when called from under another user I get the following error:
ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 1 Column: ??
Where Column: ?? points to
SELECT "MY_OWNER"."MY_PACKAGE".Convert(t.Value) FROM My_Table t
⇑
What am I doing wrong?
UPDATE. It's a function that is being called:
FUNCTION Convert ...
You need to grant privileges on this package to the other user
GRANT EXECUTE ON MY_OWNER.MY_PACKAGE TO the_other_user;
You should also check to see whether a_horse_with_no_name is correct. Is this a function that you can call in the way you specify or a procedure which should be called in this way
DECLARE
v_value VARCHAR2(10);
BEGIN
MY_OWNER.MY_PACKAGE.CONVERT(v_value);
END;
Also check the package to see what rights are defined. Current User or package owner. More details can be found here
Related
I try to execute a package in oracle that it works when call him with software, but in sql developer no
show me the following error:
ORA-06550: Line 2 column 11
PLS-00103 Encountered the symbol "package name" when expection one the following
:= . ( # % ; was substituted form "package name" to continue.
06550. 000000 - "line%s column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action
Vendor code 6550 Error at Line:1
the line 11 start of name package
begin
execute packageName.procedureName(parameter1,parameter2,parameter3,...);
end
Remove EXECUTE. It is used when you want to run a procedure at SQL*Plus prompt. In PL/SQL, you don't use it.
Code that should work is:
begin
packageName.procedureName(parameter1,parameter2,parameter3,...);
end;
/
There's an issue when installing several objects via SQL*Plus.
Let's install two objects: package A and view B, and A has compilation errors
SET FEEDBACK OFF
prompt install PACKAGE_A spec
create or replace package package_a is
procedure p;
end;
/
show errors
prompt install PACKAGE_A body
create or replace package body package_a is
procedure p is begin hello; end;
end;
/
show errors
prompt install VIEW_B
create or replace view view_b as
select * from dual;
show errors
Thus we get in the output:
install PACKAGE_A spec
No errors.
install PACKAGE_A body
Warning: Package Body created with compilation errors.
Errors for PACKAGE BODY PACKAGE_A:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/24 PL/SQL: Statement ignored
2/24 PLS-00201: identifier 'HELLO' must be declared
install VIEW_B
Errors for PACKAGE BODY PACKAGE_A:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/24 PL/SQL: Statement ignored
2/24 PLS-00201: identifier 'HELLO' must be declared
I had faced this problem not only in a "view after package" case, but currently I can not reproduce it in a short example for a "package after package" case (which bothers me mostly). So it seems to not appear for all types of compilation errors.
Documentation says When you specify SHOW ERRORS with no arguments, SQL*Plus shows compilation errors for the most recently created or altered stored procedure.
It is also clear that there is an option of specifying a particular object
SHOW ERR[ORS] [{FUNCTION | PROCEDURE | PACKAGE | PACKAGE BODY ...} [schema.]name]
But it does not look usable, because the requirement of giving an object type overcomplicates the situation (it is not obvious why the command cannot be satisfied with an object name alone).
Could you help me find a way to clear the buffer of SHOW ERRORS command, so it could be set in a pristine state before every object compilation?
If there is a way, I don't know it.
SHOW ERRORS is a SQL*Plus command. As fara as I can tell, it fetches data from USER_ERRORS (or, possibly, ALL_ERRORS or DBA_ERRORS). Its description is
SQL> desc user_errors;
Name Null? Type
----------------------------------------- -------- ----------------
NAME NOT NULL VARCHAR2(30)
TYPE VARCHAR2(12)
SEQUENCE NOT NULL NUMBER
LINE NOT NULL NUMBER
POSITION NOT NULL NUMBER
TEXT NOT NULL VARCHAR2(4000)
ATTRIBUTE VARCHAR2(9)
MESSAGE_NUMBER NUMBER
If I do something like this:
SQL> create or replace procedure ptest is
2 l_Res number;
3 begin
4 l_res := 1 * A;
5 end;
6 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE PTEST:
LINE/COL ERROR
-------- --------------------------------------------------------
4/3 PL/SQL: Statement ignored
4/16 PLS-00201: identifier 'A' must be declared
then SHOW ERR returns the last errors I got. Does it mean that USER_ERRORS doesn't contain something else? No:
SQL> select name, line, substr(text, 1, 50) text from user_Errors;
NAME LINE TEXT
------------ ---------- --------------------------------------------------
PTEST 4 PL/SQL: Statement ignored
PTEST 4 PLS-00201: identifier 'A' must be declared
ADD_COURSE 0 PL/SQL: Compilation unit analysis terminated
ADD_COURSE 2 PLS-00201: identifier 'COURSE.TILTE' must be decla
SQL>
So, can I simply delete its contents? Ideally, I'd do that between every two CREATE PROCEDURE (or whatever) statements in that .SQL script:
SQL> delete user_errors;
delete user_errors
*
ERROR at line 1:
ORA-01031: insufficient privileges
Nope, I can't do that.
Therefore, I think you'll have to use that not-very-usable option and specify whose errors you want to see.
I want to create procedure which will kill all session. After I run the statement i get error:
[Warning] ORA-24344: success with compilation error 10/13 PL/SQL:
ORA-00942: table or view does not exist 6/6 PL/SQL: SQL Statement
ignored 15/31 PLS-00364: loop index variable 'V_KILL' use is invalid
15/9 PL/SQL: Statement ignored (1: 0): Warning: compiled but with
compilation errors
CREATE OR REPLACE PROCEDURE KILL_ORACLE_SESSIONS
IS
BEGIN
FOR v_kill IN
(SELECT
'alter system kill session '''
||sid||','||serial#||',#1'|| ''' immediate;' as statement
FROM
v$session
WHERE
sql_id='sql_id_here'
)
LOOP
dbms_output.put_line (v_kill.statement);
END LOOP;
END;
/
Where is the catch ?
Thanks
Most likely you don't have permissions to select view v$session because your user received this privilege by a ROLE. Privileges inside a PL/SQL block must be granted directly to the user (i.e. GRANT SELECT ON V$SESSION TO {username};). A role (for example DBA ROLE) does not apply inside PL/SQL.
I had built a few tables with sequences and triggers, since I need to share the script with my team at uni I did an export with sqldeveloper, now when I try to import/execute the resulted .sql I'm getting errors with triggers.
This is the error message:
"Error starting at line 250 in command:
CREATE OR REPLACE EDITIONABLE TRIGGER "TRG_ACCOUNTS"
BEFORE INSERT ON ACCOUNTS
FOR EACH ROW
BEGIN
SELECT SEQ_ACCOUNTS.NEXTVAL INTO :NEW.ACCOUNT_ID FROM DUAL
Error report:
SQL Command: editionable TRIGGER
Failed: Warning: execution completed with warning
Error starting at line 258 in command:
END
Error report:
Unknown Command
trigger "TRG_ACCOUNTS" altered."
This is the part of the script it's complaining about. I have a few other triggers and it's giving me the same error on all of them. I've checked how the triggers are created after executing the script, and all of them seem to be missing a semi colon and the "END;" at the end.
Example:
create or replace
TRIGGER "TRG_FL_AR"
BEFORE INSERT ON FLOOR_AREAS
FOR EACH ROW
BEGIN
SELECT SEQ_FL_AR.NEXTVAL INTO :NEW.FLOOR_AREA_ID FROM DUAL <-- missing ";" here
<missing "END;" here>
Could you please help me?
Thank you.
Try to put a back slash / after line 258 and check again
Step 1 : I have created one package with procedures to create context and set value to the context.
create or replace PACKAGE Context_check AS
PROCEDURE set_context_vpd_proc (V_ISID in varchar2);
procedure set_context (v_isid_a in varchar2);
END Context_check;
create or replace PACKAGE BODY Context_check AS
PROCEDURE set_context_vpd_proc (V_ISID in varchar2)
AS
v_STAT VARCHAR2(200);
v_chk varchar2(2000);
BEGIN
DBMS_SESSION.SET_CONTEXT('VPD_CTX', 'ISID', V_ISID );
--v_STAT := '';
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
procedure set_context (v_isid_a in varchar2)
as
begin
EXECUTE IMMEDIATE 'CREATE OR REPLACE CONTEXT VPD_CTX using set_context_vpd_proc';
set_context_vpd_proc (v_isid_a);
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
end set_context;
END Context_check;
Step 2: When I am trying to executing the procedure I am getting an error
EXECUTE Context_check.set_context('Ana');
Error starting at line 43 in command:
EXECUTE Context_check.set_context('Ana')
Error report:
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SESSION", line 114
ORA-06512: at "SEC_ADMIN.CONTEXT_CHECK", line 8
ORA-06512: at "SEC_ADMIN.CONTEXT_CHECK", line 20
ORA-06512: at line 1
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to change the current username or password
without the appropriate privilege. This error also occurs if
attempting to install a database without the necessary operating
system privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
if the user was granted the necessary privilege at a higher label
than the current login.
*Action: Ask the database administrator to perform the operation or grant
the required privileges.
For Trusted Oracle users getting this error although granted the
the appropriate privilege at a higher label, ask the database
administrator to regrant the privilege at the appropriate label.
I have already given all the grants on that package.Still I am not able to execute this procedure.
Note : If I create the same procedures as stand alone ,its working fine and setting the context.
You need to create a context using a package, not using a procedure inside of a package.
Instead of
EXECUTE IMMEDIATE 'CREATE OR REPLACE CONTEXT VPD_CTX using set_context_vpd_proc';
Write
EXECUTE IMMEDIATE 'CREATE OR REPLACE CONTEXT VPD_CTX using Context_check';