Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to LOCK TABLE/READ ONLY table in own schema after data insertion
This can be done using policies also.
Policies are there for VPD and are having log of thing/features.
It solves your purpose also ..
We will create a function and it's returning value would be appended for each select/update/delete statement.
In your case we will be appending a *where caluse* for all update and delete statements to that table.
SQL> create table t as select rownum r
2 from dict where rownum < 11;
Table created.
SQL> select * from t;
R
1 2 3 4 5 6 7 8 9 10
10 rows selected.
SQL> create or replace function mypolfunc
2 (p_schema varchar2,p_object varchar2)
3 return varchar2
4 as
5 begin
6 return '1=0';
7* end;
SQL> /
Function created.
SQL> SQL> SQL> exec
PL/SQL procedure successfully completed.
SQL> select * from t;
R
1 2 3 4 5 6 7 8 9 10
10 rows selected.
SQL> delete from t;
0 rows deleted. <<--- because of '1=0'
SQL> update t set r=r ;
0 rows updated. <<---
SQL> select * from t;
R
1 2 3 4 5 6 7 8 9 10
10 rows selected.
Whenever you want to load database just disable the policy.
SQL> exec dbms_rls.enable_policy(user,'T','mypol',false)
PL/SQL procedure successfully completed.
SQL> delete from t;
10 rows deleted.
create or replace trigger
after insert or update on that table
begin
raise_application_error(-20001,' not allowed ' );
end;
/
sanjeev_atvankar_at_hotmail.com wrote:
> Jagjeet Singh wrote:
> > >But after inserting the data into call_by_call_hist i want to lock this
> > >table till next insert,that means no one can change the data from hist
> > >table i.e.In this hist table only insert and fire a query is possible.
> >
> > Do you want to lock the table after loading till next job.
> > or you want to block only updates.
> >
> > Regards,
> > Js
>
>
>