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 8112611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:33:39+00:00 2026-06-06T02:33:39+00:00

When I run this it doesn’t throw an error however it doesn’t insert/delete an

  • 0

When I run this it doesn’t throw an error however it doesn’t insert/delete an entry either. I don’t know why it’s not working.

DECLARE @trAction VARCHAR(5)
  SET @trAction = 'addTR'

  IF EXISTS (SELECT TransgeneID
            FROM tbl_MT
            WHERE MouseID = '3' AND TransgeneID = '3')
    IF (@trAction = 'rmvTR')    
      DELETE
      FROM tbl_MT
      WHERE MouseID = '3' AND TransgeneID = '3'
  ELSE
    IF (@trAction = 'addTR')  
      INSERT INTO tbl_MT 
      VALUES ('3', '3')
  • 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-06T02:33:41+00:00Added an answer on June 6, 2026 at 2:33 am

    First, put BEGIN and END on the IF's:

      DECLARE @trAction VARCHAR(5)
      SET @trAction = 'addTR'
    
      IF EXISTS (SELECT TransgeneID
                FROM tbl_MT
                WHERE MouseID = '3' AND TransgeneID = '3')
      BEGIN
        IF (@trAction = 'rmvTR')    
        BEGIN
          DELETE
          FROM tbl_MT
          WHERE MouseID = '3' AND TransgeneID = '3'
        END
      END
      ELSE
      BEGIN
        IF (@trAction = 'addTR')  
        BEGIN
          INSERT INTO tbl_MT 
          VALUES ('3', '3')
        END
      END
    

    Second and final, if the first IF is true, the inner IF (@trAction = 'rmvTR') will fail and nothing will be done.

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

Sidebar

Related Questions

I assume this is an IIS error, as this doesn't happen if I run
I am getting this error when I run db:migrate Mysql2::Error: Table 'sample_app_development.microposts' doesn't exist:
I only want this function to run if .toolbar li does not have the
Have tried to compile and run this program, but have received this error message
This is what I still don't understand (but probably should)... if I run this
This should be simple but I don't manage to get it working. I have
When i run this the if statement always returns false and thus doesn't run
I have an application (winform exe) that I run several times. Does this mean
I run this code here <html> <script type=text/javascript src=lib/jquery-ui-1.8.21.custom.min.js></script> <script src=http://127.0.0.1:5984/_utils/script/jquery.couch.js></script> <!--<script type=text/javascript src=lib/jquery-1.7.2.js></script>-->
I run this code: - (void)unitButtonButtonTapped:(id)sender { [_label setString:@Last button: Unembossed square]; MilitaryUnits *target

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.