Oracle: disable trigger before Insert - oracle

I'm trying to write a transaction on Oracle DBMS to make a "simple" insert.
In a single transaction I want disable the trigger, make the Insert and re-enable the trigger... I'm working with C# and Oracle Db Oracle Database 11g.....
Is it possible?
How?
Thanks in advance

alter trigger trigger1 disable;

ALTER TABLE evaluations DISABLE ALL TRIGGERS;
ALTER TABLE evaluations ENABLE ALL TRIGGERS;

Related

Oracle trigger to listen to alter table statements

Is it possible to create a trigger in Oracle that gets triggered if any alter operation happens across any table schema wide ?
if yes then any examples would be appreciated.
Look at the create trigger documentation and search for the system trigger part. There are lots of examples on how to build system triggers and how they can fire on ddl

Cannot alter column 'column_name' because it is 'REPLICATED'

I am trying alter a Column however replication is not enabled or cdc. I am getting error Cannot alter column 'column_name' because it is 'REPLICATED'. I ran below TSQL
SELECT * FROM SYS.tables
WHERE NAME=N'ac_payment_info';
is_replicated=0
I would appreciate any help or workaround.
Im my case I had to disable the CDC on that table (sys.sp_cdc_disable_table), alter the column, and enable de CDC again (sys.sp_cdc_enable_table). It worked.
I do not use replication.

Oracle audit trigger code used for multiple tables with different table names

I have a requirement to populate an audit column with current timestamp only if there are any updates to the table. Here is the trigger. Trigger works fine
create or replace TRIGGER test.Audit_Trigger
BEFORE UPDATE ON test.TEST_TABLE
FOR EACH ROW
BEGIN
:NEW.column_dtm := current_timestamp;
END;
Instead of adding same trigger for every table (around 1000 tables means 1000 triggers) with only change in table name, is there any other better way to accomplish this task?
It would be nice if you could write a schema level trigger to do this, but unfortunately Oracle only supports schema level triggers for DDL, not for DML.
You could generate triggers on each table quite easily using dynamic SQL, but assuming your DB version is reasonably recent (9i or later I think), a better alternative might be to talk to your DBA about turning on fine grained auditing for table updates.
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4007.htm

Scheduling a job in oracle to drop and create table

I am trying to DROP and CREATE a table using a scheduled job. How to do it please?
DROP TABLE REGISTRATION;
CREATE TABLE REGISTRATION AS
SELECT *
FROM REGISTRATION_MV#D3PROD_KMDW
perhaps you are looking for a materialized view instead of the table?
create materialized view registration as
select *
from registration_mv#d3prod_kmdw
and then refresh it in job
dbms_mview.refresh('REGISTRATION');
This is much better than dropping and creating the table because PL/SQL objects will become invalid after dropping the table. With mview it will be silent and without harm.
You should use DBMS_SCHEDULER to schedule jobs in Oracle.
Refer to the documentation for how to create a sample scheduler job
Don't drop and recreate the table. If you do this on a regular basis you will end up with a huge number of items in your recycle bin, which can lead to problems. Also as above you can invalidate pl/sql when you drop objects, and can break your app if they fail to recompile.
Instead you should truncate the table to delete all rows, and then repopulate it:
truncate table registration;
insert into registration (select * from registration_mv#D3PROD_KMDW);

Oracle 10g - An invisible column?

Is it possible to 'hide' a column in an Oracle 10g database, or prevent data from being inserted altogether? We'd prefer to have existing INSERT statements still function, but have the information NOT insert for a particular column. Also, column masking or any type of encryption is not preferred.
Not sure if it's possible, but thanks in advance.
If all you need to do is stop data from being inserted, you could create a BEFORE INSERT FOR EACH ROW trigger that wipes out any value inserted into the column before the row is saved.
There are various other things you can do with security (also views) to prevent inserts/selects from particular users in particular circumstances, but these will probably not let existing inserts continue to work.
With Oracle feature virtual private database (VPD) you can define which users can change and which users can select a column. Virtual private database is also called fine-grained access control (FGAC).
I know how to hide the column.
You use the
SET UNUSED
option to mark one or more columns as unused.
You use the DROP
UNUSED COLUMNS
option to remove the columns that are marked as unused.
ALTER TABLE emp
SET UNUSED (last_name);
and
ALTER TABLE emp
DROP UNUSED COLUMNS;
Rename original table, create view with original table name but only selecting the columns you want to show.
Recompile code referring to existing table.
what about just setting your grants to each item you allow to update or insert
grant select on emp to scott;
grant update (column1, column2), insert (column1) on emp to scott

Resources