How to use the instruction box in where clause

Hi all


I need to use cases where clause guide me please how I can do it.


AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
END



Concerning

Published by: user10941925 on March 4, 2012 22:31

Hello

CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.

You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:

AND     (     (:KAPCO = 'KAPCO'          AND cla.CLASS_NAME       LIKE '%KAPCO%')     -- Don't you want UPPER on this line?
     OR     (:KAPCO = 'NON_KAPCO'           AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%')
     OR     (NVL (:KAPCO, 'ALL') = 'ALL'       AND cla.CLASS_NAME IS NOT NULL)
     )

If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.

Tags: Database

Similar Questions

  • How to use a function in a Where Clause?

    Hello
    I have a doubt. If MY_FUNCT is a function that returns a Boolean value, can I use in a where clause clause to write a query like this? :

    Select...
    table one
    where the...
    *...*
    and MY_FUNC (a.field) = true
    *...*
    *;*

    Thank you!

    Published by: Mark1970 on 3.27 lug-2-2010

    But is it possible that the function does not return a Boolean value?

    Yes (as sysdate, substr and instr etc.) you can also use your own function in a where clause clause, as long as it does not return a BOOLEAN value.

    I mean how to use a function in a where clause clause?

    Your own pseudocode seems a good example for me.
    So, just give it a try.

  • Using the Case statement in Where clause with operator

    Hi all

    I'm doing the following work (this is just a simple version of what I'll eventually need):

    Sorry, I forgot how to use the code tags...

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906 ', ' 9321471')
    end


    Problem is that I get a missing closing parenthesis error.

    Wouldn't - that evaluate against a value(as below) it works fine:

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906')
    end


    Any thoughts? Is it possible to use a box (or decode) in an In clause with multiple values? I tried to use decode as well and get the same results.

    Thank you.

    Darren.

    What:

    and ( case
            when :prompt = 'Energy' and li.MAJOR_ACCT in ('9320906', '9321471') then 1
            when :prompt = 'Vehicle' and li.MAJOR_ACCT in ('9812180', '9812320')  then 1
            when :prompt = 'Meals' and li.MAJOR_ACCT in ('983120', '983452') then 1
          end
        ) = 1
    
  • several instructions box in where clause

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    Hi, Micah,

    User12611868-Oracle wrote:

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    How get the desired results of your data depends on the desired results and your data.  What do you do?  (I can't tell just by looking at the aat code that do not do).  After CREATE TABLE and INSERT statements for some sample data and a couple of sets of parameters (variables such as p14_zone) and the exact results that your choices in each set of parameters, given the same sample data.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

    CASE expressions are generally not useful in a WHERE clause.  CASE expressions are a convenient way to IF-THEN-ELSE logic of the places where you can't do anything other than (the SELECT clause), but WHERE the clauses allow IF-THEN-ELSE logic in any case

    Maybe you want something like

    WHERE MERGE (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4) IS NULL

    OR IN i.compute_zone (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4)

    It returns TRUE if all 4 parameters are set to NULL.  If 1 or more of them are not NULL, then it will return TRUE if i.compute_zone is equal to one of them.

  • Using the index function in where clause of Exchange.

    Hello friends,

    I need your help with a problem.

    I have a query that uses two table Say T1 and T2, where C1 is common column with which both are joined.
    C1 is the primary key in T1, but no index available in Q2 for the C1. T1C2 is the column that we want to select.
    (Note that table may be a Master table)

    Now let's see the query:
    Select T1C2
    From T1, T2
    where T2. C1 = T1. C1

    Here where the clause may have other conditions and From clause can have other tables as needed.

    I want to know that if I have change the query as continuation of leave my query to use the index available of T1. C1.

    Select T1C2
    from T1, T2
    where T1. C1 = T2.C1

    Then, the query uses the index available of T1. and I get better performance. Even a small improvement of performance help me much because this type of query is used in a loop where clause (so it will be run several times).

    Please advise on this...

    Kind regards
    Lifexisxnotxsoxbeautiful...

    Hello

    18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
    
    Table created.
    
    18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
    
    18:45:08 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t1(c1,c2) values (i,i+100);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    
    PL/SQL procedure successfully completed.
    
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t2(c1,c2) values (i,i+200);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    
    18:45:23 rel15_real_p>select count(*) from t1;
    
      COUNT(*)
    ----------
           100
    
    18:45:30 rel15_real_p>select count(*) from t2;
    
      COUNT(*)
    ----------
           100
    
    18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
    _name='T1';
    
    INDEX_NAME                     INDEX_TYPE
    ------------------------------ ---------------------------
    SYS_C0013059                   NORMAL
    
    18:48:21 rel15_real_p>set autotrace on
    18:52:25 rel15_real_p>Select T1.C2
    18:52:29   2  From T1, T2
    18:52:29   3  where T2.C1 = T1.C1
    18:52:29   4  /
    
            C2
    ----------
           101
           102
           103
           104
           105
      .....
      ......
    
            C2
    ----------
           200
    
    100 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
              900)
    
       1    0   HASH JOIN (Cost=7 Card=100 Bytes=3900)
       2    1     TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
              es=2600)
    
       3    1     TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
              es=1300)
    
    Statistics
    ----------------------------------------------------------
              0  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    18:52:31 rel15_real_p>analyze table t1 compute statistics;
    
    Table analyzed.
    
    18:55:35 rel15_real_p>analyze table t2 compute statistics;
    
    18:55:38 rel15_real_p>set autotrace on
    18:55:42 rel15_real_p>Select T1.C2
    18:55:43   2  From T1, T2
    18:55:45   3  where T2.C1 = T1.C1
    18:55:46   4  /
    
            C2
    ----------
           101
           102
           103
           104
           105
    
      .....
      ......
    
            C2
    ----------
           200
    
    100 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
    
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
    
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
    
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    18:56:56 rel15_real_p>Select T1.C2
    18:56:56   2  From T1, T2
    18:56:56   3  where T1.C1 = T2.C1
    18:56:58   4  /
    
            C2
    ----------
           101
           102
           103
           104
           105
    
      .....
      ......
    
            C2
    ----------
           200
    
    100 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
    
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
    
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
    
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed
    

    -Pavan Kumar N

  • How to filter the result with a where clause clause?

    Hello

    I have a nice sql query. I would like to include a where clause with a joker clause.

    If the user selects for example a "AGENT_ID", then where clause would include the AGENT_ID, otherwise, every thing would appear.
    SELECT 
       "FICHE"."FICHE_ID" "FICHE_ID", 
       "FICHE"."AGENT_ID" "AGENT_ID", 
       "FICHE"."EQUIPE_ID" "EQUIPE_ID", 
       "FICHE"."DATE_ACTIVITE" "DATE_ACTIVITE", 
       "FICHE"."DATE_CREATION" "DATE_CREATION", 
       "FICHE"."TYPE_FICHE" "TYPE_FICHE", 
       "FICHE"."FICHE_CREE_PAR" "FICHE_CREE_PAR", 
       "FICHE"."TOTAL_HEURES" "TOTAL_HEURES", 
       "FICHE"."TOTAL_HEURES_EXCEPTIONNELLES" "TOTAL_HEURES_EXCEPTIONNELLES", 
       "FICHE"."DATE_MODIFICATION" "DATE_MODIFICATION"
    FROM 
       "FICHE"
    The WHERE clause:
    WHERE AGENT_ID = ' * ' if nothing is selected.

    WHERE AGENT_ID = "4290" If an agent ID is selected.

    Hope I'm clear that English is not my mother tongue.

    Thanks for you help.

    Christian

    Hello

    Try this

    WHERE "FICHE".AGENT_ID like NVL(:val, '%')
    

    see you soon

    VT

  • How to use the Bypass box?

    If we click the right button on a video image / sound, four options appear: Motion, opacity, Volume and Balance.

    Balance has a check box and a blue clock icon.  Checking the box and play with the clock.

    I don't find any filter bandpass, neither high nor low.   How can I activate the bypass filter, please.

    The derivation that is not mentioned in the official manual or the classroom in a book.

    Production of an intense film of a Cambodian circus.  Edit in DC.

    Currently using 10 PE.  At the end of this huge project, intend to go for 14.

    vumadave

    Just my visits on the first Forum of elements from today and see your answers.

    Thanks for the replies. Are you still OK with by-pass of Volume? Looks like progress. But if necessary, I'll go through a specific example the effect you're looking for. Just to confirm the details of what you are looking for.

    Best wishes

    RTA

  • problem with an instruction box in where clause getting ora-00905

    The query runs @ 07:00 every day and must return data for the last day, except Monday when the previous 3 days must be returned.

    Select ip.adm_date+ip.adm_time/86400 as admDateTime,

    IP.pt_code,

    ICC. Surname,

    CPI.first_given_name,

    IP.w_code,

    "as 'MR < 24."

    "as"MR 24-36"

    "as 'MR 36-48."

    "as"MR 48-60,"

    "" as "MR 60-72",.

    "as 'MR > 72."

    "as 'MR finalized."

    «like "Pharm/Tech",

    "as 'MR criteria."

    Of

    k_ipreg ip, k_cpireg ICC

    where ip.pt_code = cpi.pt_code

    and ip.disch_date is null

    and ip.adm_date between ((affaire quand (select to_char (sysdate,'d ') of double) = 1 then ip.adm_date > sysdate-3))

    of another ip.adm_date > sysdate-1

    end)) and sysdate

    and w_code not in ("ICW", "OEN", "ANTE", "BABY", "CHILD", "DELI", "ED", "MATY", "USSN")

    Try to learn to use properly the functions of Oracle:

    SELECT Ip.Adm_Date + Ip.Adm_Time / 86400 AS Admdatetime
         , Ip.Pt_Code
         , Cpi.Surname
         , Cpi.First_Given_Name
         , Ip.W_Code
         , '' AS "MR < 24"
         , '' AS "MR 24-36"
         , '' AS "MR 36-48"
         , '' AS "MR 48-60"
         , '' AS "MR 60-72"
         , '' AS "MR>72"
         , '' AS "MR Finalised"
         , '' AS "Pharm/Tech"
         , '' AS "Met MR Criteria"
      FROM K_Ipreg Ip, K_Cpireg Cpi
     WHERE Ip.Pt_Code = Cpi.Pt_Code
       AND Ip.Disch_Date IS NULL
       AND Ip.Adm_Date BETWEEN ( ( CASE
                                     WHEN TO_CHAR ( SYSDATE, 'd' ) = 1
                                     THEN SYSDATE - 3
                                     ELSE SYSDATE - 1
                                  END ) )
                           AND SYSDATE
       AND W_Code NOT IN ('ICW', 'NWB', 'ANTE', 'BABY', 'CHILD', 'DELI', 'ED', 'MATY', 'SCBU');
    
  • How to use the automatic configuration wizard and where can I FIND?

    How to use the automatic configuration wizard and where can I FIND?

    Hi TannySmedt,

    To activate the Configuration service automatic wireless so it starts automatically, click the Start button. Select settings , then select Control Panel. If you use Windows XP display, select the performance and Maintenance category, and then select Administrative Tools. If you use Classic view, and then select Administrative Tools. In the left pane, click the Services icon. Click the automatic Wireless Configuration icon in the right pane, and change the box Startup Type to Automatic. This parameter will be defined the service starts automatically at boot time. Then click on the Start button to start the automatic Wireless Configuration service zero wireless and click on the OK button.

    The automatic Wireless Configuration can also be started and stopped from a command prompt. To start the automatic Wireless Configuration, run the following command:

    net start wzcsvc

    To stop the automatic Wireless Configuration, run the following command:

    net stop wzcsvc

  • Where are the Solution Center shortcuts, and how to use the (Scans)

    A frustration more than Windows 8 to get more than

    I have attached my C3180 to my new Windows 8 machine and the software installed.  It is running, but I'm a bit lost in the use of the center of Solution that seems different from what I had on XP.

    1. the only way I could see to change the destination of a scan, has been to create a new shortcut with the destination I want to use.  Is this correct?

     

    2. now that I have a short cut, where is it? When I run a scan from the Solution Center, the analysis proceeds to the default destination, so it must use the default shortcut.

    Is it possible to use the start scanning on the home of the solution Center window and make the scan go to my choice of the destination folder?

    Quit smoking research

    I found how to use the solution Center in Windows 8 here.

  • How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    Ashley,

    What about window > show the rectangle enclosing (Ctrl / Cmd + Shift + B to toggle)?

  • Oracle: how to use the max() function in expression box

    How to use the max() function in the case where expression, please explain with an example

    Hope this helps and should be explicit

    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col
    
  • I'm not clear how to use the recovery CD

    I added all the space using my HDD is it comes about 12 GB, I have 27.9 GB of disk space, but my drive has only 1.80 left disk space. I made clear to solve this problem. Basket is empty, I ran disk cleanup.

    A computer expert suggested that Windows might have become confused and cannot recognize what place I save, it might be because I ran a program called Cyberscrub often. His solution is to reload Windows XP home. My laptop came with recovery discs, everything else is already loaded. I have so much I don't want to lose on my laptop. If I use the recovery discs, I will lose everything on my computer, am I better off buying Windows XP home and re-load, in which case I will not lose my job?

    Also I am not clear how to use the recovery discs, I can't find instructions on what you are doing.
    The only person who could help me went to travel and not reachable.
    Any help greatly appreciated
    Lorraine Hart

    It of a very simple to recover the laptop.
    Just boot from the recovery CD and follow the instructions on-screen ;)

    I put t know what version recovery CD you have, but the older one provides the standard and expert mode. In expert mode, you can choose you partition where the OS is to be installed.
    So in this case only the selected partition will be formatted!

    But have you checked the size of the HARD disk in disk management?
    Simply click on the my icon my computer and choose manage.

    Of course, you could remove the internal HARD disk and it could connect to the external USB HDD controller. Then, connect the drive HARD to the second PC and you record data on another HARD drive.

  • Help... How to use the recovery on Pavilion g4 2014tx partition

    Hi all... Would like to ask how to use the recovery partition and what is the effect if I used it... ?

    Thank you...

    Hello:

    You normally start the PC, and at the beginning of the HP welcome screen, you press the F11 key to start the Recovery Manager program.

    Then follow the instructions to restore your PC to its state of software "out of the box.

    In so doing you re-partition and reformat the hard drive.

    All THE data you have on the PC will be lost.

    So make sure that you copy the files that you want to keep on a portable hard drive before proceeding.

    It is also for if you have created a storage partition. You must copy all the files from that too.

    All partitions are erased and redone.

  • How to use the digitizer pen

    Hello

    I just got my new X230T and I can't find how to use the pen from the digitizer.

    Is it possible to write directly on word or a PDF file?

    This video shows that we can configure the stylus but I don't know where!

    http://www.YouTube.com/watch?v=Dy1bg7jRiAE

    I've also heard the box tools Lenovo think Vantage. Where can I download it?

    If anyone can help me, I would be grateful.

    Lenovo X230T with 64 bit of Windows 8

    Toolbox ThinkVantage... She shouldve is preinstalled on your system. You can check support.lenovo.com and look at the driver downloads, however, im not sure if they have eliminated this program. the program that the guy has been used on youtube is called windows journal.

    but other programs that you can write directly on grahl pdf annotator, a single note of microsoft office, microsoft word and office outlook (However, users only for outlook office outlook can see each other drawings).

    personally, I use grahl pdf annotator and there is more to school

Maybe you are looking for

  • Portege R700 - using HDMI when the lid is closed

    Hello I just bought a new monitor. I have it plugged into the laptop with hdmi. I can get a picture very well but when I close the lid of the laptop I lose hdmi output. As I want to use this monitor for my work at home, the State of the laptop comput

  • Structure of the event does not run

    Hello I have a Board who I am control with loop open using a stepper motor system.  I want to run some tests to measure to what extent and how constantly the motor can move the stage.  How my software works is that I give the engine a position (numbe

  • I need a copy of windows XP

    My dad had it on his desk, but then put in a 500gig Xp Player did not like to be moved. The code is on the side of the computer for XP and I read that if you sent Windows they would send you a XP disk because you owned before. How do you do that? Not

  • Net framework problem help?

    I did a cleaning net framework (because of this program that I use...) just tried to see if the program would work again... net framework cleanup did not like before... damn things... A lot Used this:http://www.softpedia.com/progDownload/NET-Framewor

  • sign of admin on user accounts

    I don't remember of my admin password to log on to widows to make or edit user accounts. I had comcast and now I cannot rec. ot all mail it. How can I reset the password on my admin.sign on?