REG: CASE WHEN IN WHERE WOULD ADOPT

Hi friends, this is my query SELECT DISTINCT FILE_DIRECTION FROM RA_PROCESS_ID_MAP WHERE FILE_DIRECTION = (CASE WHEN "TAP" = "TAP" and (FILE_DIRECTION = 'A' AND FILE_DIRECTION = 'TI'), THEN WHEN 'NRTRDE"THEN FILE_DIRECTION =" NEITHER "WHEN 'SWITCH' AND FILE_DIRECTION = 'SO' END) = 1; its me given expression error... Please help.

If this is what he wants, then it is probably more clear to remove the CASE statement total:

Select distinct file_direction

of ra_process_id_map

where (: b1 = 'TAP' and file_direction in ('TO', 'TI'))

or (: b1 = "NRTRDE' and file_direction = 'NOR')

or (: b1 = 'SWITCH' and file_direction = 'IF')

I think the just CASE statement confuses the issues and has clearly confused the heck out of the op.

Tags: Database

Similar Questions

  • using case when statement or decode unfavorable in where clause

    Hi the gems...

    I have a problem in the following query...
    I try to use when case statement in where clause of a select query.


    Select cr.customer_name. ' - ' || CR.customer_number as cust_name,
    CR. Salary salary
    of customer_details cr
    where (case when ' > ' = ' > ' then ' cr.salary > 5000')
    When ' > ' = ' < ' then ' cr.salary < 5000'
    When ' > ' = '=' and then 'cr.salary = 5000'
    Another null
    (end);


    the expression in the when clause of the statement of the case, when comes from HQ and according to the choice I have to make the where clause.
    That is why, for the execution of the query, I put ' > ' in this place.

    If the original query will look like this (for reference):

    Select cr.customer_name. ' - ' || CR.customer_number as cust_name,
    CR. Salary salary
    of customer_details cr
    where (case when variable = ' > ' then ' cr.salary > 5000')
    When the variable = ' < ' then ' cr.salary < 5000'
    When the variable = '=' and then 'cr.salary = 5000'
    Another null
    (end);


    so, in a real case, if the user selects ' > ' then the filter will be ' where cr.salary > 5000.
    If the user selects ' < ' then the filter will be ' where cr.salary < 5000.
    If the user selects '=', then the filter will be 'where cr.salary = 5000 '.

    but I get the error "ORA 00920:invalid relational operator.

    Help, please... Thanks in advance...

    Hello

    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
     from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
          )
       or (    v_variable = 'less'
          and cr.salary < 5000
           )
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )
    

    Published by: user6806750 on 22.12.2011 14:56
    For some reason that I can't write in sql "<', '="">", "=".

  • Select the case when several returnvalue? 20 D

    Hello
    I would like to know if there is a solution less than 10g for something like this

    Select case when 'C' = 1
    then
    (select double 1,2,3,4,5)
    on the other
    (select double 6,7,8,9,0)
    end
    of the double.
    (select 1 double 'C')

    What I really need, is the full output of (select double 1,2,3,4,5) or (select double 6,7,8,9,0) If a State due to a different sql query is true or false. No matter if the solution uses 'case when' or anything else.

    Thanks in advance for any help.
    Best regards
    Carsten

    Something like this would work with the example you gave.

    SQL> with test_data as
      2      (select 1 c from dual)
      3  select
      4      1, 2, 3, 4, 5
      5  from
      6      dual,
      7      test_data
      8  where
      9      c = 1
     10  union all
     11  select
     12      6, 7, 8, 9, 0
     13  from
     14      dual,
     15      test_data
     16  where
     17      c != 1;
    
             1          2          3          4          5
    ---------- ---------- ---------- ---------- ----------
             1          2          3          4          5
    
    SQL> edi
    Wrote file afiedt.buf
    
      1  with test_data as
      2      (select 2 c from dual)
      3  select
      4      1, 2, 3, 4, 5
      5  from
      6      dual,
      7      test_data
      8  where
      9      c = 1
     10  union all
     11  select
     12      6, 7, 8, 9, 0
     13  from
     14      dual,
     15      test_data
     16  where
     17*     c != 1
    SQL> /
    
             1          2          3          4          5
    ---------- ---------- ---------- ---------- ----------
             6          7          8          9          0
    
  • Problem with case when try to alter the query from siimple

    Hello PL/SQL gurus and Experts.

    I'm stuck with a question (can be simple), but not gettings all headsway.
    select 365/day_num_yr Anul_Fact from Date where date_dt = trunc(sysdate -1) 
    value returns is as - 1.46

    need to write it in the form of case (I have to multiply it to some other outer query), I want to store variable ina and then use the same in an outside -.
    but when use the following syntax, then it always returns 0 and not the same output returned by the query above without the scabbard.
    select (case when date_dt =trunc(sysdate -1) then 365/day_num_yr else 0 END) Anul_Fact 
    Help kindly, I appericate your time and effort in advance.

    user555994 wrote:
    Problem is that I do not get the output as 1.46, even the output is coming like the 0 only if using the query - next

    select /*date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,*/
    case when date_dt = trunc(sysdate -1) then  365/day_num_yr
    else 0
    end num_day
    from date_dim;
    

    Completely, which seems to be a question of DATA. Have you checked if the table contains data for DATE_DT = SYSDATE - 1? Can you check if the data stored do not have hours and Minutes stored?

    Although I have provided examples of data, which is the same as the data in my main table and once I used the previous solution you provided and then also gives the result as same as those mentioned by you.

    I think it's something like -

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
    case when date_dt = trunc(sysdate -1) then  366/day_num_yr where day_num_yr=(select day_num_yr from date_dim where date_dt = trunc(sysdate -1))
    else 0
    end num_day
    from date_dim;
    

    Once we get the day_num_yr then he deviding by 366/day_num_yr :(
    but he does not like throwing an error ORA-95 - missing keyword

    Yes, it does not work

    -case when date_dt = trunc (sysdate-1) then 366/day_num_yr where day_num_yr = (select day_num_yr from the date_dim where date_dt = trunc (sysdate-1))

    due to a syntax of alien.
    I don't think that you really need. I already said, with the data in your Table, you will be having only * 1 * record with a Non - zero value. Thus, simply apply a filter to extract the corresponding record SYSDATE - 1 and you should get an output which is Non-zero. If you apply a where predicate, then would not need you a CASE statement. You can directly use something like below:

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
           365 / day_num_yr num_day
      from t4
     where date_dt = trunc(sysdate - 1);
    

    Published by: Jen K, September 7, 2012 16:00

  • CASE in a WHERE clause: ORA-00905

    Hello world
    I try to use a BOX in a WHERE clause clause and I got the error ORA-00905: lack of keyword. Here is my code:

    SELECT id_reserv,
    Concat (name, Concat ('_', index)) as name,
    Libelle,
    num_lot,
    resa_keyword1,
    resa_keyword2,
    resa_keyword3,
    resa_keyword4,
    date_creation,
    comm_creation,
    id_util,
    assets,
    id_env_act,
    (SELECT connection of user u where u.id_util = r.id_util) AS nom_util,
    (SELECT name e environment where e.id_env = r.id_env_act) AS nom_env,
    (SELECT count (*) of rc reserv_comp where rc.id_reserv = r.id_reserv) AS nbComp,
    (SELECT count (*) MC reserv_modif where mc.id_reserv = r.id_reserv) AS nbModif
    BOOKING r
    WHERE the r.nom NOT LIKE 'RESERV_LOT_ % '.
    AND id_util = '1'
    AND active = '1'
    AND id_env_act > = '-1'.
    AND the MATTER sansdemande
    WHEN true THEN id_reserv not in some id_reserv from demande_livraison where id_env_dep > = '-1'.
    ELSE id_reserv = id_reserv
    END
    AND name LIKE '% '.
    ORDER BY date_creation;

    I already looked at the CASE statement and it seems that the syntax is correct, so I don't know I can use in a WHERE clause.
    Any help would be nice!

    Andalusians

    Hello

    It should be something like this:

    AND CASE
      WHEN 'false'='true' THEN (select id_reserv from demande_livraison where id_env_dep>='-1')
      ELSE id_reserv
         END = id_reserv 
    

    The subquery must return a line

    But I think that it is better to write your query in the form:

    SELECT id_reserv,
         concat(nom,concat('_',indice)) as nom,
         libelle,
         num_lot,
         resa_keyword1,
         resa_keyword2,
         resa_keyword3,
         resa_keyword4,
         date_creation,
         comm_creation,
         id_util,
         actif,
         id_env_act,
         (SELECT login from utilisateur u where u.id_util=r.id_util) AS nom_util,
         (SELECT nom from environnement e where e.id_env=r.id_env_act) AS nom_env,
         (SELECT count(*) from reserv_comp rc where rc.id_reserv=r.id_reserv) AS nbComp,
         (SELECT count(*) from reserv_modif mc where mc.id_reserv=r.id_reserv) AS nbModif
    FROM reservation r
         WHERE r.nom NOT LIKE 'RESERV_LOT_%'
         AND id_util='1'
         AND actif='1'
         AND id_env_act>='-1'
         AND
                       (
                          (  'false'='true' and id_reserv not in (select id_reserv from demande_livraison where id_env_dep>='-1')
                          )
                          or
                          ( 'true'= 'true' and id_reserv=id_reserv
                          )
                       )
         AND nom LIKE '%'
    ORDER BY date_creation;
    

    This coding in SQL something as if a = b, then c, d also in the simplest form.

    Herald tiomela
    http://htendam.WordPress.com

  • "CASE WHEN 1 = 0 THEN... ON THE OTHER... END '?

    This might be a very basic question I'm still confused about it.
    Can you explain me please "BOX WHEN 1 = 0 THEN... ON THE OTHER... END '?
    Where and why to use this declaration?


    Help appreciated.

    First Let's break down what it means. Because 1 is never equal to 0, OBI will ignore what comes immediately after and run what comes after the ELSE.

    So, why would we do that? Well, often we want to perform an action that has nothing to do with a particular column in our field. Using this CASE statement, trick us OBI into thinking that we use a column for a calculation or action, but in fact, the column is unchanged.

    For example, suppose that you have been the construction of a line of dashboard. You want to use a column twice in the dashboard command prompt, for example a column ACCOUNT_OPEN_DATE for a range of dates. You cannot use the same column twice in a row of dashboard. (Try it, OBI will ignore your attempt to put the same column twice in your workspace).

    So, what are you doing? You first get a column (in this example, I use a column of type CHAR) as the name of the branch. It doesn't matter which column you are using. The TANK is used the syntax is so logical.

    Move the column to your workspace. Now you click on the amending formula and you type CASE WHEN 1 = 0 THEN organization. "" The branch name ' ELSE 'TEST' END.
    So in this case, the values of the branch name are not affected and the dummy column represents just the word 'TEST '. Now in the 'Show' of the command prompt part, we switch to 'SQL results' and SELECT 'attributes of the account' type. Account_Open_Date OF THE industry and together for a PV called StartDate.

    Because the column is a model, you can call it in fact once again. Use the instruction BOX even make a "dummy" column Then use the same SQL, you used previously, but this time save it in a TICKET called EndDate.

    You now have two date values, you can use your ACCOUNT_OPEN_DATE column to get a date range.

    So, in conclusion, normally you choose a column in the subject box, because you have the values in this column in your report. But when you just need a column to do something unrelated to any column, you use CASE 1 = 0 to make a "dummy" column, and then you can perform your action.

    HTH,

  • To convert a new Win 8 PC Win XP PC w/Ffx 28.0, is Ffx 28,0 v. keep? If not, then v. and when and where to install the conversion?

    I will be the conversion of my PC for 9 years with the victory. A new PC with Win XP. 8. my list of program control panel tells me that my old PC running Firefox 28.0 (x 86 en - us). I need to be sure that Firefox 28.0 is your latest version and that I should go to my new PC (it seems to be so many versions out there that it is confusing... in one place you say version 17 is the only one to use). If I do not need to install another version of Firefox, I would need to know that one, and that it must be installed on the old computer first, before changing the PC, or anywhere elsewhere in the in the conversion sequence, that is, on the new PC before (or after?) transfer everything from the old PC. I intend to transfer to new PC software free LapLink offered for us the current XP users through a LapLink/Microsoft agreement.

    Yes, Firefox 28 is the current Windows XP or higher version.

    I'm not exactly sure how works of Laplink, but assuming that he transfer all your data from Windows user profile, then you should bring your Firefox to your new computer data. You can confirm by checking here on both computers and comparing what you see:

    (paste into start > run or WinButton + r): %APPDATA%\Mozilla\Firefox\

    In particular, make sure that Laplink copied the profiles.ini file and folder profile and its subfolders.

    I suggest you copy the data in the first, then installation of Firefox. In this case, when you install Firefox it should automatically find your data and you will be running. If you install Firefox first, then you will need to take some additional precautions to get your old data in.

  • The App initialization: when and where?

    In a recent update BB10, I noticed that, if an application is not fully initialize in the 5-6 seconds that newspapers appears:

    forensics_logworthy_state: fixing error 2, no such file or directory, bail

    And the app seems to hang.

    It took a while to figure out what is the code, but how long the code was running - which is the root of my problem. My application has significant amount of initialization to do work, the question is when and where is the best place to do this tedious work?

    I initialially but I had to leave the event loop start and I'd be sure but no, it wasn't the case, always down that has happened.

    Do I have to perform this initialization process in another thread? It is unwise to run this a lot of work in the context of the UI?

    Devs, how you initialize your portions of app NON-INTERFACE?

    I think you yourself have already given your answer, but yes the run in another thread.

    The processes of your time should be asynchronous and performance using one of the methods as QThread QtConcurrent threads...

    http://developer.BlackBerry.com/native/reference/Cascades/QThread.html

  • ORA-06592: not found CASE when executing CASE statement

    Hello

    I have a table of application where I built a form master detail (table with 33 columns, 13 is not hidden items and rest are hidden).

    When I run the page I get an error "error while rendering page, article. P10_TIME_SAVED_FREQUENCY, ORA-06592: not found when executing CASE statement CASE"

    Error:

    Error during rendering of the element on the page P8_MONEY_SAVED_FLAG.

    ORA-06592: not found CASE when executing CASE statement

    Technical information (only visible to developers)

    is_internal_error: true

    apex_error_code: WWV_FLOW_FORM. UNHANDLED_ERROR

    ora_sqlcode:-6592

    ora_sqlerrm: ORA-06592: not found CASE when executing CASE statement

    Component.type: APEX_APPLICATION_PAGE_ITEMS

    Component.ID: 13345536607188241

    Component.Name: P8_MONEY_SAVED_FLAG

    error_backtrace:

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 1751

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 4241

    ORA-06512: at "APEX_040200.WWV_FLOW_PLUGIN", line 1251

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 977

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 1406

    DEBUG:

    Exploitation forest exception in final_exception_handler:

    SQLERRM: ORA-20987: APEX - error during rendering of the element on the page P8_MONEY_SAVED_FLAG. -

    ORA-06592: not found CASE during the execution of the instruction BOX Backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 853 ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 888 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS"

    line of 3240 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1780 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1950 ORA-06512: at "APEX_040200.WWV_FLOW", line 6725

    How to solve this problem. Please advice

    Oracle Apex Vesion: 4.2.1

    Thank you

    BO123 wrote:

    Hello

    I have a table of application where I built a form master detail (table with 33 columns, 13 is not hidden items and rest are hidden).

    When I run the page I get an error "error while rendering page, article. P10_TIME_SAVED_FREQUENCY, ORA-06592: not found when executing CASE statement CASE"

    Error:

    Error during rendering of the element on the page P8_MONEY_SAVED_FLAG.

    ORA-06592: not found CASE when executing CASE statement

    Technical information (only visible to developers)

    is_internal_error: true

    apex_error_code: WWV_FLOW_FORM. UNHANDLED_ERROR

    ora_sqlcode:-6592

    ora_sqlerrm: ORA-06592: not found CASE when executing CASE statement

    Component.type: APEX_APPLICATION_PAGE_ITEMS

    Component.ID: 13345536607188241

    Component.Name: P8_MONEY_SAVED_FLAG

    error_backtrace:

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 1751

    ORA-06512: at "APEX_040200.WWV_FLOW_NATIVE_ITEM", line 4241

    ORA-06512: at "APEX_040200.WWV_FLOW_PLUGIN", line 1251

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 977

    ORA-06512: at "APEX_040200.WWV_FLOW_FORMS", line 1406

    DEBUG:

    Exploitation forest exception in final_exception_handler:

    SQLERRM: ORA-20987: APEX - error during rendering of the element on the page P8_MONEY_SAVED_FLAG. -

    ORA-06592: not found CASE during the execution of the instruction BOX Backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 853 ORA-06512: at "APEX_040200.WWV_FLOW_ERROR"

    line 888 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS"

    line of 3240 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1780 ORA-06512: at "APEX_040200.WWV_FLOW_PAGE"

    line of 1950 ORA-06512: at "APEX_040200.WWV_FLOW", line 6725

    How to solve this problem. Please advice

    Oracle Apex Vesion: 4.2.1

    Post a backtrace of the page see the request and the item type properties and the source / default to the value of the P8_MONEY_SAVED_FLAG element.

    Seems to be similar to ORA-06592 with the page only items appear, which also involved a master/detail form. Can you reproduce this on apex.oracle.com?

  • Add case/When statement to display

    I am trying to add the Sub instruction 'case' in my opinion, but I get an error "invalid identifier" where he currently is now.

    CASE

    WHEN LATEST_EVENT_DT < "the Max event Date".

    THEN "CANCELLED."

    OF OTHER LATEST_EVENT_DESC

    END as 'Max Event'

    CREATE OR REPLACE FORCE VIEWS GREATEST_DATE_VW_SGD
    ("PCFN"
    , "TCN.
    , "LATEST_EVENT_DT".
    , "LATEST_EVENT_DESC".
    , "OIT_Closed_Date".
    , "OIR_Closed_Date".
    , "OIN_Closed_Date".
    , "The Max event date".
    "Max Event")

    AS
    SELECT

    MV. PCFN,

    MV. TCN,

    MV LATEST_EVENT_DT.

    MV LATEST_EVENT_DESC.

    ILO. CLOSED_DATE,

    OIR. CLOSED_DATE,

    ISO. CLOSED_DATE,

    largest (mv. LATEST_EVENT_DT
    nvl (ILO. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))
    nvl (OIR. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))
    nvl (ISO. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))
    ) AS "event of Max Date."

    CASE
    WHEN LATEST_EVENT_DT < "the Max event Date".
    THEN "CANCELLED."
    OF OTHER LATEST_EVENT_DESC
    END as 'Max Event'

    OF APEX01. SGD_CIET_NDN_ROUTES_MV mv

    LEFT OUTER JOIN APEX01. OEF_ITV_TALLINN ILO ON mv. PCFN = ILO. PCFN AND mv. TCN = ILO. TCN

    LEFT OUTER JOIN APEX01. IRO OEF_ITV_RIGA ON mv. PCFN = IRO. PCFN AND mv. TCN = IRO. TCN

    LEFT OUTER JOIN APEX01. ISO of OEF_ITV_NDN ON mv. PCFN = ISO. PCFN AND mv. TCN = ISO. TCN;

    Is this possible? or do I have to create another view just for the case of "Max Event?

    CREATE OR REPLACE FORCE VIEW MAX_EVENT_DESC_SGD ('Max Event')

    AS

    SELECT THE CHECK BOX

    WHEN LATEST_EVENT_DT < "the Max event Date".

    THEN "CANCELLED."

    OF OTHER LATEST_EVENT_DESC

    END as the "last event".

    OF greatest_date_vw_sgd g;

    Thank you

    Steven

    Post edited by: StevenD609

    Hello.

    Today, there is already this question...

    CREATE OR REPLACE FORCE VIEWS GREATEST_DATE_VW_SGD

    ("PCFN"

    , "TCN.

    , "LATEST_EVENT_DT".

    , "LATEST_EVENT_DESC".

    , "OIT_Closed_Date".

    , "OIR_Closed_Date".

    , "OIN_Closed_Date".

    , "The Max event date".

    "Max Event")

    AS

    SELECT

    Z.*,

    CASE

    WHEN LATEST_EVENT_DT< "max="" event="">

    THEN "CANCELLED."

    OF OTHER LATEST_EVENT_DESC

    END as 'Max Event'

    Of

    (

    SELECT

    MV. PCFN,

    MV. TCN,

    MV LATEST_EVENT_DT.

    MV LATEST_EVENT_DESC.

    ILO. CLOSED_DATE,

    OIR. CLOSED_DATE,

    ISO. CLOSED_DATE,

    largest (mv. LATEST_EVENT_DT

    nvl (ILO. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))

    nvl (OIR. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))

    nvl (ISO. Closed_Date, TO_DATE ('01011950', 'MMDDYYYY'))

    ) AS 'Max event Date.

    Of

    APEX01. SGD_CIET_NDN_ROUTES_MV mv

    LEFT OUTER JOIN APEX01. OEF_ITV_TALLINN ILO ON mv. PCFN = ILO. PCFN AND mv. TCN = ILO. TCN

    LEFT OUTER JOIN APEX01. IRO OEF_ITV_RIGA ON mv. PCFN = IRO. PCFN AND mv. TCN = IRO. TCN

    LEFT OUTER JOIN APEX01. ISO of OEF_ITV_NDN ON mv. PCFN = ISO. PCFN AND mv. TCN = ISO. TCN

    ) Z ;

  • Case statement in where clause

    Hello

    I have to write the following query using the value of the l_var variable in the case statement

    How do I get there?


    Select col3

    of the test

    where col1 = "A".

    and the case

    When l_var = "Y' and col2 = 'B '.

    When l_var = 'n' and col2 = 'C '.

    end;

    In your expression

    case

    When l_var = 'Y' and col2 = 'B '.

    When l_var = ' only then col2 <> 'B '.

    end;

    you try to return a Boolean (True or False) value like 'then' value of the CASE statement.

    Values Boolean are not an Oracle SQL data type, you cannot use the true/false result of col2 = 'B' as an expression. This is why it does not work.

    It's even more simple as:

    Select col3

    of the test

    where col1 = "A".

    and ((l_var = «Y» et col2 = «B») or (l_var = ' no and col2 <> 'B'))

    If you really want a CASE statement then:

    Select col3

    of the test

    where col1 = "A".

    and the CASE WHEN l_var = 'Y', THEN CASE WHEN col2 = 'B', 1 ELSE 0 END

    WHEN l_var = ' no CASE THEN WHEN col2 <> 'B', 1 ELSE 0 END

    END = 1

  • Subselect with clause with and nvl() with case when as 2nd argument does not work

    I get an error for this one

    Select)

    with x

    (select 1 of the double)

    Select

    NVL (x.a, cases where x.a is null then fine otherwise 3 2)

    the double)

    of the double

    Error is:

    ORA-00904: 'X '. "' A ': invalid identifier

    ... related to the use of x.a in an expression box as the 2nd argument of nvl (...)

    Rgds,

    Frank

    Hello

    Maybe like this?

    Select)

    with x

    (select 1 of the double)

    Select

    NVL (x.a, case when x.a is null, then Itf_Pkg.Itf_Null_Value ("x.a', 'a null value'") or 3 end)

    X)

    of the double

  • Error number invalid when using case when

    I have a table called NATIONAL_RARE_ECOSYSTEMS that contains 1 column called TEST_COLUMN (data type: varchar2):

    TEST_COLUMN
    rare ecosystem
    rare
    0
    0
    (null)
    (null)

    what I want is a query that will add a column called NRE_SCORE that will give each instance of line a score of 0 if it is null.
    If it is 0, then the score should be 0.
    If the line contains any text, partition should be 1

    I wrote the request:

    SELECT
    (CASE WHEN test_column is null THEN 0)
    WHEN test_column = 0 THEN 0
    WHEN test_column > 0, 1
    END) AS NRE_SCORE
    OF NATIONAL_RARE_ECOSYSTEMS;

    I get the error message:

    ORA-01722: invalid number
    01722 00000 - "invalid number."

    I think it is because on the 2nd and 3rd line, trying to perform arithmetic operations on a column which is varchar2 which I know that I can't do.

    How can I write a query that says: If the line contains text, then gives the score of 1?

    I'm using oracle 11g.

    Hello

    993451 wrote:
    I have a table called NATIONAL_RARE_ECOSYSTEMS that contains 1 column called TEST_COLUMN (data type: varchar2):

    TEST_COLUMN
    rare ecosystem
    rare
    0
    0
    (null)
    (null)

    what I want is a query that will add a column called NRE_SCORE that will give each instance of line a score of 0 if it is null.
    If it is 0, then the score should be 0.
    If the line contains any text, partition should be 1

    Any text other than '0', you mean. I guess that doesn't matter if this text is all the numbers, like '9876 'or something with no numbers, as 'rare'.

    I wrote the request:

    SELECT
    (CASE WHEN test_column is null THEN 0)
    WHEN test_column = 0 THEN 0
    WHEN test_column > 0 THEN 1
    END) AS NRE_SCORE
    OF NATIONAL_RARE_ECOSYSTEMS;

    I get the error message:

    ORA-01722: invalid number
    01722 00000 - "invalid number."

    I think it is because on the 2nd and 3rd line, trying to perform arithmetic operations on a column which is varchar2 which I know that I can't do.

    You are not actually doing arithmetic, but you compare your VARCHAR2 column, so he tries to convert the string to a NUMBER, and that's why you get the error ORA-01722.
    >

    How can I write a query that says: If the line contains text, then gives the score of 1?

    I'm using oracle 11g.

    Here's one way:

    SELECT       CASE
               WHEN  NVL (test_column, '0') = '0'
               THEN  0
               ELSE  1
           END          AS nre_score
    ,       ...          -- you must want other columns, too
    FROM       national_rare_ecosystems
    ;
    

    Since you are not really care on the numerical value, do not use numbers anywhere; stick with VARCHAR2s, for example '0'.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Point where the above query was to get erroneous results, and explain, using specific examples, how you get these results of the sample data in these palces.
    See the FAQ forum {message identifier: = 9360002}

  • any case when and the sql clause

    Hello:
    What follows is my sql clause:
    SELECT T.*, b.name
    OF dbtest1 t
    LEFT OUTER JOIN dbtest b ON t.NO = b.empno
    WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
    ORDER BY t.ChineseName

    The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
    When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
    the result data are not entirely accurate.
    is it possible to use the case when it is implemented in the following code snippet:

    -case when b.name is not NULL then b.name like "%" | : name | » %'
    Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
    end

    Thank you very much.

    962769 wrote:
    The main problem is the table is the form of the cross, and the like clause will filter the
    data without a name. Basically, it should show the empty columns, however, it won't.
    so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
    has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.

    Thank you

    WHERE t.ChineseName like '%'||:ChineseName||'%'
    AND  (
            b.name like '%'||:name||'%'
           or b.empno is null
        )
    
  • Reg: Case Stmt

    Hi Experts,

    I implemented a stmt case to load data from a table to another table (the two tables are same pattern only).

    My source as table spec

    Select * from EMP

    Sal jdate empid EmpName
    Emp1 100 1000 2012
    Emp1 101 5000 2012

    even my table target spec also even called as emp1:


    my code is



    Insert into EMP1
    (
    EMPNAME,
    EMPID,
    SAL,
    JDATE

    )

    Select
    EMPNAME,
    EMPID,
    SAL,
    JDATE

    DE)


    Select
    EMPNAME,
    EMPID,
    SAL,
    EMPNAME CASE
    WHEN 'EMP' THEN TO_DATE (C4_JDATE, 'YYYY')
    WHEN 'EMP1' THEN TO_DATE(C4_JDATE,'dd-mon-yyyy')
    WHEN 'EMP2' THEN TO_DATE(C4_JDATE,'mm/dd/yyyy')
    end JDATE
    from EMP
    where (1 = 1)



    This query above works fine, but when the time to display the basic data in emp1 as of data

    JDate as: July 01, 2012

    data remaining is fine.


    Have that I need to change the date format of database to jdate disaplay as 2012 (yyyy)...

    Please suggest me where I need to change...


    Thank you
    H







    )

    Oracle date formats needs to be in a year, month, day, and hour of the elements. If update us or insert a value into a date column that does not have some of these Oracle components using the default values.

    Thus, if provide us everything a year that oracle will generate a date which is midnight the first day of the current month. It's what you do, and is why you currently values JDATE July 1, 2012. If you run your code on Wednesday you will find the JDATEs will be August 1, 2012.

    Cheers, APC

Maybe you are looking for