Ask the Expert

How to execute DML in an Oracle trigger with EXECUTE IMMEDIATE

Is it possible to create an index within a trigger? I have to do that because to optimize my process I need an additional index on a table (that is created on the fly by another product). If the index doesn't exist, I create it. Last time I tried it I got a message that the DML is not authorized in the trigger.

    Requires Free Membership to View

You can execute DML in a trigger if that DML is part of the EXECUTE IMMEDIATE statement similar to the following:

   Stmt := 'CREATE INDEX my_index ON my_table(column)';

This was first published in November 2009

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: