title: Error: maximum number of recursive SQL levels (50) exceeded
body: <p>I want to enforce integrity so that a Person can't loan a book more than once a day. The tables &amp; trigger compiles without errors but and i get the above error when u try to insert. I can't fix it. Syntax:</p>
  
  <pre><code>create or replace trigger chk_DateL
  for insert or update on lending
  COMPOUND TRIGGER
  --declare
  L_Date number(1);
  avail varchar2(10);
  subtype copy_booksRec is lending%ROWTYPE;
  type copied_bks is table of copy_booksRec;
  cbks copied_bks := copied_bks();
  
  after each row is 
  begin
    cbks.extend;
    cbks(cbks.last).cb_num := :new.cb_num;
    cbks(cbks.last).sb_num := :new.sb_num;
  end after each row;
  
  after statement is
  begin
    for i in cbks.first .. cbks.last loop
      select loancode into avail from copy_books where num = cbks(i).cb_num;
      select count(date_L) into L_Date from lending where sb_num = cbks(i).sb_num and date_L = cbks(i).date_L;
        if (L_Date = 0) then
          insert into Lending values (cbks(i).cb_num, cbks(i).sb_num, cbks(i).date_L);
          update copy_books set loancode = 'Not' where num = cbks(i).cb_num;
  --        cbks(i).date_L := cbks(i).date_L;
      else
        dbms_output.put_line('You can only make ONE LOAN in a day! You have already loaned a book on ' || L_Date);
        cbks.delete;
      end if;
    end loop;
    end after statement;
  end chk_DateL;
  /
  show errors
  </code></pre>