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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:30:35+00:00 2026-05-26T17:30:35+00:00

I have a trigger in Oracle SQL. CREATE OR REPLACE TRIGGER test BEFORE INSERT

  • 0

I have a trigger in Oracle SQL.

CREATE OR REPLACE TRIGGER test
BEFORE INSERT ON SomeTable
FOR EACH ROW
    DECLARE str1 VARCHAR(30);
            str2 VARCHAR(30);
    BEGIN
        -- some code
        IF ( str1 <> str 2 ) THEN
            DBMS_OUTPUT.PUT_LINE( ' if ' );
        ELSE
            DBMS_OUTPUT.PUT_LINE( ' else ' );
        END IF;
    END;

Now, this always goes to the else statement, even when the strings are definitely not equal. I tried to use != instead of <> with the same result. However, it works, in reverse, if I just use

IF ( str1 = str2 ) THEN ... ELSE ... END If;

So what is the right way to test for two strings not being equal to each other (in Oracle)?

  • 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-26T17:30:36+00:00Added an answer on May 26, 2026 at 5:30 pm

    Can you show us the actual values being used?
    It is possible that the reason for the above behavior is becuase one of the values is null?

    If it is possible for str1 and str2 to have null values, your if’s should be like..

    IF (str1 is null and str2 is null) then
       <statments depending on whether you want to treat nulls as equal>
    else if (
       (str1 is null and str2 is not null) or
       (str2 is null and str1 is not null) or
       (str1 <> str2)) then
      <statements when str1 and str2 are not equal>
    else
      <statements when str1 and str2 are equal?
    end if;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small doubt regarding BEFORE INSERT TRIGGER in oracle, my trigger looks
In have an Oracle (10i) PL/SQL Row-Level trigger which is responsible for three independent
Question is following: I have an oracle trigger after row insert. From trigger, I
I have a problem with compiling an Oracle trigger via SQL*PLUS - I don't
I have Oracle 10gR2. I am trying to create autoincrement trigger. Here is the
I am trying to create a trigger in Oracle. I know sql but i
In Oracle, you can write a row-level trigger by specifying the FOR EACH ROW
I'm using the following logon trigger on an Oracle 10.2 database: CREATE OR REPLACE
I have never created a trigger in Oracle before so I am looking for
If I have a trigger before the update on a table, how can I

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.