I’m encountering permission and object recognition issues when creating and executing stored procedures in OceanBase Database. Here’s my environment:
Steps to Reproduce
CREATE TABLE test_proc (
id NUMBER PRIMARY KEY,
name VARCHAR2(50)
);
CREATE OR REPLACE PROCEDURE insert_test(
p_id IN NUMBER,
p_name IN VARCHAR2)
IS
BEGIN
INSERT INTO test_proc VALUES(p_id, p_name);
COMMIT;
END;
/
EXEC insert_test(1, 'test1');
-- Error: ORA-00942: table or view does not exist
Attempted Solutions
SELECT * FROM test_proc; -- Works fine
GRANT ALL PRIVILEGES TO current_user;
INSERT INTO current_user.test_proc VALUES(...);
-- Still fails with the same error
Question
Why can't existing tables be recognized in stored procedures? I’ve reviewed OceanBase’s official PL/SQL documentation but couldn’t resolve this.
I understand that this issue is about the permissions or scope of stored procedures
In OceanBase’s Oracle-compatible mode, stored procedures by default run using the permissions of the person who created them — not the person who calls them.
That means:
You might want to try adding an explicit schema name. Here’s an example:
CREATE OR REPLACE PROCEDURE insert_test(
p_id IN NUMBER,
p_name IN VARCHAR2)
IS
BEGIN
INSERT INTO YOUR_SCHEMA_NAME.test_proc VALUES(p_id, p_name);
COMMIT;
END;
/