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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:53:22+00:00 2026-05-27T11:53:22+00:00

On an Oracle 11g engine using PL/SQL I have logic that runs like this

  • 0

On an Oracle 11g engine using PL/SQL
I have logic that runs like this

if (flag = Y) then 
   select id, flavor, color
   from menu
   where flavor in (1,2,3,4,5);
else 
   select 
   id, flavor, color
from 
   menu
   where flavor in (2,4,6);
end if;

I’m thinking using decode or case logic in the where clause? I’d like to have just one query that can handle both ‘flag’ values.

  • 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-27T11:53:23+00:00Added an answer on May 27, 2026 at 11:53 am

    Can you just change it to use an OR? (assumed that flag it N if not Y, but may be NULL which will be treated as N)

      select 
       id, flavor, color
    from 
       menu
       where 
            (flag = 'Y' and flavor in (1,2,3,4,5))
            or(nvl(flag,'N') = 'N' and flavor in (2,4,6)) ;
    

    if you want to check for flag <> Y (in a similar fashion as @Crappy Coding Guy posted, but it can be NULL, changing

    nvl(flag,’N’) = ‘N’

    to

    nvl(:flag,’N’) <> ‘Y’

    will suffice

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

Sidebar

Related Questions

I'm using Oracle 11g Standard Edition. I would like to log all SQL queries,
Have some dates in my local Oracle 11g database that are in this format:
Using Oracle 11g release 2, the following query gives an ORA-01790: expression must have
I am using oracle 11g and have a table with an XMLType. There are
I have a schema in an Oracle 11g R2 database that I'm trying to
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I suddenly noticed that Oracle JDBC driver that I was using With Oracle 11g
I am using Oracle 11g, and I have a lot of stored procedure code
is PL/SQL the language of Oracle 11g? Is there some other langauge that Oracle
We've got an Oracle 11g installation that is starting to get big. This database

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.