Execute Oracle stored procedure in operation manager configuration - oracle

I have a stored procedure with 3 parameters. I want to execute this from configuration in operation manager. I used like this :
begin
saman_test.CONVERTHISTORY('$Config/JobType$','$Config/HostFQDN$','$Config/Environment$'); end;
but it does not work without any error.
And I used this code:
exec
saman_test.CONVERTHISTORY('$Config/JobType$','$Config/HostFQDN$','$Config/Environment$')
but I get this error :
ORA-00900: invalid SQL statement
How do I execute my procedure?

I find the keyword for execute my procedure.
call
saman_test.CONVERTHISTORY('$Config/JobType$','$Config/HostFQDN$','$Config/Environment$')

Related

PL/SQL ORA-01031 Insufficient Privilege In conditional statement

I've got pl/sql script which can be run in two modes: 1) on test database where I've got full access 2) on prod database where I've got limited access
part of the script:
<code>
IF mode = 'test' then
DELETE FROM TABLE1;
END IF;
</code>
In test database I've got full access to TABLE1 and I haven't got access in prod database so I don't want to execute delete staement. I want run the script on both databses just changing the mode parameter. But the compiler gives ORA-01031 Insufficient Privilege. Are there any methods to overcome the situation?
Use EXECUTE IMMEDIATE:
<code>
IF mode = 'test' then
EXECUTE IMMEDIATE 'DELETE FROM TABLE1';
END IF;
</code>

Oracle's dbms_metadata.get_ddl for type DIRECTORY: invalid input value for parameter SCHEMA

When I try to call dbms_metadata.get_ddl('TABLE', 'MYTABLE', 'MYSCHEMA') either in the pl/sql block or in the package procedure it works fine.
When I try to call dbms_metadata.get_ddl('TABLE', 'MYTABLE') (without schema explicitely provided) either in the pl/sql block or in the package procedure it works fine also.
When I try to call dbms_metadata.get_ddl('DIRECTORY', 'MYDIR') (without schema explicitely provided) in the pl/sql block it works fine also.
But,
When I try to call dbms_metadata.get_ddl('DIRECTORY', 'MYDIR', 'MYSCHEMA') either in the pl/sql block or in the package procedure it raises the error:
ORA-31600: invalid input value MYSCHEMA for parameter SCHEMA in function GET_DDL
When I try to call dbms_metadata.get_ddl('DIRECTORY', 'MYDIR') (without schema explicitely provided) in the package procedure it raises the error:
ORA-31603: object "MYDIR" of type DIRECTORY not found in schema "MYSCHEMA"
What is the problem?
EXECUTE_CATALOG_ROLE=true
SELECT_CATALOG_ROLE=true
'CREATE ANY DIRECTORY'=true
PL/SQL Release 12.2.0.1.0 - Production
You need to add the AUTHID CURRENT_USER clause (Docs)
create or replace procedure dir_ddl (dir_name in varchar2) AUTHID CURRENT_USER is
x clob;
begin
SELECT DBMS_METADATA.get_ddl ('DIRECTORY', dir_name) into x from dual;
dbms_output.put_line(x);
end dir_ddl;
/
set serveroutput on
exec dir_ddl('PLSHPROF_DIR')
And my output is...
Procedure DIR_DDL compiled
CREATE OR REPLACE DIRECTORY "PLSHPROF_DIR" AS '/home/oracle/profiler'
PL/SQL procedure successfully completed.
If I remove the AUTHID clause, I see the same error as you report.

Oracle triggers error on sqldeveloper export script

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

How to make to see the output result to execute PL/SQL from SQL Plus?

When i run PL/SQL statment from SQL Plus,I don't see my output result.However,it was successful completed but it don't show output result.
My code is here
DECLARE
message varchar2(20):= 'Hello World';
BEGIN
dbms_output.put_line(message);
END;
/
RESULT: PL/SQL is successfully completed.
It didn't show Hello World output.
You need use the command set serveroutput on to configure buffering for dbms_output like below. Check this Oracle Community Post
set serveroutput on size 15000;

Insufficient Priviledges error when trying to execute the procedure from package

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';

Resources