title: Trigger performing insert
body: <p>I have to create a trigger that does not allow more than one null in a certain column (hourfinish). Here is the trigger I wrote (I am using Sybase):</p>
  
  <pre><code>ALTER TRIGGER "InsertIntoCardDetail" instead of insert on
  DBA.CardDetail
  referencing new as new_name
  for each row
  begin
    declare @nullCount integer;
    if(new_name.hourfinish is null) then
      select COUNT(*) into @nullCount
        from CardDetail
        where hourfinish is null;
      if(@nullCount &gt; 0) then
        raiserror 99999 'Cannot have Multiple Nulls'
      else
        insert into CardDetail( card,hourstart,hourfinish,"work",project,N) 
          values( new_name.card,new_name.hourstart,new_name.hourfinish,new_name."work",new_name.project,new_name.N) 
      end if
    else
      insert into CardDetail( card,hourstart,hourfinish,"work",project,N) 
        values( new_name.card,new_name.hourstart,new_name.hourfinish,new_name."work",new_name.project,new_name.N) 
    end if
  end
  </code></pre>
  
  <p>The trigger works fine. What I am asking is if there is a command executing the insert - a command that can replace those long insert statements.</p>