Can't understand why Oracle did not fire any DDL trigger.
>SELECT * FROM V$VERSION
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Example from https://docs.oracle.com/en/database/oracle/oracle-database/21/lnpls/plsql-triggers.html#GUID-6CF3A208-0BE7-45FF-928C-A755526933D0
STUDENT> CREATE OR REPLACE TRIGGER drop_trigger
BEFORE DROP ON student.SCHEMA
BEGIN
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot drop object');
END;
[2022-04-29 11:28:09] completed in 293 ms
STUDENT> create table tbl1 (a integer)
[2022-04-29 11:28:16] completed in 124 ms
STUDENT> drop table tbl1
[2022-04-29 11:28:17] completed in 155 ms
user and schema - both "Student";
Absolutely the same with DDL-logging example from http://www.dba-oracle.com/sf_ora_04098_trigger_string_string_is_invalid_and_failed_re_validation.htm - no any results for
after ddl on schema
after ddl on student.schema
after ddl on database -- created from name of SYS user
All triggers a visible and shown as ENABLED at all_triggers .
There no problem-related message at user_errors or all_errors
Any suggestion?
Related
I am new to oracle. I am using oracle database 19c. I try to create a materialized view from a view. But i get "ORA-00942" error. Does this mean a mview cannot be created from a force editionable view or it is possible to create with any additional privileges? Thanks in advance.
sql>conn kish/password
Connected.
sql>create table ds as select * from dba_source;
Table created.
sql>create or replace force editionable view "dsv" as select * from ds;
View created.
sql>create materialized view dsmv as select * from dsv;
create materialized view dsmv as select * from dsv
*
ERROR at line 1:
ORA-00942: table or view does not exist
"dsv" is different from dsv. In Oracle, never use double quotes (unless you have a really, really good reason - and this isn't one).
Remove double quotes, entirely.
SQL> create view dsv as select * from dept;
View created.
SQL> create materialized view dsmv as select * from dsv;
Materialized view created.
SQL> select * from dsmv;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
I am using ALL_TABLES/ALL_TAB_COLUMNS to get count of tables in my schema (EDW_SRC) and another schema(EDW_STG). I get correct counts when i run the query in my sql developer as shown below. But if i put the same query inside a trigger, i get wrong count for other schema(EDW_STG).
Please refer below code:
(This is just a sample code to replicate the issue, not my business requirement. I am referring ALL_TAB_COLUMNS in my actual code to get the number of columns in a particular table in different schema, for which i have Select access.)
select user from dual;
USER
-----
EDW_SRC
DROP TABLE ABC;
Table ABC dropped.
CREATE TABLE ABC(ID NUMBER);
Table ABC created.
select count(1) EDW_STG_CNT
from all_tables
where owner='EDW_STG';--Different Schema
EDW_STG_CNT
----------
101
select count(1) EDW_SRC_CNT
from all_tables
where owner='EDW_SRC';--My Schema
EDW_SRC_CNT
------------
1554
create or replace trigger trig_test_dml_abc
before insert on abc
DECLARE
V_STG_CNT number :=NULL;
V_SRC_CNT number :=NULL;
begin
DBMS_OUTPUT.PUT_LINE('***** TRIGGER OUTPUT *****');
select count(1) into V_SRC_CNT from all_tables
where owner='EDW_SRC'; --My Schema
DBMS_OUTPUT.PUT_LINE('My Schema EDW_SRC_CNT :'||V_SRC_CNT);
select count(1) into V_STG_CNT from all_tables
where owner='EDW_STG'; --Different Schema
DBMS_OUTPUT.PUT_LINE('Different Schema EDW_STG_CNT :'||V_STG_CNT);
end;
Trigger TRIG_TEST_DML_ABC compiled
INSERT INTO ABC VALUES (2);
1 row inserted.
***** TRIGGER OUTPUT *****
My Schema EDW_SRC_CNT :1554
Different Schema EDW_STG_CNT :2
The Different Schema count should be 101. Why is it coming as 2.
Oracle Version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
Thanks
K
I create a CakePhp model following the right CakePhp naming conventions and add into the $sequence property the name of the sequence as it was created on the Oracle database.
Inserting one record via sql plus was ok, but inserting data via Cakephp triggers the error:
[code] => 2289
[message] => ORA-02289: the sequence does not exists
[offset] => 7 [sqltext] => SELECT my_sql_table_seq.currval FROM dual
Even after cleaning up the tmp/cache content i see the same error as if cakephp try to guess the sequence name even having the sequence property named in the right way.
Is there a way to see why it happens ?
It's obvious that you don't have a sequence called my_sql_table_seq in your oracle schema,
or perhaps you have this sequence in another schema and you're missing related schema name as prefix let's call myschema : select myschema.my_sql_table_seq.currval from dual;
( provided your schema is granted for this sequence to execute ) :
SQL> conn otherschema/password1
SQL> grant execute on my_sql_table_seq to myschema;
SQL> conn myschema/password2
SQL> select otherschema.my_sql_table_seq.currval from dual;
or just create a sequence :
SQL> conn myschema/password2
SQL> create sequence my_sql_table_seq increment by 1 minvalue 0;
SQL> select my_sql_table_seq.currval from dual;
I have been testing audit area in Oracle 11g. Unfortunately, after I go through below-described steps, I get no results in audit tables. I am connected to the database as store. Why is that?
GRANT AUDIT SYSTEM TO store;
GRANT AUDIT ANY TO store;
AUDIT CREATE ANY TABLE BY store;
CREATE TABLE test_mj_aud(
id INTEGER);
INSERT INTO test_mj_aud
VALUES (1);
COMMIT;
SELECT * FROM test_mj_aud;
SELECT * FROM user_audit_trail; --no results
SELECT * FROM db_audit_trail; --no results
I want to grant SELECT access to v$session to other users in an Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
but when I run this query:
SELECT owner, object_type FROM dba_objects WHERE object_name = 'V$SESSION';
I got this error:
00942. 00000 - "table or view does not exist"
Oracle v$ views are named V_$VIEWNAME and they have synonyms in format V$VIEWNAME and you can’t give privilege on a synonym. If you want to give permission to a V$ view you must give it like below
SQL> grant select on v_$session to hr;
We also needed a regular user without access to v$session to cleanup sessions. A function will execute with the privileges of the owning schema, so if you create a function as the user having access to V$SESSION you can execute it from the user not having the required privilege.
For example, IFH_OWNER has access to v$session, user id854812 doesn't:
As id854812:
select count(*) from v$session
ORA-00942: table or view does not exist
As IFH_OWNER:
select count(*) from v$session
56
create or replace function getSessionCount return int
as
vCnt int;
begin
select count(*) into vCnt from v$session;
return( vCnt);
end;
select getSessionCount from dual;
56
grant execute on getSessionCount to id854812;
As id854812:
select ifh_owner.getSessionCount from dual;
56