GRANT/REVOKE in system Trigger statement

Hello

I create DDL trigger and want to use the DCL statement in the trigger body. I wrote below bu trigger, it is invalid DDL operation s error in the outbreak.

Could anyone suggest how we can use the under DCL statement in the trigger body.

CREATE OR REPLACE TRIGGER trg_after_ddl
AFTER the DDL ON SCHEMA
BEGIN
IF (ora_login_user = 'X') THEN
IF (ora_database_name = ' XYZ.) WORLD ') THEN
RUN IMMEDIATELY "REVOKE CREATE TABLE X;
RUN IMMEDIATELY "REVOKE CREATE SEQUENCE X";
END IF;
END IF;
END;
/

Thank you.
Alok

You cannot run all sorts of DDL statements in Oracle triggers because you cannot perform COMMIT / ROLLBACK in the triggers of the Oracle: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1270

Edited by: P. Forstmann on June 24, 2009 09:09

Tags: Database

Similar Questions

  • Problem with granting/revoking of privileges on the SYSTEM (and other) tablespace

    Hello

    I'm new to this forum, so I hope I posted this topic in the wrong section.

    My problem is the following:

    I need to create a user that should have access to certain storage spaces. I read a lot of articles, tutorials, etc. (and google it of course :)), but I couldn't find a solution to my problem. I created a user with this command in SQLPLUS:

    SQL > create user identified by test test
    2 default tablespace users
    3 quota 5 m on users;

    Privileges to user test given, like this:

    SQL > grant connect to test;

    Grant succeeded.

    SQL > grant create table to test;

    Grant succeeded.

    OK, so the user must be able to connect and create dashboards on USERS tablespace. My problem is that the user can also create tables on other tablespaces. Also on the SYSTEM tablespace - I don't want. I have not affected all contingent on any other tablespace users, yet it can create arrays of anywhere. I'm obviously something wrong, since I tried this on two different installations of Oracle (we were under Linux with D Oracle version 11.2.0.2.0 and the other was Windows with 11.2.0.1.0) and I got the same result.

    These are all tablespaces on my db instance if she will give useful information:

    TABLESPACE_NAME
    ---------------
    SYSTEM
    SYSAUX
    UNDOTBS1
    TEMP
    USERS
    EXAMPLE OF

    P.S.: I also tried: SQL > change the quota of test user 0 on SYSTEM; but it did not help. The user can still create tables on the SYSTEM tablespace.

    I used this test user command to create a table on system tablespace:

    SQL > create table testtest (num number (8)) tablespace SYSTEM;

    Please, I would appreciate greatly any help on this.
    Thank you in advance.

    Blaz

    Edited by: 884002 08-Aug-2011 04:51

    Always the same questions frequently asked in this forum, so boring. Always of people who state they don't read the documentation, but still has not found an answer. So boring.

    Provide the output of the following

    Select *.
    of session_roles;

    Select *.
    of session_privs
    where privilege like '% UNLIMITED '.
    ;

    Select *.
    of user_ts_quotas

    logged in as user test.

    -----------------
    Sybrand Bakker
    Senior Oracle DBA

  • Problem of Grant/revoke / Clarification

    SQL> conn sys as sysdba
    Enter password:
    Connected.
    SQL> show user
    USER is "SYS"
    -- Create a user
    SQL> create user test identified by test ;
    
    User created.
    -- grant him the create table system privilege
    SQL> grant create session,create table to test;
    
    Grant succeeded.
    
    SQL> conn test/test
    Connected.
    SQL> create table t ( a number);
    
    Table created.
    
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64
    bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> conn sys as sysdba
    Enter password:
    Connected.
    SQL> revoke create table from test;
    
    Revoke succeeded.
    
    SQL> conn test/test
    Connected.
    SQL> create table tr(a number) ;
    create table tr(a number)
    *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    
    
    SQL> alter table t add b number;
    
    Table altered.
    
    SQL> drop table t;
    
    Table dropped.
    Hi all

    I started to go through the basics of the DBA to create a user. I came up with a scenario where it is difficult for me to understand or justify the following scenario.

    Step 1: Create a user(Eg: test) and grant create session and create system table privileges
    Step 2: Test user connection and create a table called you
    Step 3: Connect as sysdba and revoke the privilege to create test user table
    Step 4: Connect as user test and try to create a table where the user are not able to create due to insufficient privileges, but you are allowed to modify or delete the table

    Question:

    How is it possible to modify or delete a table where there is no privilege is available except create the privilege of the session of the user (test)

    Please explain the above scenario

    Thanks in advance
    Carole Kumar

    >
    Thanks for the reply and is not the same course, but the user has the privilege to create session only. then how it is possible to modify or delete?
    >
    If you had read that the doc mentioned that you would have found that there is no drop or modify privileges to the user owner of the table.

    See 'Paintings of a fall' in the DBA Guide
    >
    To remove a table that you no longer need, use the DROP TABLE statement. The table must be contained in your schema or you must have the DROP ANY TABLE system privilege.
    >
    See 'Edit the tables' in the DBA Guide
    http://docs.Oracle.com/CD/B28359_01/server.111/b28310/tables006.htm
    >
    You change a table using the ALTER TABLE statement. To modify a table, the table must be contained in your schema or you must have the privilege to ALTER object for the table or the privilege to ALTER ANY system TABLE.
    >
    And just because your user name is able to create the table when grant you CREATE TABLE does not mean that the user could actually INSERTING records in the table.

  • A trigger - States does not, other triggers work fine.

    Help, please! I've searched and searched and not found the answer to this, but it seems that it must be something simple.

    I started with a blank publication and have put all the triggers three upward in the same way. One is stuck in the active state, but the other 2 work as expected. They are all anchor links, with the link applied to the trigger, not the text inside the trigger area.

    This is how all three triggers are implemented:

    NewWins States Menu.pngOTB States Menu.png

    This is the behavior I get when published. 'New WINS' is still active:

    NewWins Active.pngOTB Active.png

    I work in the 2015.0.2.4 Muse and consultation in the latest versions of Chrome and Firefox.

    Thanks in advance for any help you can provide!

    We are already aware of this issue and working on it. We will inform you on the same thread.

    Thank you

    Sanjit

  • question about the call in the trigger statement

    I faced a question on the written examination.

    A CALL statement in a trigger to call
    package (a)
    procedure b)
    c function)
    (d) another trigger

    Can someone give me answer with reason?
    I used the CALL statement inside the trigger, but not allowing to use. Could be sooner in the oracle CALL statement, we can use... This isn't a guess, so I ask in the forum...
    Please guide me...



    Rgds,
    PC

    You can use the CALL in a trigger without using EXECUTE IMMEDIATE

    SQL> create table t1 (
      2    col1 number
      3  );
    
    Table created.
    
    SQL> create procedure t1_proc
      2  as
      3  begin
      4    dbms_output.put_line( 'In T1_PROC' );
      5  end;
      6  /
    
    Procedure created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create trigger trg_t1
      2    before insert on t1
      3    for each row
      4* call t1_proc
      5  /
    
    Trigger created.
    
    SQL> set serveroutput on;
    SQL> insert into t1 values( 1 );
    In T1_PROC
    
    1 row created.
    

    I see no reason that you would in fact intentionally structure your code this way in this day and age because it would be likely to lead to confusion for those who had to support it in the future. But it's a valid syntax that probably made sense back in Oracle 5.

    Justin

  • Icon bar system to States of bad network connection when it is connected with Windows 7

    I am connected to a wireless network, but the icon in the system tray area does not display the icon "bars wireless", instead, it shows the icon "disconnected the ethernet cable" (the square with a red X through it). How can I get Windows 7 to display the correct icon?

    When I click the icon, the pop-up shows my correct online status and I can't access the internet. In addition, all my software and drivers are up to date. The only thing that's wrong is the displayof the icon of evil.

    Note: This question was asked in a previous post, but the solution provided does not work. There is a user with the same problem that was not able to get the solution to work and the solution does not work for me either. What is the real solution to this problem? Link to previous post with the exactly the same problem and the solution of non-working: http://social.answers.microsoft.com/Forums/en-US/w7network/thread/c3ee2c3f-82e5-44c7-8f40-ee7fb7f48c83?ppud=4

    Run the network troubleshooter

    Using the troubleshooter from network in Windows 7
    http://Windows.Microsoft.com/en-us/Windows7/using-the-network-troubleshooter-in-Windows-7

    Replace the wireless network

    Setting up a wireless network
    http://Windows.Microsoft.com/en-us/Windows7/setting-up-a-wireless-network

    Latter has solved it for me!

    See you soon! "That's all a pension chequer nights and days,"
    Where destiny with men for pieces plays;
    Here and there, mates and kills.

    In a world without walls and fences, who needs windows and doors? Life sucks! Getting used to!

  • Format of variable varchar2 to the course insert in a trigger statement

    I have a trigger in my form that emits an insert into another table.

    Insert the dropper

    (phone)

    values

    (: dropperprospect.phone);

    On the insert, I want the value to include dashes, like 703-923-7000 instead of just being a string of numbers like 7039237000.  I need to do because of the transmission of data is stored on the table of the dropper.  How can I apply this format on my insert.

    Note: dropperprospect.phone is a varchar2 data type (12).  The phone on the dropper table column is also a varchar2 data type (12).

    Any help would be greatly appreciated.

    You'll have to SUBSTR() number phone and it concatenates return as well as dashes.  For example:

    DECLARE
      v_formatted_phone   VARCHAR2(15);
    BEGIN
      v_formatted_phone := SUBSTR(:dropperprospect,1,3)||'-'||SUBSTR(:dropperprospect,4,5)||'-'||SUBSTR(:dropperprospect,5,9);
      insert into dropper values(v_formatted_phone);
    END;
    

    Craig...

  • Output of a trigger statement

    Hello


    I'm seeing the output of a simple update trigger program, but it seems that its not get fired or probably I do not know how to see its outcome.

    If relaxation results in the insertion of data in another table... I get such a result, but not on the screen.

    I tried to relax and read the forum too but I don't get any

    Help, please...
    create or replace trigger print_salary_changes
      BEFORE delete or insert or update OF SALARY on employees
      for each row
         when(new.job_id<> 'AD_PRES') 
      declare
          sal_diff number;
       BEGIN   
          sal_diff:=:new.salary - :old.salary;
          dbms_output.put(:new.last_name||',');
          dbms_output.put('olD SALARY='||:old.salary||',');
          dbms_output.put('nEW SALARY='||:new.salary||',');
          dbms_output.put('Difference'||sal_diff);
    
     end;
     /
    
    TRIGGER print_salary_changes compiled
    If I try to update, I get the lines updated, but not the result of the trigger.
    update employees
    set salary= salary*1.07
    where department_id in(10,20,90);
    6 lines to date.


    Thank you

    Published by: to_learn on December 28, 2011 15:33

    Hello

    Dbms_output is useful for debugging and not much.

    If you use it only while you write and test the trigger, then it is acceptable to use it. Otherwise, you are better off inserting messages in another table, mnuch as you say so.

    In SQL * Plus, you have to say

    SET   SERVEROUTPUT   ON
    

    before calling dbms_output.put (or put_line); otherwise the message will not appear. You only need to do once in a session, but nothing bad happens if you unnecessarily.
    In the other front, there may be something similar to "SET SERVEROUTPUT ON" you need to do before you see the output of dbms_output or it is not possible to see.

  • How to use survey trigger on form6i statement

    I want to use the form6i instruction-level trigger, what does statement I don't understand? Can someone help me with this.

    Thank you

    Dear Sir

    See more of good example of statement-level trigger.

    Examples of trigger
         
    The following sections illustrate an example of each type of trigger.

    Before statement-level Trigger
         
    Here is an example of a simple before-level trigger statement that displays a message before an insert on the emp table operation.

    CREATE OR REPLACE TRIGGER emp_alert_trig
    BEFORE INSERT ON emp
    BEGIN
    DBMS_OUTPUT. Put_line ('new employees are about to be added');
    END;

    The following INSERT is built so that several new lines are inserted on a single execution of the command. For each line with an employee between 7900 and 7999 id, a new line is inserted with an incremented by 1000 employee id. Here are the results from the execution of the command when three new lines are inserted.

    INSERT INTO emp (empno, ename, deptno) + 1000 SELECT empno, ename, 40
    AND emp WHERE empno BETWEEN 7900-7999.

    New employees are about to be added

    SELECT empno, ename, deptno FROM emp WHERE empno BETWEEN 8900 AND 8999;

    EMPNO, ENAME, DEPTNO
    ---------- ---------- ----------
    8900 JAMES 40
    8902 FORD 40
    8934 MILLER 40

    The message, New employees are about to be added, appears once by the trigger shot, even if the result is the addition of three new lines.

    Thank you

  • Privileges granted to a role

    Hello

    Quick question on the privileges granted to a role...

    Scenario 1:
    ---------------

    create the CONNECT_ROLE role.

    Grant connect to connect_role;
    Grant, alter session to CONNECT_ROLE statement.
    grant create cluster to CONNECT_ROLE;
    grant create procedure CONNECT_ROLE;
    grant create sequence to CONNECT_ROLE;
    grant create synonym of CONNECT_ROLE;
    grant create table CONNECT_ROLE;
    grant create trigger to CONNECT_ROLE;
    create grant type to CONNECT_ROLE.
    grant create view to CONNECT_ROLE;
    grant debug connect session to the CONNECT_ROLE;

    grant connect_role to tom, mike;


    Scenario 2:
    ---------------

    create the dev_role role.

    Grant select on scott.emp to dev_role;
    Grant execute on rich.emp_pkg to dev_role;

    grant dev_role to tom, mike;


    To display the privileges that have been granted to a role, I created the following view.

    CREATE OR REPLACE VIEW CHECK_PRIVS
    (username, rolename, privilege)
    AS
    SELECT DECODE (SA1. GRANTEE #, 1, 'PUBLIC', U1.NAME), SUBSTR (U2.NAME, 1, 20),.
    SUBSTR (SPM.NAME, 1: 27)
    OF SYS. SYSAUTH$ SA1, SYS. SYSAUTH$ SA2, SYS. USER$ U1,
    SYS. USER$ U2, SYS. SYSTEM_PRIVILEGE_MAP SPM
    WHERE SA1. DEALER # = U1. THE USER #.
    AND SA1. PRIVILEGE # = U2. THE USER #.
    AND U2. USER # = SA2. DEALER #.
    AND SA2. PRIVILEGE # = SPM. PRIVILEGE
    UNION
    SELECT U.NAME, NULL, SUBSTR(SPM.NAME,1,27)
    OF SYS. SYSTEM_PRIVILEGE_MAP SPM, SYS. SYSAUTH$ SA, SYS. THE USER$ U
    WHERE SA. GRANTEE #= U.USER #.
    AND SA. PRIVILEGE #= SPM. PRIVILEGE


    I get the correct results of the esteem for the #1 scenario, but I don't get any results for the #2 sight. Am I missing something here?

    Thanks for your time.

    Object level of subsidies are not access privileges.

    Oracle already provide views to display system object and the level of privileges such as dba_tab_privs and dba_sys_privs so why do you need to create your own point of view?

    HTH - Mark D Powell.

  • Grant select on the object a.a to user b to user test

    Hello

    I am logged in as user test.

    I would like to issue the following grant.

    grant select on a.a to user b;
    

    Unfortunately, this does not work with the test user. But it works with SYS. What permissions are required for the declaration works as a test.

    Best regards

    Stone

    Documentation, https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_9013.htm#SQLRF01603

    Prerequisites

    To grant a privilege to system, one of the following conditions must be met:

    • You must have obtained the GRANT ANY PRIVILEGE system privilege. In this case, if you grant the system privilege to a role, then a user who has been granted the role doesn't have the privilege unless the role is enabled in the user's session.
    • You must have been granted the privilege of system with the ADMIN OPTION . In this case, if you grant the system privilege to a role, then a user who has been granted the role has the privilege without worrying if the role is enabled in the user's session.

    To grant a role, you must either got the role with the ADMIN OPTION or have received the GRANT ANY ROLE privilege system, or you must have already created the role.

    To grant a privilege object, you must have the object, or the owner of the object must have a permission you privileges of the object with the GRANT OPTION , or you must have obtained the GRANT ANY OBJECT PRIVILEGE system privilege. If you have the GRANT ANY OBJECT PRIVILEGE , then you can grant the privilege of the object only if the owner of the object could have granted the same privilege of object. In this case, the GRANTOR column of the DBA_TAB_PRIVS view displays the owner of the object rather than the user that issued the GRANT statement.

  • GRANT SELECT on a table to the user / role changes for the tab last_DDL

    Hello

    Is grant select (or any private object) to the user/role a DDL statement?

    GRANT SELECT on a table to the user / role changes the last_DDL to the table.
    1 > is this expected behavior?
    2 > no way in which we can grant select on a table by another user, without changing the DDL? (for example create view).


    The test is performed:

    Prior to the issuance:


    OBJECT_NAME CREATED TIMESTAMP LAST_DDL_TIME OWNER
    ------- ---------------------- ---------- ------------- --------------------
    AR HZ_CUSTOMER_PROFILES 8 MAY 00 13 MARCH 13 2003-06 - 26:12:41:29



    Grant statement:
    GRANT SELECT ON "AR". "' HZ_CUSTOMER_PROFILES ' TO 'AR_VIEW ';

    Note: AR_VIEW is a role, I tried granting also directly to the user.


    After the grant:

    OBJECT_NAME CREATED TIMESTAMP LAST_DDL_TIME OWNER
    ------- ---------------------- ---------- ------------- --------------------
    AR HZ_CUSTOMER_PROFILES 8 MAY 00 21 MARCH 13 2003-06 - 26:12:41:29



    Old thread, discuss whether Grant is DDL or not, but no documented conclusions.
    ( Re: Grant, revoke is DDL and DCL? )

    Please help in the assessment above.

    -Best regards,.
    Mani

    It's the DOF.

    After all, this isn't DML, it implicitly committed and you cannot use it directly in PL/SQL: features of DDL. :-)

  • Mod_user handling in a table using the trigger

    Hello

    I have a table with two columns value ' test' and the mod_user. Currently, the table has a before Update trigger to update the mod_user as a user of the system
    Now, I need to change the trigger to meet the criteria below

    (1) in an update statement if I manually put the mod_user, then it should be updated such as defined in the update statement.

    For example:
    UPDATE test
    Value = 1,
    mod_user = "xyz".
    WHERE value = 4;

    In the scenario above mod_user should be updated to "xyz" in the table

    (2) if I don't talk to any term set for mod_user, the default windows user should be changed in the table.
    UPDATE test
    Value = 1
    WHERE value = 4;

    In the scenario above mod_user should be updated as a user of windows in the table

    The trigger statement, I used doesn't seem to work.

    CREATE OR REPLACE TRIGGER t_mod_test
    BEFORE the UPDATE OF value WE test
    FOR EACH LINE
    BEGIN
    : new.mod_user: = NVL (SYS_CONTEXT ('USERENV', 'OS_USER'), USER);
    END;

    Any suggestions on how I can do the work of scenario would be very appreciated.

    Thanks in advance
    DAS

    It looks like you want something like

    SQL> create table test(
      2    value number,
      3    mod_user varchar2(100)
      4  );
    
    Table created.
    
    SQL> create or replace trigger t_mod_test
      2    before update on test
      3    for each row
      4  begin
      5    if( updating( 'MOD_USER' ) )
      6    then
      7      null;
      8    else
      9      :new.mod_user := NVL( sys_context('USERENV', 'OS_USER')
     10                           ,user );
     11    end if;
     12  end;
     13  /
    
    Trigger created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace trigger t_mod_test
      2    before update on test
      3    for each row
      4  begin
      5    if( not updating( 'MOD_USER' ) )
      6    then
      7      :new.mod_user := NVL( sys_context('USERENV', 'OS_USER')
      8                           ,user );
      9    end if;
     10* end;
    SQL> /
    
    Trigger created.
    
    SQL> insert into test values( 4, 'xyz' );
    
    1 row created.
    
    SQL> update test
      2     set value = 1
      3        ,mod_user = 'abc'
      4   where value = 4;
    
    1 row updated.
    
    SQL> select * from test;
    
         VALUE MOD_USER
    ---------- ----------
             1 abc
    
    SQL> update test
      2     set value = 2
      3   where value = 1;
    
    1 row updated.
    
    SQL> select * from test;
    
         VALUE
    ----------
    MOD_USER
    ------------------------------------------------------------------------------
    
             2
    JCAVEDDBC64\jcave
    
    SQL>
    

    Justin

  • switch bulean for trigger

    Hello everyone,

    I am puzzled about the problem I've encountered in my vi. It's acquisition of forces from a load cell and he recorded the coordinates of the point of my motion system.

    I added a block to trigger, which sends the TTL 5V signal to a PIV system, trigger works, and I can read signal meter and PIV starts its sequence after him. What I am tryint to accomplish is to start recording to the file and trigger at the same time.

    I tried to bulean my "writing on a file" control switch wire to digital bool > slot, but when I run vi, as soon as I press "record", labview freezes. If I create a bulean dedicated control for relaxation (which is what I have in attached file), everything works fine.

    Can someone proposes a possible solution?

    Thanks in advance

    Oleks

    Update,

    I found the problem. Apparently, I have to pay attention to the error message.  The cause for the program of 'freeze' was my attempts to write data in a switched to the broad external hard drive... Ouch

    It's working now.

    Oleks

  • State machine, controls, and indicators

    Hey everybody,

    I'm working on the conversion of a VI to use a state machine architecture. In other words, there are several buttons that trigger States through a structure of the event in the standby mode. Two States need write values in the same set of indicators, but the rest should be left alone. Several States also contain a Subvi, which takes a cluster entry. The cluster is composed of about 10 digital/boolean controls. I wonder what is the best way to deal with these two problems. I could use local variables or references, but that seems to be discouraged for most cases. I do not have access to the VI himself at the present time, but it might send more later if necessary.

    You could go with the local population, in this case it should be ok, or have an update-state indicator.

    I have probably to take the easy road and go with local to a simple state machine.

    /Y

Maybe you are looking for