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

  • SEARCH
  • Home
  • 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 8611835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:28:19+00:00 2026-06-12T04:28:19+00:00

I have to create a trigger that does not allow more than one null

  • 0

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):

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 > 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

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.

  • 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-06-12T04:28:21+00:00Added an answer on June 12, 2026 at 4:28 am

    I achieved the same result with a before insert trigger. This way i don’t need to write any insert statement in the trigger.

    ALTER TRIGGER "InsertIntoCardDetail" before insert on
    DBA.CardDetail
    referencing new as new_name
    for each row
    begin
      if(new_name.hourfinish is null)
        and exists(select 1
          from CardDetail
          where hourfinish is null) then
        raiserror 99999 'Cannot have Multiple Nulls'
      end if;
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a trigger that looks something like this: create or replace TRIGGER cluster_check
is is possible in postgres to have a trigger on CREATE TABLE that will
I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT
The Tastypie documentation states that bundles keep Tastypie more thread-safe but does not explain
We have created a table with a trigger that updates a ModifiedDate field in
I have a pretty simple trigger: CREATE OR REPLACE FUNCTION f_log_datei() RETURNS TRIGGER AS
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
I am trying to set up a MySQL trigger that does the following: When
every night i have a trigger that executes asp.net page with method that first
The table I am working with does not have a standard auto-increment field to

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.