Condition to check in decode statement

Hi All,
I have a requirement to check below condtion in decode , please help me on this
I need to check name field from a table if it is not equals to null and not equals to ABC% then i need to print some static value as 'XYZ'
Thnaks

Use CASE
case when column_name not like 'ABC%' and column_name  is not null then 'XYZ' else null end
or
decode(nvl(substr(column_name,1,3),'ABC'),'ABC',null,'XYZ')Edited by: jeneesh on Sep 14, 2012 5:03 PM
Tested

Similar Messages

  • Need help in decode statement to check condition

    Hi All,
    I have table emp with below structure
    empno
    work_phone_no
    Home_phone
    cell_phone
    For the employee if work_phone & Home Phone is null then in place of work_phone we need to send the cell_phone number.
    How to use the decode statement in this scenario to test for Home_phone
    condition in the select statement.
    select DECODE (work_phone_no,
    null, cell_phone_no,office_phone_no )
    from emp
    Thanks

    Hi,
    Given the data you posted:
    empno work_phone_no home_phone_no cell_phone_no
    1     null          80032108556   8003210855
    2     null          null          8003210000 and your requirement is
    "If work & Home nunbers are null then display cellhone number in place of workphone number "
    , then, as John said, you do not want the results you posted. You want:
    1 null       80032108556
    2 8003210000 null That is, on the first row, where empno=1, the work_phone_no is NULL because the home_phone_no is NOT NULL, and cell_phone_no is only to be shown when both of the other phone numbers are missing.
    To get the results above, use CASE:
    SELECT  empno
    ,       CASE
                WHEN  work_phone_no IS NULL
                  AND home_phone_no IS NULL
                THEN cell_phone_no
                ELSE work_phone_no
            END  AS work_phone_no
    ,       home_phone_no
    FROM    ...If you really do want the results you posted, then, as John said, use NVL.

  • DECODE statement

    please can someone kindly code the following line of SQL using the DECODE statement:
    case when Student_Status in ('Registered','Repeat','Referral', 'Deferral')and GRADE <> 'MISSING' then EXAM1_RESULT else Null end as Valid_EX1
    It will be most appreciated.
    Thanks

    user607929 wrote:
    I'm ever so sorry, I keep sending the same Wrong thing.
    This is what i need translated to DECODE:
    "case when
    Student_Status in ('Registered','Repeat','Referral', 'Deferral') and GRADE is not 'MISSING'
    then EXAM1_RESULT
    else Null end as Valid_EX1"
    the issue is with the NOT 'MISSING' string.Check this. Just re-arrange of Andrés Muchiut post
    DECODE (
    STUDENT_STATUS
    ,'Registered',DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Repeat' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Referral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Deferral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    , null) Valid_EX1Hope this may help you...

  • Nested decode statement

    Hi i was trying to get the below information.
    I wanted to know is it possible to use nested decode function. also is it possible to use a condition in a decoded function.
    how could i frame the below mentioned information into a nested decode statement.
    IF LSGD = '00000000' then TC = "NS"
    IF LSGD <> '00000000' and RP = 0 and RC =0 OR RU=0 then TC ="NU"
    IF LSGD <> '00000000' and RP = 0 and RC >0 then TC="RR"
    If RU > 1 and INT=0, then TC="TT"
    If PERC is >=66% then TC="RR"
    If PERC is < 66% then TC="TT"
    thanks for your help

    Hi Guido,
    This is the case statement i have constructed. would appriciate if you could assist further to make it more accurate.
    select
    case when LSGD = '00000000' then 'NS'
    when LSGD <> '00000000' then
    case when RP=0 then case when RC=0 then 'NU' else case when RC >0 then 'RR' else 'TT' end end
    else
    case when RU=1 then 'NU' when RU>1 and INT=0 then 'TT' else 'RR' end
    end
    when PERC >=0.66 then 'RR'
    when PERC < 0.66 then 'TT'
    end TC
    from my table
    Thanks in advance

  • Check the Row state in Application Module.

    Hi All,
    I have an EOVO in my page. Is there any way to check the row state in Application module??
    My requirement is if any row is created for the EOVO , just delete it.
    Please suggest suitable methods to fulfill this requirement...
    Regards,
    Tarun

    Yes, you can check the status of the rows of a VO in Application Module(AM)
    In AM, get the instance of the VO and loop through it's rows and check the status of the rows as
    In row you have a method called getNewRowState(). It will return values like Row.STATUS_INITIALIZDED etc.
    Check the javadoc of oracle.jbo.Row for possible values and explanations about the status.
    So ideally you have to write a condition as follows. This is a sample code..just use as a guide.
    if (row.getNewRowState() = oracle.jbo.Row.STATUS_INITIALIZED){
    row.remove();
    Regards,
    Peddi.

  • Decode statement in Select line of a View Object Query

    I attempted to create a view object in expert mode with a customized query.
    The query had a decode statement in the select line of the query. The view
    object compiled correctly but gave an error when run.
    ex: select .... decode(CrpSchools.SCHOOLS_ID,null,CrpCustSchools.SCHOOL_NAME,CrpSchools.SCHOOL_NAME) SCHOOL_VALUE, ...
    from ....
    where ....
    The error was that school_value does not exist in the statement. I got the error when
    doing a vo.executeQuery().
    When I removed the decode statement everything worked correctly. Does anyone know if
    the decode statement cannont be used in the select line of a query in a view object?
    Or maybe I was linking the query column (SCHOOLS_ID) up to the view attribute (SCHOOL_VALUE) incorrectly in the
    Attribute Mappings tab of the VO wizard?

    There should be no problem using a DECODE() statement, provided that you've aliases the column as you have done.
    At design time, if you click on the (Test) button, does your query test ok?
    Are you by chance applying a custom where clause at runtime?
    If so, are you saying:
    setWhereClause("yourtable.column_alias = ?";
    or are you doing:
    setWhereClause("column_alias = ?";
    for an expert-mode query, you'll need to use the latter syntax.

  • Action with a condition that checks for a survey filled in a transaction

    Hi!
    I need to create an action with a condition that checks if there is a survey filled in the complaint document.
    Is there any way to do it?
    Thanks a lot!
    Susana Messias

    Hi Siva,
    Thanks for the document.
    My scenario its the following:
    I have a complaint with a survey assigned to it. I need to create an action that creates a follow-up task to the person responsible when the status is equal to Completed and the survey it's not filled.
    I customized the action profile as you said, but the problem is to create a condition with the information about the survey. The field status it's ok to insert in a condition, but how about the survey?
    Any ideas?!
    Susana Messias

  • Logical Standby SQL Apply Using Incorrect Decode Statement

    We are seeing statements erroring out on our logical standby that have been rewritten (presumably by sql apply) with decode statements that don't appear to be correct. For example, here is one of the rewritten statements.
    update /*+ streams restrict_all_ref_cons */ "CADPROD"."OMS_SQL_STATEMENT" p
    set *"APPLICATION"=decode(:1,'N',"APPLICATION",:2)*,
    "STATEMENT"=dbms_reputil2.get_final_lob(:3,"STATEMENT",:4)
    where (:5='N' or(1=1 and (:6='N' or(dbms_lob.compare(:7,"STATEMENT")=0)or(:7 is null and "STATEMENT" is null)))) and(:8="APPLICATION")
    The problem comes in, we believe, with the attempt to write the value "APPLICATION" to the application column which is only a 10 character field. the value for the :1 bind variable is "N" and the value for :2 is null.
    We see the following error on the logical standby:
    ORA-00600: internal error code, arguments: [kgh_heap_sizes:ds], [0x01FCDBE60], [], [], [], [], [], []
    ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [kxtoedu+54] [PC:0x2542308] [ADDR:0xFFFFFFFFFFFFFFFF] [UNABLE_TO_READ] []
    ORA-12899: value too large for column "CADPROD"."OMS_SQL_STATEMENT"."APPLICATION" (actual: 19576, maximum: 10)
    Is this a configuration issue or is it normal for SQL Apply to convert statements from logminer into decode statements?
    We have an Oracle 10.2.0.4 database running on windows 2003 R2 64-bit os. We have 3 physical and 2 logical standby's, no problems on the physical standbys.

    Hello;
    I noticed some of your parameters seem to be wrong.
    fal_client - This is Obsolete in 11.2
    You have db_name='test' on the Standby, it should be 'asadmin'
    fal_server=test is set like this on the standby, it should be 'asadmin'
    I might consider changing VALID_FOR to this :
    VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES)Would review 4.2 Step-by-Step Instructions for Creating a Logical Standby Database of Oracle Document E10700-02
    Document 278371.1 is showing its age in my humble opinion.
    -----Wait on this until you fix your parameters----------------------
    Try restarting the SQL Apply
    ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATEI don't see the parameter MAX_SERVERS, try setting it to 8 times the number of cores.
    Use these statements to trouble shoot :
    SELECT NAME, VALUE, UNIT FROM V$DATAGUARD_STATS;
    SELECT NAME, VALUE FROM V$LOGSTDBY_STATS WHERE NAME LIKE ;TRANSACTIONS%';
    SELECT COUNT(1) AS IDLE_PREPARERS FROM V$LOGSTDBY_PROCESS WHERE
    TYPE = 'PREPERER' AND STATUS_CODE = 16166;Best Regards
    mseberg
    Edited by: mseberg on Feb 14, 2012 7:37 AM

  • Condition type check in va01 transaction

    Hi friends,
    I have a requirment.
    in va01 transaction , at the line item level iam entering a  material number and order quantity and  when i press enter i get the corresponding values for that particular line item.
    now iam double clicking on that particluar line item(matnr) and clicking on the conditions tab.
    there in the condtion type i will get what all the condition types are maintianed for that particular line item.
    now my requirment is i need to add another concdtion type manully
    say 'ZABC' and hit enter. the pricing for that particlular contion type 'ZABC' will be Determined.
    Now  can any one tell me in which internal table will i get all the condition type,
    coz i need to do some additional check for the  the manual entry'ZABC'  (condition type ) which i have given .
    which user exit should i use it.
    remember i need user exit for condition type check but not for pricing bsaed on the contion type
    Regards
    Priyanka.

    Hi priyanka
    If you want to Check  then check in the  KOMK and KOMP tables
    As you want to go for user exit use any one of the user exits as per your requirement  USEREXIT_PRICING_PREPARE_TKOMK  or USEREXIT_PRICING_PREPARE_TKOMP
    But can you tell what exactly you want to change and why you want to go for user exits
    Regards
    Srinath

  • How to determine INT and FLOAT in a DECODE statement

    Can anyone help me with the following problem:
    I have a column defined as a NUMBER(15,4). I am trying to determine the java type using the getScale() method in ResultSetMetaData. When the scale is greater than 0, then it is an float, else it is an int. In this case, the getScale() method should return 4. However, when querying with a DECODE statement on the NUMBER(15,4) field, the getScale() method always returns 0 and the value is therefore converted to an int. Anyone knows how to solve this problem?
    Thanks

    Alcides,
    Oracle NUMBER data type is mapped to "java.math.BigDecimal" class.
    You will find more information in the JDBC Developer's Guide and Reference which is part of the Oracle documentation and available from:
    http://www.oracle.com/technology/documentation/index.html
    Good Luck,
    Avi.

  • Need help on decode statement

    I had the table as follows :
    ITEMCODE TEDCODE AMOUNT
    AAAA BED 12345
    AAAA EDU CESS 1234
    AAAA SHECESS 123
    AAAA CST 3% 12456
    AND SO ON.
    Now i want to convert the rows in Column heading TEDCODE to columns. But i want the specific rows like BED, EDU CESS, SHECESS in one column suppose EXCISE, and the other row i.e CST 3% in other column under heading TAX.
    Please help me how i can do it using Decode statement.

    SQL> create table t (itemcode varchar(4),tedcode varchar(10),amount number);
    Table created.
    SQL> insert into t values('AAAA','BED',12345);
    1 row created.
    SQL> insert into t values('AAAA','EDU CESS',1234);
    1 row created.
    SQL> insert into t values('AAAA','SHECESS',123);
    1 row created.
    SQL> insert into t values('AAAA','CST 3%',12456);
    1 row created.
    SQL> select itemcode, tedcode,decode(tedcode,'CST 3%',null,amount) EXCISE, decod
    e(tedcode,'CST 3%',amount,null) TAX from t;
    ITEM TEDCODE    EXCISE                                          TAX
    AAAA BED        12345
    AAAA EDU CESS   1234
    AAAA SHECESS    123
    AAAA CST 3%                                                   12456

  • Workflow condition to check error records in a multi line container element

    Hi All,
    My requirement is to change a standard workflow in which below condtion is checked and subsequent action is taken.
    The condtion checks a return internal table contains a row or not. Now the problem is for success and Information messages
    also the return table contains entries and the condition is becoming true. Subsequently workflow follows error recovery steps when there is no error.
    SAP suggests a note with manual corrections and mentions to change the condition to check whether error records are there. So can we enhance the condition &return& NX to something that it checks error records. I dont want to create a new step and go to business object method to delete non error records.
    Please let me know if this condition can be enhanced.
    Thanks in Advance.
    Aleem Mohiuddin.

    Dear Aleem,
    As this is sap standard workflow, should report this error and wait for feed back. Or add a loop step before of this check any E messages inside, if yes put a errflg as x other wise keep as blank.
    Best of luck.
    Regards,
    Ranjith

  • Calling a stored proc in a decode statement

    I am having a problem calling a store procedure in a SQL statement. I am using Oracle's thin driver.
    I have been able to do the following:
    select col1,
    col2,
    SOME_STORED_PROC(var1,var2,col3)
    from some_table
    where col3 = var3
    However, when I try to call a stored procedure with-in a decode statement, the call fails. I have tested the call from a sql prompt and it works fine but it does not work when I execute the query in my Java program.
    Here is an example of what I am trying to do:
    select col1,
    col2,
    decode((select col1
    from some_other_table
    where col2 = var1), 'X',
    SOME_STORED_PROC(var1,var2,col3),
    SOME_OTHER_STORED_PROC(var2,var4,col5))
    from some_table
    where col3 = var3
    Does anyone know if this type of call is not supported in Oracle's thin driver?
    Thanks,
    Cory
    null

    I played around with a [parallel PL/SQL launcher|http://www.williamrobertson.net/feed/2008/08/parallel-plsql-launcher-update.html] a while ago, but I wouldn't call it production-ready.
    You could also [submit procedure calls in background|http://www.williamrobertson.net/feed/2005/12/job-control-object.html] using DBMS_ALERT to track completion status.

  • Problem with Decode statement

    Hi
    I am trying to achieve the following in my report:
    If an employee has a surname of . (dot) or a first name of . (dot), the report should not display a dot. An employee's name is made up of surname, first name and middle name which should all be concatenated together. To try to achieve this, I have the following statement in my report:
    decode(e.Surname, '.', ( LTRIM(RTRIM((INITCAP(e.FIRST_NAME)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    e.FIRST_NAME, '.', ( LTRIM(RTRIM((INITCAP(e.Surname)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    ( LTRIM(RTRIM((INITCAP(e.SURNAME )))||', '||INITCAP(e.FIRST_NAME)||' '||INITCAP(e.MIDDLE_NAME)) ) ) as emp_name
    FROM Employee e
    Problem: The above statement is only working for those employees with surname of . (dot). It's not working for first names of dot. How can I use the decode statement OR is there any other way of doing it without using the CASE statement?
    It seems my decode statement doesn't work with 2 different fields (surname, firstname) being tested within one decode statement.Thanks.

    Thank you so much InoL . I have used the ltrim with Replace but now have a new problem.
    Because I am joining Surname, First name and middle name together and put a comma after the Surname, the name now appears as follows:
    , Maria Ane (if Surname is a dot)
    Boiler, (if first name is a dot)
    I would like to get rid of a comma and only have comma when surname or first name does not have a dot, i.e. for those people with full names e.g. Blake, Anna Marie.
    InoL, how can I achieve this? Thanks.

  • Decode statement in a mapping involve Source Text File & Table.

    Hi All,
    Oracle 9i Warehouse Builder Client: 9.2.0.4.0
    Oracle 9i Warehouse Builder Repository: 9.2.0.2.0
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    Does OWB allow to use Decode statement in a mapping involves Source Text File and Oracle Table.
    My understanding is it's not possible, since OWB makes use of Sqlloader. For this work arround could be make use of External Table instead of Text Flat File.
    However I came across an old posting (June-2003) which says that this feature is available OWB 9.2.
    Following is the url:
    IF THEN LOGIC from Flat File to Table
    Can someone please confirm this?
    Thanks in Advance.
    Regards,
    Vidyanand

    Hi all,
    If you want to validate correctly this mapping you must to :
    1. Right click on the mapping, then Configure
    2. Right click on Sql Loader Data Files, then Create
    3. Verify that the location name is correct and complete the Data File Name
    4. OK
    The validation is now OK.
    I hope it will be help you
    Best Regards
    Samy

Maybe you are looking for

  • Error- Create Report doesnt work on client machine

    Hi All, On one of the machine i have installed BO XI R2 server, VS 2005 I have tried Create report application using Web intelligence sdk on it and it's working. But when i try to run the same sample from another machine it throws an error as below.

  • Using the phone on other networks.

    Hey guys i have searched for this through the threads but cant find an exact answere. I have a E51 that was from Finland, I know there are diff models from diff areas, I live in the US and the phone is unlocked, on Tmobiles network, Tmobile works in

  • Residence and restention time for archiving object

    Folks I am starting archiving in our company and have question on residence time and retention time of the document. In which activity or t code we use to specify these timing once we determine that timing after discussing with business. So we have t

  • Hangs every 50 days

    hi folks. i have Oracle 10g (10.2.1.0) on Debian Linux 2.6.19 (etch). it seems every 50 days, the whole system hangs. i have to reboot the whole server in order to get it to work again (not just kill off all the oracle processes). when it hangs, i ca

  • What region to choose?

    Hello, I live in Latvia (Baltic countries). I have bought ps4 from England and i have a question. What region should i choose to purchase all games prom ps+, pay for ps+ subscription and all other thing, trough my bank card. My bank card is registere