Oracle: error using DMBS_IJOBS - oracle

I've got the following error using the following code:
BEGIN
sys.dbms_ijob.run(25950);
COMMIT;
EXCEPTION
WHEN others
THEN
DBMS_OUTPUT.put_line (SQLERRM);
RAISE;
END;
ORA-06550: line 2, column 5:
PLS-00201: identifier 'SYS.DBMS_IJOB' must be declared
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored

I guess you're not running this as SYS. Either you need to run it as SYS or you need a DBA to grant you execute privileges on the package.

While #APC is correc that this is a permissions issue, I would strongly question why you are using the DBMS_IJOB package in the first place. It is an undocumented, internal package, not something that should generally be used by developers. And there is a perfectly good RUN procedure in the public, documented DBMS_JOB package that you can use instead
BEGIN
dbms_job.run( 25950 );
commit;
END;
/
There is no reason to use the internal, undocumented package when the public, documented package has a method to do what you want.

I don't think there is a package called DBMS_IJOB in Oracle Database. It should be DBMS_JOB.

Related

refresing Oracle MV remotely

I'm trying to refresh Oracle Materialized View on remote DB using DB Link name. everything working fine once I'm using static db link name like
DBMS_MVIEW.REFRESH#QA_LINK('tablename_mv','?')
BUT
when I want to get it (db link name) as a variable in many ways
v_dblink :='qa';
DBMS_MVIEW.REFRESH#v_dblink('AVBROCHURESTATS','?');
always getting an errors like
ORA-06550: line 57, column 15:
PLS-00352: Unable to access another database 'V_DBLINK'
ORA-06550: line 57, column 15:
PLS-00201: identifier 'DBMS_MVIEW#V_DBLINK' must be declared.
Please advice.
DB link names must always be explicit; there's no variable substitution in the DDL. The best you could do would be to use dynamic SQL to build the execution string on the fly:
v_dblink := 'QA'
EXECUTE IMMEDIATE 'DBMS_MVIEW.REFRESH#' || v_dblink ||'(''AVBROCHURESTATS'',''?'')';
the problem was related to the same invoking , becuse
with execute immediate you need to put that statement into a begin end; block
like
execute immediate ' begin DBMS_MVIEW.REFRESH#'|| v_dblink||'(''AVBROCHURESTATS'',''?''); end;';

Compiling a stored procedure with local functions on Oracle 9i

I have a legacy application that is still running on Oracle 9i. We'll me migrating to 11g later this year, but for the moment, I need to run some test scripts on the current environment.
My test uses a stored procedure, but when I try to compile the procedure I get the following error.
"PLS-00103: Encountered the symbol "end-of-file" when expecting one of
the following:"
This is strange as the stored procedure compiled on the same server about two years ago. The only difference is that the database has been overwritten with a copy of the production database since (this procedure is only used in test, so is not present in the production database).
The problem seems to stem from local functions within the procedure. Here's a very simple procedure that illustrates the error I'm getting:
create or replace procedure test
as
l_dt date;
function dt
return date
is
begin
return sysdate;
end;
begin
l_dt := dt;
dbms_output.put_line(to_char(l_dt, 'dd-mm-yyyy'));
end;
Edit: Here's the complete output when I try to compile this:
1 ORA-24344: success with compilation error
10 PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
10
10 begin function package pragma procedure form
13 ORA-06550: line 2, column 3:
13 PLS-00201: identifier 'L_DT' must be declared
13 ORA-06550: line 2, column 3:
13 PL/SQL: Statement ignored
14 ORA-06550: line 3, column 32:
14 PLS-00201: identifier 'L_DT' must be declared
14 ORA-06550: line 3, column 3:
14 PL/SQL: Statement ignored
14 SQL parse error location
It definitely seems to be the local function that's causing it, as if I take it out, it compiles just fine. Here's the above procedure with the local function removed, and that working:
create or replace procedure test
as
l_dt date;
begin
l_dt := sysdate;
dbms_output.put_line(to_char(l_dt, 'dd-mm-yyyy'));
end;
I wonder if anyone else has encountered this problem, or knows if there's any reason local functions wouldn't compile under Oracle 9i?
Thanks,
James
The error is being reported against line 10, after the end of the function, so the enclosing procedure isn't being parsed properly. What you're doing is fine though, and works through other clients, and with the version of SqlDbx I tried. It looks like the procedure is being treated as two statements, and sent to the database in two chunks, neither of which is valid on its own.
This problem is reported on the SqlDbx Oracle forum, which mentions the bug exists in versions 3.64 and 4.0. It doesn't appear to be specific to the Oracle version. On 2014-04-14 the response was:
This is a bug and it will be fixed in a follow up to the latest release in about two weeks.
The release notes for version 4.1 include:
Fixes:
1. Corrupted text returned in Unicode version
2. Error parsing nested function (Oracle)
...
So you need to upgrade to version 4.1 or later; the current version is 4.3, and I don't see this problem with that version against a 9i or 11g database.

Why can't execute SCHEMA_NAME.PACKAGE_NAME.PROCEDURE, Oracle

I have a schema A, Package B and Procedure C. B is in A schema and C is in B's Package Body.
It works fine when I say:
Begin
Exec B.C;
END;
But it throw an error when I say:
Begin
Exec A.B.C;
END;
Error report:
ORA-06550: line 2, column 12:
PLS-00302: component 'B' must be declared
ORA-06550: line 2, column 4:
PL/SQL: Statement ignored
I log in as A so it's in A's schema.
and
SELECT * FROM user_OBJECTS WHERE OBJECT_NAME = 'B';
shows package and package body both valid.
I had the same problem and found the issue. I will write here the answer to close this problem and help other people.
In my case, my user A have execute privilege on a procedure B(just a procedure, not a package, but it's the same). When the user tries to run:
Begin
Exec A.B;
END;
Get the error:
ERROR at line 2:
ORA-06550: line 2, column 7:
PLS-00302: component 'B' must be declared
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
Problem: That's because a public synonym with name A was created in the database. This is an old database and I am just the DBA, not the developer, but in this case the developer was an uninspired developer. He used 4 types of objects with the same name: user, table, tablespace and public synonym. A public synonym named A in front of a table named A.
Solution: Because you don't know exactly who is using that public synonym I had to found another solution instead of deleting the public synonym. I created a private synonym for that procedure. Now the user can skip the owner of procedure in the execution code and ignore the public synonym. This problem appears in Oracle Database 10.2.0.4.
Begin
Exec B;
END;
PL/SQL procedure successfully completed.
Conclusion: Never use a public/private synonym with the name of the schema.
Hope to help someone. If I didn't made myself clear, please leave a comment.
Fix syntax error in the package, this is a generic PL/SQL compile error message.
Check error points (line 2, column 12) in the PL/SQL where the syntax error occurred, correct it and then try recompiling your code.
Component 'B' must be declared.
After that grant EXECUTE_CATALOG_ROLE to allow user 'A' execute privileges for packages and procedures in the data dictionary.
grant EXECUTE_CATALOG_ROLE to A;

Including the schema name when calling a PL/SQL procedure doesn't work in one schema but does in another

This problem came up when trying out the Unit Testing capabilities of SQLDeveloper.
When running a test for a procedure that is created within my schema I am seeing an error however when the same procedure is run in one of the oracle supplied schemas it works without an issue.
SQL Developer generates the following calls:
1) This one doesn't work (error is shown below):
BEGIN
"IANC"."SIMPLE_PARAMETER"(P_X => 123);
END;
2) This one does:
BEGIN
"HR"."SIMPLE_PARAMETER"(P_X => 123);
END;
This is the procedure:
CREATE OR REPLACE PROCEDURE SIMPLE_PARAMETER
(
P_X IN NUMBER
)
IS
BEGIN
null;
END SIMPLE_PARAMETER;
The following is the output from SQLPLUS, where you can see when the procedure is run in my schema I see an error whilst when running the same procedure in another schema the procedure works as expected:
In case of need my I am using Oracle Enterprise Edition 11.2.0.1.0
Update
Screen shot showing procedure signatures
I should also mention that if I remove the schema name from the procedure call then the procedure runs and completes as expected.
Thanks in advance for any help received.
Are you sure that the SIMPLE_PARAMETER procedure in IANC is the same (or at least has the same signature) as the one in HR? What do you get from `DESCRIBE "IANC"."SIMPLE_PARAMETER".
(P.S. since your identifiers are all upper-case, you shouldn't need the double quotes at all.)
Added: Another possibility is that you have a package called IANC in the IANC schema, so Oracle is looking for a procedure in that package called SIMPLE_PARAMETER that does not exist. Example:
SQL> exec bigdecimaltest
PL/SQL procedure successfully completed.
SQL> exec dcosta.bigdecimaltest
PL/SQL procedure successfully completed.
SQL> create or replace package dcosta as
2 end;
3 /
Package created.
SQL> exec dcosta.bigdecimaltest
BEGIN dcosta.bigdecimaltest; END;
*
ERROR at line 1:
ORA-06550: line 1, column 14:
PLS-00302: component 'BIGDECIMALTEST' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
This seems like buggy behavior -- if the attempt to resolve the name as package.member doesn't succeed, I think Oracle ought to then try it as schema.object, but it looks like once it has found a match on the package name it won't reconsider that.

Oracle: problem with constructing JMS message

After some struggle with Oracle Advanced Queuing and dbms_aq package
I encountered another issue. I copied code from Oracle tutorials
but when I compile this code:
create or replace
procedure jms_test(msg varchar2)
is
id pls_integer;
message sys.aq$_jms_stream_message;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
begin
message := sys.aq$_jms_stream_message.construct(0);
message.set_string_property('FROM', 'TEST');
id := message.clear_body(-1);
end;
it complains with:
Error(9,40): PLS-00302: component 'CONSTRUCT' must be declared
Error(10,10): PLS-00302: component 'SET_STRING_PROPERTY' must be declared
Error(11,16): PLS-00302: component 'CLEAR_BODY' must be declared
I think this code works out of procedure body, because I tried with success
recipes from What's in my JMS queue?
My Oracle version is:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
Any idea what can be wrong?
Looks like a database version problem. AQ$_JMS_STREAM_MESSAGE has a construct method in 10G but not in 9i. What version of Oracle Server are you using?
Looks like grants again
GRANT EXECUTE ON SYS.aq$_jms_stream_message To <your-user>;
Does:
desc sys.aq$_jms_stream_message
work in SQL*Plus from both the SYS + your schema?
Note that SYS.AQ$_JMS_STREAM_MESSAGE is a datbase object/type, whereas SYS.DBMS_AQ is a package
EDIT
Ok... maybe the TYPE body is missing / invalid. What does:
SELECT owner, object_name, object_type, status
FROM dba_OBJECTS
WHERE OBJECT_NAME = 'AQ$_JMS_STREAM_MESSAGE'
return?

Resources