How to create a Redact Policy in oracle - oracle

I am trying to create a redact policy to hide NIC from Customer table for all users.
BEGIN
DBMS_REDACT.ADD_POLICY (
object_schema => 'RETAILX',
object_name => 'CUSTOMER',
column_name => 'NIC',
policy_name => 'REDACT_NIC_POLICY',
function_type => DBMS_REDACT.PARTIAL,
function_parameters => 'MDy1',
expression => '1=1'
);
END;
Above is my code for the policy creation. However, I am getting an error while creating the policy. Error as below.
ORA-06550: line 7, column 27:
PLS-00201: identifier 'DBMS_REDACT' must be declared
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
What Could be wrong here?

Related

PLS-00201 Error Occured for the Trigger must be declared pls-00201

CREATE OR REPLACE TRIGGER trg_test
AFTER DELETE
ON ADMİN.KULLANICILAR
for each row
DECLARE
v_username := USER;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_username);
END;
Hey guys I'm getting that error always I put every privalege to my user and
it says :
after editing
CREATE OR REPLACE TRIGGER trg_test
AFTER DELETE
ON ADMİN.KULLANICILAR
for each row
DECLARE
v_username nvarchar2(20) := USER;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_username);
END;
and error like that it ll runs on apex but not on oracle sql dev:
BEGIN
DBMS_OUTPUT.PUT_LINE(v_username);
END;
Error report -
ORA-06550: line 2, column 26:
PLS-00201: identifier 'V_USERNAME' must be declared
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

Oracle: define job_priority in a Job dbms_scheduler

I Want to create a job with the highest priority in Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'parseMsg',
job_type => 'PLSQL_BLOCK',
job_action => 'begin S_IN_TDK.parseMsg; end;',
repeat_interval => 'FREQ=SECONDLY;INTERVAL=1',
enabled => true,
job_priority => 1,
comments => 'Job that polls device n2 every 1 seconds');
END;
but I got this error:
Informe de error -
ORA-06550: line 2, column 3:
PLS-00306: wrong number or types of arguments in call to 'CREATE_JOB'
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
https://docs.oracle.com/database/121/ARPLS/d_sched.htm#ARPLS72302
Not all possible job attributes can be set with CREATE_JOB. Some must
be set after the job is created. For example, job arguments must be
set with the SET_JOB_ARGUMENT_VALUE Procedure or the
SET_JOB_ANYDATA_VALUE Procedure. Other job attributes, such as
job_priority and max_runs, are set with the SET_ATTRIBUTE Procedure.

trigger compiling error in sqldeveloper with oracle11g

I have been studying triggers from
[ http://www.tutorialspoint.com/plsql/plsql_triggers.htm][1]
with sqldeveloper and I connected Oracle 11g database. I created customers table successfully. But when I tried to create trigger as :
CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
sal_diff number;
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line('Old salary: ' || :OLD.salary);
dbms_output.put_line('New salary: ' || :NEW.salary);
dbms_output.put_line('Salary difference: ' || sal_diff);
END;
I get these errors:
Error starting at line : 1 in command -
CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
sal_diff number
Error report -
SQL Command: trıgger DISPLAY_SALARY_CHANGES
Failed: Warning: yürütme uyarı ile tamamlandı
Error starting at line : 7 in command -
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line('Old salary: ' || :OLD.salary);
dbms_output.put_line('New salary: ' || :NEW.salary);
dbms_output.put_line('Salary difference: ' || sal_diff);
END;
Error report -
ORA-06550: line 2, column 5:
PLS-00201: identifier 'SAL_DIFF' must be declared
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
ORA-06550: line 3, column 60:
PLS-00487: Invalid reference to variable 'SQLDEVBIND1Z_2'
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
ORA-06550: line 4, column 60:
PLS-00487: Invalid reference to variable 'SQLDEVBIND1Z_1'
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
ORA-06550: line 5, column 51:
PLS-00201: identifier 'SAL_DIFF' must be declared
ORA-06550: line 5, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
What is wrong with this create trigger block?
It seems to be the same "Securing Literals" feature as described here
http://krisrice.io/2015-09-11-sqlcl-more-secure-now-with-rest/

SQL Procedure Errors

i am learning mysql and have moved onto procedures. I have created a procedure and i am trying to run it. But when I run the procedure i am faced with lots of errors, the error point to lines that have no errors that I can see, can anyone help me out?
This is the procedure I have created
create or replace PROCEDURE AD_AGENCY_INFO(
v_ad_id IN ad_agency.AGENCY_ID%TYPE,
v_cert IN ad_agency.NO_OF_AD_RUNS%TYPE,
v_price IN ad_agency.CREDIT_WORTHY%TYPE,
v_agency_id IN ad_agency.AGENCY_ID%TYPE
) AS
BEGIN
UPDATE AD SET AD_ID = v_ad_id, CERTIFICTAION = v_cert, PRICE = v_price where agency_id = v_agency_id;
INSERT INTO AD_SLOT (AD_ID) VALUES (v_ad_id);
EXCEPTION
WHEN NO_DATA_FOUND THEN
rollback;
END AD_AGENCY_INFO;
This is how I am calling the procedure
DECLARE
V_AGENCY_ID NUMBER:=&Enter_Agency_ID;
V_NO_OF_RUNS NUMBER:=&Enter_No_of_Runs;
V_CREDIT_WORTHY CHAR(3):=&Enter_Credit_Worthy;
V_AVAILABLE_SLOTS NUMBER:=&Enter_Available_Slots;
V_STATUS CHAR(1):=&Enter_Status;
BEGIN
V_AGENCY_ID := NULL;
V_NO_OF_RUNS := NULL;
V_CREDIT_WORTHY := NULL;
V_AVAILABLE_SLOTS := NULL;
V_STATUS := NULL;
AD_AGENCY_INFO(
V_AGENCY_ID => V_AGENCY_ID,
V_NO_OF_RUNS => V_NO_OF_RUNS,
V_CREDIT_WORTHY => V_CREDIT_WORTHY,
V_AVAILABLE_SLOTS => V_AVAILABLE_SLOTS,
V_STATUS => V_STATUS
);
END;
And this is the error log I get after running the procedure
Error report -
ORA-06550: line 4, column 28:
PLS-00201: identifier 'N' must be declared
ORA-06550: line 4, column 19:
PL/SQL: Item ignored
ORA-06550: line 6, column 21:
PLS-00201: identifier 'Y' must be declared
ORA-06550: line 6, column 12:
PL/SQL: Item ignored
ORA-06550: line 10, column 3:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 10, column 3:
PL/SQL: Statement ignored
ORA-06550: line 12, column 3:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 12, column 3:
PL/SQL: Statement ignored
ORA-06550: line 17, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 14, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
In the script that you're using to call the procedure, you're using substitution variables. They are replaced by their value before the script is interpreted. This means that a line like V_CREDIT_WORTHY CHAR(3):=&Enter_Credit_Worthy; with the value "no" will be translated into V_CREDIT_WORTHY CHAR(3):=no; You'll notice that "no" is unquoted there. In order to use substitution variables to pass a string to a PL/SQL script, you need to enclose the bind variable in quotes: V_CREDIT_WORTHY CHAR(3):='&Enter_Credit_Worthy';.
An alternative would be to use bind variables. They are interpreted as a part of the script and can therefore be treated as normal variable. To do this, you would simply need to replace the ampersands with colons. The line I referenced above would become V_CREDIT_WORTHY CHAR(3):=:Enter_Credit_Worthy;.

got pls-00201 when I call a package via public synonym in Oracle

I created a package named sf_timer in sys, then I created a public synonym on this:
create or replace public synonym sf_timer for sys.sf_timer;
select * from all_synonyms where synonym_name = 'SF_TIMER';
Then I call this package from another user:
set serveroutput on
declare
i integer;
j integer;
begin
sf_timer.start_timer;
for i in 1..100000
loop
j := j +1;
end loop;
sf_timer.show_elapsed_time('Test 1');
end;
/
Unfortunately I got error below:
Error report:
ORA-06550: line 5, column 3:
PLS-00201: identifier 'SF_TIMER' must be declared
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
ORA-06550: line 10, column 3:
PLS-00201: identifier 'SF_TIMER' must be declared
ORA-06550: line 10, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
I can see this public synonym from all_synonyms but I don't know why I cannot call the package in my schema.
Thanks in advance.
Have you granted permissions?
When running as SYS, do this...
GRANT EXECUTE ON SYS.SF_TIMER TO <user-you're-using>;
As a further note it's generally regarded as bad practise to create objects in the SYS schema :-)

Resources