Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5968867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:09:01+00:00 2026-05-22T20:09:01+00:00

create or replace trigger insert_test_id before insert on test where(test.name=’Ash’) begin insert into test(s_no)

  • 0
create or replace trigger insert_test_id
before insert on test
where(test.name='Ash')
begin
insert into test(s_no) values('def');
end

my table is

test
id integer
name varchar2(200)
s_no varchar2(250)

please tell me that what is the error in this trigger. I am not able to find out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:09:02+00:00Added an answer on May 22, 2026 at 8:09 pm

    A quick glance at the online documentation would have told you that the conditional syntax is WHEN not WHERE.

    You should also reference the column using the NEW keyword rather than the table name. And as Gary rightly points out, we can only apply the conditional clause for ROW LEVEL triggers:

    SQL> create or replace trigger insert_test_id
      2  before insert on t23
      3  for each row
      4  when (new.name='Ash')
      5  begin
      6      insert into t23(name) values('def');
      7  end;
      8  /
    
    Trigger created.
    
    SQL> insert into t23 values ('abc')
      2  /
    
    1 row created.
    
    SQL> select name from t23
      2  /
    
    NAM
    ---
    abc
    
    1 rows selected.
    
    SQL>
    

    The condition works too…

    SQL> insert into t23 values ('Ash')
      2  /
    
    1 row created.
    
    SQL> select name from t23
      2  /
    
    NAM
    ---
    abc
    def
    Ash
    
    3 rows selected.
    
    SQL>
    

    It even works for multiple rows….

    SQL> insert into t23
      2  select txt from t42
      3  /
    
    4 rows created.
    
    SQL> select name from t23
      2  /
    
    NAM
    ---
    abc
    def
    Ash
    XXX
    ZZZ
    ABC
    DEF
    
    7 rows selected.
    
    SQL>
    

    So what’s the problem? This:

    SQL> create or replace trigger insert_test_id
      2  before insert on t23
      3  for each row
      4  when (new.name='def')
      5  begin
      6      insert into t23(name) values('def');
      7  end;
      8  /
    
    Trigger created.
    
    SQL> insert into t23 values ('def')
      2  /
    insert into t23 values ('def')
                *
    ERROR at line 1:
    ORA-00036: maximum number of recursive SQL levels (50) exceeded
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger 'APC.INSERT_TEST_ID'
    ORA-06512: at "APC.INSERT_TEST_ID", line 2
    ORA-04088: error during execution of trigger
    
    
    SQL>
    

    Of course I have cheated here, to generate the error. If both the test value and the substituted value are hard-coded the problem can be avoided. But if either is a lookup, then the risk of recursion is there.


    If what you actually want to do is replace an input value rather insert an additional row you should use the simple assignment syntax posted by @Lukas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trigger: CREATE TRIGGER tr_update_ts BEFORE INSERT OR UPDATE ON public.test FOR EACH ROW EXECUTE
create or replace trigger insert_catid before insert or update or delete on categories for
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
CREATE OR REPLACE TRIGGER UPDATE_TEST_280510 AFTER insert on TEST_TRNCOMPVISIT declare V_TRNCOMPNO NUMBER(10); CURSOR C1
I created a trigger as below: CREATE OR REPLACE TRIGGER trigger_test AFTER INSERT ON
I want to disable in before insert trigger inserting into table when some condition
I have the trigger: create or replace TRIGGER JACKET_DELETE BEFORE DELETE ON JACKET FOR
I'm using the following logon trigger on an Oracle 10.2 database: CREATE OR REPLACE
I have a table for which i have written a trigger: CREATE OR REPLACE
I tried using the following but apparently it's invalid SQL: CREATE OR REPLACE TRIGGER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.