I am getting the error at line 7 (see the code below) which is specified by 10g as :
"Statement ignored"
Can anyone tell me what I'm doing wrong?
create or replace trigger demo1_bifer
BEFORE INSERT ON demo1
FOR EACH ROW
declare
lock_id number;
resource_busy exception;
pragma EXCEPTION_INIT(resource_busy,-54);
begin
lock_id := dbms_utility.get_hash_value(to_char(:new.x),0,1024);
if (dbms_lock.request( id => lock_id,lockmode => dbms_lock.x_mode, timeout => 0, release_on_commmit => TRUE) not in (0,4))
then raise resource_busy;
end if;
end;
/
You have mistyped commit in the parameter name release_on_commmit. Delete one of the three ms.
On my system (Oracle 11g XE) I also got an error PLS-00201: identifier 'DBMS_LOCK' must be declared. To fix this I needed to grant EXECUTE on DBMS_LOCK to the user I was creating the trigger as.
Related
When I generate the SQL using PowerDesigner and run it in Oracle, it throws the error
Warning:Trigger creation with compilation errors
create trigger "tib_material_classify" before insert
on "material_classify" for each row
declare
integrity_error exception;
errno integer;
errmsg char(200);
dummy integer;
found boolean;
begin
-- column ""id"" uses sequence material_classify_seq;
select material_classify_seq.nextval into :new."id" from dual;
-- errors handling
exception
when integrity_error then
raise_application_error(errno, errmsg);
end;
When I issue show errors in Oracle, it says the following:
10/5 PL/SQL: SQL Statement ignored
10/12 PL/SQL: ORA-02289: sequence does not exist
What am I doing wrong?
The error message suggests that sequence material_classify_seq is missing. You can create the missing sequence with the following SQL statement:
Create Sequence material_classify_seq;
Before create trigger you need create sequnce
Create sequence material_classify_seq start with 1; after create trigger
I have a procedure created and i am using a merge query inside it.
when i compile the procedure, there is no error and when i try to execute it giving me
below error. Can someone help in solving this.
Code:
CREATE OR REPLACE PROCEDURE DEVICE.Check1
IS
BEGIN
MERGE INTO DEVICE.APP_C_CATEGORY A
USING (SELECT market_segment_id,
market_segment_name,
UPDATE_USER,
UPDATE_DATE
FROM CUST_INTEL.MSE_MARKET_SEGMENT_MASTER#SOURCE_CUST_INTEL.ITG.TI.COM
WHERE market_segment_id NOT IN ('120', '130', '100')) B
ON (A.APP_CATEGORY_ID = B.market_segment_id
AND A.APP_CATEGORY_NAME = B.market_segment_name)
WHEN MATCHED
THEN
UPDATE SET A.DESCRIPTION = B.market_segment_name,
A.PARENT_APP_AREA_ID = NULL,
A.RECORD_CHANGED_BY = B.UPDATE_USER,
A.RECORD_CHANGE_DATE = B.UPDATE_DATE
WHEN NOT MATCHED
THEN
INSERT (A.APP_CATEGORY_NAME,
A.DESCRIPTION,
A.TYPE,
A.PARENT_APP_AREA_ID,
A.RECORD_CHANGED_BY,
A.RECORD_CHANGE_DATE)
VALUES (B.market_segment_name,
B.market_segment_name,
1,
NULL,
B.UPDATE_USER,
B.UPDATE_DATE);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
DBMS_OUTPUT.PUT_LINE (SQLERRM);
DBMS_OUTPUT.PUT_LINE (SQLCODE);
END;
/
Error: when i am executing
BEGIN
DEVICE.CHECK1;
COMMIT;
END;
the following errors occur:
ORA-06550: line 2, column 10:
PLS-00302: component 'CHECK1' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
This is nothing to do with the merge, it isn't getting as far as actually executing your procedure. From the create procedure statement you have a schema called DEVICE. Since the error message is only complaining about CHECK1, not DEVICE.CHECK1, you also appear to have a package called DEVICE. Your anonymous block is trying to find a procedure called CHECK1 within that package, not at schema level.
If you are connected as the device schema owner (user) when you execute this, just remove the schema prefix:
BEGIN
CHECK1;
COMMIT;
END;
/
I executed a PL/SQL script that created the following table
TABLE_NAME VARCHAR2(30) := 'B2BOWNER.SSC_Page_Map';
I made an insert function for this table using arguments
CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert(
p_page_id IN B2BOWNER.SSC_Page_Map.Page_ID_NBR%TYPE,
p_page_type IN B2BOWNER.SSC_Page_Map.Page_Type%TYPE,
p_page_dcpn IN B2BOWNER.SSC_Page_Map.Page_Dcpn%TYPE)
I was notified I had to declare B2BOWNER.SSC_Page_Map prior to it appearing as an argument to my function. Why am I getting this error?
EDIT: Actual error
Warning: compiled but with compilation errors
Errors for FUNCTION F_SSC_PAGE_MAP_INSERT
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/48 PLS-00201: identifier 'SSC_PAGE_MAP.PAGE_ID_NBR' must be declared
0/0 PL/SQL: Compilation unit analysis terminated
EDIT: Complete PL/SQL Function
RETURN INTEGER
IS
TABLE_DOES_NOT_EXIST exception;
PRAGMA EXCEPTION_INIT(TABLE_DOES_NOT_EXIST, -942); -- ORA-00942
BEGIN
INSERT INTO
B2BOWNER.SSC_Page_Map VALUES(
p_page_id,
p_page_type,
p_page_dcpn);
RETURN 0;
EXCEPTION
WHEN TABLE_DOES_NOT_EXIST THEN
RETURN -1;
WHEN DUP_VAL_ON_INDEX THEN
RETURN -2;
WHEN INVALID_NUMBER THEN
RETURN -3;
WHEN OTHERS THEN
RETURN -4;
END;
SHOW ERRORS PROCEDURE F_SSC_Page_Map_Insert;
GRANT EXECUTE ON F_SSC_Page_Map_Insert TO B2B_USER_DBROLE;
RETURN INTEGER
EDIT: I change the arguments and received a new error related to the insert command
CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert(
p_page_id IN INTEGER,
p_page_type IN VARCHAR2,
p_page_dcpn IN VARCHAR2)
RETURN INTEGER
IS
TABLE_DOES_NOT_EXIST exception;
PRAGMA EXCEPTION_INIT(TABLE_DOES_NOT_EXIST, -942); -- ORA-00942
BEGIN
INSERT INTO
B2BOWNER.SSC_Page_Map VALUES(
p_page_id,
p_page_type,
p_page_dcpn);
The error
Errors for FUNCTION F_SSC_PAGE_MAP_INSERT
LINE/COL ERROR
-------- -----------------------------------------------------------------
17/18 PL/SQL: ORA-00942: table or view does not exist
16/5 PL/SQL: SQL Statement ignored
The tables has been verified within the correct schema and with the correct attribute names and types
EDIT: I executed the following command to check if I have access
DECLARE
count_this INTEGER;
BEGIN
select count(*) into count_this
from all_tables
where owner = 'B2BOWNER'
and table_name = 'SSC_PAGE_MAP';
DBMS_OUTPUT.PUT_LINE(count_this);
END;
The output I received is
1
PL/SQL procedure successfully completed.
I have access to the table.
EDIT:
So I finally conducted an insert into the table via the schema using PL/SQL and it worked fine. It appears I simply do not have authority to create functions but that is an assumption.
EDIT:
Actual table DDL statement
v_create := 'CREATE TABLE ' || TABLE_NAME || ' (
PAGE_ID_NBR NUMERIC(10) NOT NULL Check(Page_ID_NBR > 0),
PAGE_TYPE VARCHAR2(50) NOT NULL,
PAGE_DCPN VARCHAR2(100) NOT NULL,
PRIMARY KEY(Page_ID_NBR, Page_Type))';
EXECUTE IMMEDIATE v_create;
COMMIT WORK;
COMMIT COMMENT 'Create Table';
When creating the TABLE under B2BOWNER, be sure to prefix the PL/SQL function with the Schema name; i.e. B2BOWNER.F_SSC_Page_Map_Insert.
I did not realize this until the DBAs pointed it out. I could have created the table under my root USER/SCHEMA and the PL/SQL function would have worked fine.
The procedure name should be in caps while creating procedure in database.
You may use small letters for your procedure name while calling from Java class like:
String getDBUSERByUserIdSql = "{call getDBUSERByUserId(?,?,?,?)}";
In database the name of procedure should be:
GETDBUSERBYUSERID -- (all letters in caps only)
This serves as one of the solutions for this problem.
you should give permission on your db
grant execute on (packageName or tableName) to user;
Package mypackage.bdy owned by user mq has a public procedure CALCTAX. This procedure refers to a table TAXINFO owned by another mr.
code
PROCEDURE CALCTAX(P_TAX_END_DAT IN DATE,
P_CODE IN VARCHAR2,
P_DEFER OUT NUMBER) IS
BEGIN
IF (P_TAX_END_DAT <= V_FECHA_FIN_PERIODO) THEN
P_DEFER := 15;
ELSE
BEGIN
SELECT 15
INTO P_DEFER
FROM MR.taxinfo T
WHERE SUBSTR(P_MINOR_CODE, 2, 5) IN T.TAX_CODE_NAME;
EXCEPTION
when not found
....
I get the error PL/SQL: SQL Statement ignored PL/SQL: ORA-00942: table or view does not exist while trying to compile the package.
Can anyone help me solve this issue?
Try this DCL and then your procedure
GRANT SELECT ON MR.TAXINFO TO MQ;
I have pl/sql anonymous block like below
declare
v_count pls_integer := 0;
begin
select count(1) from product_component_version
into v_count
where product like '%Enterprise%';
if v_count = 0 then
raise program_error;
end if;
exception
when program_error then
raise_application_error (-20001, 'This is valid for Oracle Enterprise Edition only!');
end;
When I try to execute the above,I am getting the below error
ORA-06550: line 5, column 5:
PL/SQL: ORA-00933: SQL command not properly ended
Which is nothing but for "into v_count" statement.
As per my understanding the syntax is wrong and when I changed that statemnt like below it is working fine.
select count(1) into v_count
from product_component_version
where product like '%Enterprise%';
I have tested this in "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit".
But the original script is available in all our older versions of our product.
I would like to know the syntax in original script is supported in older oracle versions?
Or can you please let me know any information on this which can answer my confusion?
Thanks,
Vijay
With a test block:
declare
x dual.dummy%type;
begin
select dummy from dual into x;
end;
/
In Oracle 9iR2 (9.2.0.8 on Solaris), 10gR2 (10.2.0.5 on Solaris) and 11gR2 (11.2.0.3 on Linux) I get exactly the same error:
select dummy from dual into x;
*
ERROR at line 4:
ORA-06550: line 4, column 28:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 4, column 5:
PL/SQL: SQL Statement ignored
I don't believe it has ever been supported the way you had it, though I don't have an 8i or earlier database to test against.
You said 'the original script is available in all our older versions of our product', but would it actually ever have been run, and if so can you identify an exact version it didn't raise an error against?
At least not from 8i onwards:
http://www.oracle.com/pls/tahiti/tahiti.tabbed?section=49135
Even i don't thing so about select dummy from dual into x;
try this:
declare
v_count pls_integer := 0;
begin
select count(1) into v_count from product_component_version
where product like '%Enterprise%';
if v_count = 0 then
raise program_error;
end if;
exception
when program_error then
raise_application_error (-20001, 'This is valid for Oracle Enterprise Edition only!');
end;