How to run DDL in a Trigger?

I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.
. The problem is, I am getting an ERROR at line 1:
ORA-04092: cannot COMMIT in a trigger
CREATE OR REPLACE TRIGGER TESTER.AUTO_QUOTA
AFTER INSERT ON USERS FOR EACH ROW
DECLARE
sqlstmt     VARCHAR2(100);
BEGIN
sqlstmt:='ALTER USER ' || :NEW.USERNAME || ' QUOTA UNLIMITED ON ' || :NEW.TABLESPACE_NAME;
execute IMMEDIATE SQLSTMT;
END;
/

ji**** wrote:
I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.This approach is wrong.
What is the purpose of a trigger? The answer is protecting the integrity of the transaction - not to do "extra stuff" outside the current actual business transaction. Like sending e-mails. Or SMS's. Or issue DDL commands.
What happens when you do "extra stuff" in that trigger and the transaction is rolled back for example? What now happens to that "extra stuff" that should not have existed/have been done in the first place?
The correct approach is to create a procedure or package that does this "extra stuff". Then schedule a job from this trigger to call that procedure.
When the transaction commits, so too is the job to do the "extra stuff". If the trigger is rolled back, so too the submission of the job. And the trigger does not need smelly approaches like autonomous transactions for getting "extra stuff" done.

Similar Messages

  • How to run batch file using trigger?

    Hi, i am trying run a batch file using a trigger on a table.
    say i have a table XYZ(col_1 varchar2 primary key, col_2 varchar2)
    the values of col_2 keeps changing and col_1 are constant
    whenever the value of col_2 in any row changes from "on" to "off" i want to run a batch file C:\Users\ABC\Desktop\test.bat
    i did some searching but couldn't find any solution. Thanks in advance
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

    >
    the script will be started around 60-70 times a day
    >
    No - as marwim said the script will be executed every time the trigger is fired. And that trigger, depending on how it is written, might be fired several times for the same transaction.
    And if the trigger is fired the script will be executed even if the transaction that caused the trigger to fire issues a ROLLBACK.
    Triggers are non-transactional. You need to clearly define the business rules for when the script should run. Should it run only when the transaction is COMMITTED? Or should it run if the transaction executes even if the transaction performs a ROLLBACK?
    A trigger is the wrong solution for your problem.
    Please clarify what the business rules are that should control the execution of the script.

  • How to run a batch file using tigger....

    Hi, i am trying run a batch file using a trigger on a table.
    say i have a table XYZ(col_1 varchar2 primary key, col_2 varchar2)
    the values of col_2 keeps changing and col_1 are constant
    whenever the value of col_2 in any row changes from "on" to "off" i want to run a batch file C:\Users\ABC\Desktop\test.bat
    i did some searching but couldn't find any solution. Thanks in advance
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    sorry wrong foum to post.
    will post in the correct one
    how to run batch file using trigger?

    Hallo,
    welcome to the forum.
    This is the forum for the tool {forum:id=260}. Your question should be placed in {forum:id=75} or {forum:id=61}.
    When you post your question there please provide additional information like db version, what kind of trigger you want to use, how you want to prevent the execution when the transaction is rolled back... {message:id=9360002}
    Regards
    Marcus

  • How to run drill down reports

    now i am using 9ids
    Before dev 2.1 was used.
    now before we had provision to run drill reports
    by putting a button on report
    and using
    srw.run_report(); procedure ,in button action trigger.
    now in 9i what i observed there is no object button in reports.
    button has changed to text item and there is no such action trigger.
    how to run the report
    as reports are run from form by using
    web.show_document
    pls suggest.

    Hi Rajendra,
    Again prasanth here, As u said, there is no more push button in 9i and 10g, ok. so u can drill down reports by using hyperliks which is only way(according to me). some may suggest to include JSP buttons. But u can simply place any text item like 'click here to run report' and in the property inspector(i.e.property pallette) set the hyper link property with the desination of your file. It may be a weblink or may be local file path.
    example
    hyperlink: www.oracle.com/..or
    c:\temp\test.rdf
    or u can write a trigger for that text item:
    1)right clik the text item
    2)goto pl/sql editor
    3)put the code
    a varchar(30);
    begin
    a:=srw_run_report('<the report link you want')
    return(a);
    but before doing this make sure that the item type of tha t text item property should be pl/sql(this can be set in property pallete of that text item)
    I think this help you,
    Thanks and Regards
    Prasanth A.S.

  • How to handle DDL in remote database

    Hi our db running on 10g. How to handle DDL's on the remote database? My requirement is as a object migration, how to migrate object/s from database A to database B through user. Say i have table call my_table in database A I want to create/replace this table on database B as a database user. Is there a way can be done? Database link or streams or any other method?
    Thanks in advance,
    -B

    You have many options to do this, just to name a few
    use COPY command of SQLPLUS
    SQL> copy from scott/tiger@DB_A
             to scott/tiger@DB_B
             create new_emp using select * from emp;create database link to database A in database B, run this from database B
    create new_emp as select * from emp@dblinkDB_A;or export/import
    etc.

  • How to run the form without logon?

    sir:
    I want to create the application without logon,but before the
    form appear,I must logon, I want to know how to run the form
    without logon(comment:I don't connect to database!);
    null

    steve (guest) wrote:
    : Create trigger ON-LOGON. Supply alternative logon code
    : or NULL; if you want to do nothing. Form will execute
    : but will not produce logon window.
    : gang lee (guest) wrote:
    : : sir:
    : : I want to create the application without logon,but before
    the
    : : form appear,I must logon, I want to know how to run the form
    : : without logon(comment:I don't connect to database!);
    Mr steve,thanks for your help!
    null

  • How to run report server in oracle 9i DS

    hi..
    can any 1 tell me how to run report server in oracle 9i DS
    i've installed oracle 9i DS, but don't know how to run
    report server.
    actually i want to run a report from my form
    on button press trigger.. some of the experts r tellin
    that 1st u check whether report server is running or not..
    so pls tell me how to install report server.
    while installing oracle 9i DS, i've given Mail server
    as mysmtp.com
    Thanks
    amit

    hi ..
    i've to go in this directory n run
    rwserver -install repservername
    where repserver name is my mailserver..
    this will install reports server
    Amit

  • How to run VI using bolean control?

    How to run VI using bolean control? Do I need to use invoke node or something else?
    Thank you in advance.

    You cannot start running a vi using a boolean on the front panel of that same VI. Detecting the state of the control requires the VI to be running.
    Maybe you can clarify WHY you need to do this. The run button is for VI development. Once you have a final application, it should be set to "run when opened". The actual code could start out in a wait loop (or wait event) such that pressing a certain button will trigger execution of the main code as needed.
    LabVIEW Champion . Do more with less code and in less time .

  • How to run the paper layout & web layout?

    Hi,
    I have 10gR2 application server (Linux). A report was created in Reports 6i, now i opened the same in 10g and compiled in my local machine(development pc with windows xp).
    question 1
    In the development pc, i can run the paper layout but the same cant in web layout.
    1. How to run the weblayout?
    question 2
    Now my application is running in&as web enabled. A menu calling a report ,that i want to run as paper layout, is it possible in web enable mode? Otherwise i have to run as web layout.
    please guide me.
    Kanish

    Thanks for the advice.
    I am trying to run any iViews that connect to the R/3 back end.  I have read that you have to first connect to the SLD, and then set up the JCO connections.  Correct?
    I have got the SLD running, but I can't connect to it.  I have supplied the required SLD Data Supplier information in the Content Administrator. 
    In the Visual Administrator, under the SLD Data Supplier, I enter the Host, Port, User, and Password, but when I hit the Trigger Data button I get an error saying "Operation Failed!  Failed to collect SLD data.  Failed to send HTTP data: 401: Unauthorized.  Please check if the target SLD system is available and the SLD bridge is started there."
    Any help?

  • ISR on Portal - how to run it?

    Hi guys!
    I try to implement ISR on portal. In ERP, you run it through Office item in menu.. But, is teher a way, how to run it in portal?
    Thanx 4 answers!
    Peter

    Check your regular PC shop, Newegg, SilentPCReview.com there is no special right one, just has to fit, and my Mac Pro has some dampeners that fit between the door and case, but the vibration is on the upper front and lower back corners, even though it seemed to start with addition of hard drive.
    Over the 4 yrs there have been a good dozen or more threads on what, why, and how this hum and whether different drive hums can trigger such a clash.
    For a long time I kept my case on its side (using coffee table) because the high pitch was otherwise so annoying the minute I entered the room, not loud but a "just right" (or wrong) pitch. Now it seems to be okay (and after I built what I hoped was the ultimate silent PC).

  • How to run a batch file clicking a button?

    Hi All,
    Can you tell me anyone how to run a batch file clicking a button? And also the progress bar showing the progress.
    Arif

    As said: write the insert statement like above (of course replace the databaselink, column and table names with your own) in a stored procedure and call this procedure in the WHEN-BUTTON-PRESSED Trigger.
    As for the progress bar: how many records are you processing and how is the network connection between your database server? As above method is rather fast it might take just a few seconds and you could spare you the progress bar (this might be a little tricky to implement).
    cheers

  • HOW TO RUN ADOBE READER IN MACBOOK PRO

    HOW TO RUN ADOBE READER IN MACBOOK PRO

    Please stop using caps.  It is considered shouting and rude.
    You need to download the program. The reader runs when needed.
    Barry

  • How to run 'Get-AssignedAccess' or 'Set-AssignedAccess' power shell commands in c# Application

    Hi,
    I have console application using which i am trying to run power shell command  like 'Get-AssignedAccess' or 'Set-AssignedAccess'.
    i am using below code for this it is throwing exception 'Get-AssignedAccess' doesn't exist in cmdlet which is correct because these commands belongs to function category.
    using (PowerShell pwInstance = PowerShell.Create())
                            pwInstance .AddScript("Get-AssignedAccess");
                            var result = pwInstance .Invoke();
    How can we execute this kind of command using c#?
    Thanks,

    Hi prakashlight,
    Thank you for comming back and tell us the result. For more information about how to run PowerShell script in C# language, you can refer to this blogpost here:
    Executing PowerShell scripts from C#
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Does anyone know How to run twin monitors on a MacBook Pro operating on a Windows Server 2008 R2 ?

    Hi
    Does anyone know How to run twin monitors on a MacBook Pro operating on a Windows Server 2008 R2 ?

    I know this doesn't help you much, but, I think you have to see if your Mac pro does audio out via HDMI. I don't even know if mine does via DVI. I think it may have to do with the adapter. Try going into Audio MIDI and setting the digital out to multichannel
    and using the toslink cable for now. Lemme see...apparently DVI does not carry audio at all. Hm. apparently monoprice could be helpful?  If I understand what you're saying correctly: you want to take DVI and multichannel audio via the Toslink and have it all go out over HDMI, right? Whooo..... amazon...looks like it's about $100http://www.amazon.com/Audio-SPDIF-Toslink-Converter-Adapter/dp/B0015YYOQQ
    just a shot in the dark
    I'm probably wrong....or not
    John B

  • How to run expdp from client ?

    Hi All,
    I tried searching google and forums for my issue but to no avail > How to run expdp from client side ....like in my laptop.
    Because currently our PROD database server has no space for expdp dump file. So I want it directed to my laptop which has an extenal USB of 1TB harddisk...via client EXPDP
    import data using impdp command
    Posted on: 08-May-2012 11:36, by user: 841731 -- Relevance: 53% -- Show all results within this thread
    below command is correct or not? if it is not correct could you please send me the correct command. impdp user/pass@databasename schemas=sourceschemaname remap_schema=sourceschemaname:destinationschemaname ...
    System generated Index names different on target database after expdp/impdp
    Posted on: 30-May-2012 11:58, by user: 895124 -- Relevance: 43% -- Show all results within this thread
    After performing expdp/impdp to move data from one database (A) to another (B), the system name generated indexes has different ...
    [ETL] TTS vs expdp/impdp vs ctas (dblink
    Posted on: 08-May-2012 21:10, by user: 869578 -- Relevance: 39% -- Show all results within this thread
    (table : 500 giga, index : 500 giga), how much faster is TTS (transportable tablespace) over expdp/impdp, and over ctas (dblink) ? As you know, the speed of etl depends on the hardware capacity. (io ...
    Oracle Client
    Posted on: 21-Jun-2012 22:47, by user: Sh**** -- Relevance: 32% -- Show all results within this thread
    Hi Guys, Please can you guys elaborate the difference between Oracle Client and Oracle Instant Client. Also, please can you advise from where I can download the Oracle normal ...
    Oracle 10g Client
    Posted on: 05-Jun-2012 10:11, by user: dzm -- Relevance: 26% -- Show all results within this thread
    to search at oracle site and this forum, but i wasn't able to find a link to download the oracle 10g client. I really need especificaly the 10g version. Anybody know the link or another way to download ...
    9i client to access 11g database
    Posted on: 22-Jun-2012 07:31, by user: kkrm333 -- Relevance: 24% -- Show all results within this thread
    Hi, Can i access a 11g database using 9i client? Thanks,
    SQLplus in Oracle Client
    Posted on: 14-Jun-2012 00:36, by user: Tim B. -- Relevance: 24% -- Show all results within this thread
    Hi, I tried to install an 11g oracle client in linux. As I've compared the files with the files when you install using the oracle instant ...
    Re: Information on Oracle Client 11202-1.1.4-6
    Posted on: 05-Jun-2012 03:33, by user: 898763 -- Relevance: 23% -- Show all results within this thread
    Actually thats the client requirement
    Analysing the performance of a single client
    Posted on: 28-Mar-2012 02:05, by user: 880172 -- Relevance: 23% -- Show all results within this thread
    timeouts even on some of the simplest queries. I want to try and get some data about how just this one client is performing and what it’s doing, but everything Google has thrown up so far is orientated around ...
    to make client connection as sys
    Posted on: 12-Jun-2012 22:04, by user: user11221081 -- Relevance: 23% -- Show all results within this thread
    Dear gurus can i connect to my server from my client machine with sysdba without giving sys password i have connected in different ways as sys@abc ...Thanks a lot.

    Though you can initiate the binary from your client side but for the file creation, there is no other way but to store it on the server side. So your best bet would be to get some space free on the server side of yours.
    Aman....

Maybe you are looking for

  • XSLT mapping for fixed values

    Hi, i am doing a XSLT mapping. i have a field which has fixed values(can be performed using graphical mapping). but the same i am not able to implement for XSLT. can anyone give me a idea about this <removed by moderator> Thanks Deepika Edited by: Mi

  • Top shows VM usage is 255G - 1.5.0_08 (R27.1.0) crash on Linux IA64

    Hi, We are running a tomcat process using Jrockit 1.5.0_08 on Linux IA64. The process keeps crashing after a couple of days. (I pasted the dump at the end of the post) I found something wierd when I monitored the process to validate if the process cr

  • Major issues with ICHAT in Snow Leopard

    I upgraded my computer to Snow Leopard just recently. Had issues got them fixed and now have worse issues. I could use my iChat yesterday and now all of a sudden when I try to sign in it says I don't have any accounts set up in iChat. When I try to g

  • Update Statement Help Please

    I'm coming from the MS SQL world LOL and Im trying to write an update statement but in Oracle there is no INNER JOIN. Can you give me some advice on how to do this please? UPDATE employee SET employee.name = tmpuser.name FROM employee INNER JOIN tmpu

  • Adding a Calendar to iWeb

    Does anyone know how I can add an active (ie updatable) calendar to iWeb 09? Thanks!!