Decode the help function

Hello

I'm new to the development of Oracle.

MY requirement:

I need to fill a column "ISMSG" by YES / NO based on the following condition

When the code = the of ' or 'O'... the 'ISMSG' column should display any other YES no.

That is, output should be like

CODE ISMSG

A NO
S YES
S YES
O YES

My code for the Decode function:

CASE
WHEN s = c.code ' THEN decode (c.code, the of ',' YES, 'NO')
WHEN c.code = 'o' THEN decode (c.code, 'O', 'YES', 'NO')
END ISMSG

My code is correct? If Yes is the best way to do it?
If this is not the case, correct the code.

Is there an effective way to do it?

Thanks in advance.

Hello

You can use CASES or DECODE for this; There is no need to use both.
With the help of CASE:

SELECT  c.code
,     CASE
         WHEN  c.code  IN  ('S', '0')  THEN  'YES'
                                           ELSE  'NO'
     END     AS ismsg
FROM    table_x   c;

Using DECODE:

SELECT  c.code
,     DECODE ( c.code
            , 'S'      , 'YES'
            , '0'      , 'YES'
                          'NO'
            )          AS ismsg
FROM    table_x   c;

I suggest that you forget to DECODE and use always the CASE, at least while you are beginner.

CASE may do everything they can to DECODE. There is a little bit simple, situations where DECODE is a little shorter than the CASE and therefore a bit clearer, but only a little and, as I said, these are just simple situations, and CASE is clear enough in them.
DECODE is never much shorter or clearer than the CASE. The reverse is not true: there are many situations where the CASE is much, much shorter and lighter than DECODE.

Tags: Database

Similar Questions

  • Adobe Photoshop CS5.1 reinstalled because the help functions gives an error message (7).

    Hello

    When I tried to use the help function Adobe Prhotoshop CS5.1 a pop-up message shows errorcode (7) advise to reinstall the product. So I did, but it did not work. What can I do more? Mind you, the help in bridge function works as it should and the two products are installed at the same time.

    Kind regards

    AAD

    Thanks, I found a few topics on the error. I reinstalled and now it works.

    AAD

  • Decode the simple function

    Gurus,

    Please help me with a decoding function.

    doknlbc can be null or different bnuinfc in some occasions.

    Select dokkeyi, (doknlbc, null, 'no emp_id', bnuinfc) decoding as dok emp_id, bnu
    where doknlbc = bnunamc and dokkeyi in (6545,6525);


    Result
    EMP_ID DOKKEYI
    6545 70348

    Result, I want to!
    EMP_ID DOKKEYI
    6545 70348
    6525 no emp_id

    Thanks for the help!

    Try this:

    select dokkeyi, decode(doknlbc,null,'no emp_id',bnuinfc) as emp_id
    from dok, bnu
    where
         ( doknlbc = bnunamc  or
           doknlbc is null
         )
         and dokkeyi in (6545,6525);
    
  • How to implement a callback to the help function call library function node in LabView?

    I try to call a fuction from a SDK.dll library by using the node call library feature. The SDK has been provided to

    me and I don't have the source code, just the .dll and .h files.

    The SdkSetPropertyEventHandler function has a function of recall as one of its parameters. How to apply the

    callback using the NSI node? I'm a good programmer LabView but this is my first time using the library to call

    Function node. I read all the info I can find on the web site of NOR and the discussion Forum, but can not understand

    This one out. I'm using LabView 8.6.

    The deacribes SDK.h function as:

    Function: SdkSetPropertyEventHandler

    (SdkSetPropertyEventHandler) SdkError SDKAPI
    SdkCameraRef inCameraRef,
    SdkPropertyEvent inEvnet,
    SdkPropertyEventHandler inPropertyEventHandler,
    SdkVoid * context);

    //
    Description:
    Registers a callback function to receive the status
    change the notification events for the States of property on a camera.
    //
    Parameters:
    In: inCameraRef - designate the object camera.
    inEvent - designated one or all the events will be completed.
    inPropertyEventHandler - designate the pointer to the callback
    function to receive the camera property-related events.
    inContext - designated application information must be passed
    way to the callback function. All the data necessary to
    your application can be passed.
    Output: no
    //
    Returns: A sdk errors.
    -----------------------------------------------------------------------------*/

    A separate header called SDKTypes.h file contains the following data:

    typedef SdkUInt32 SdkPropertyEvent;
    typedef SdkUInt32 SdkPropertyID;
    typedef void SdkVoid;

    typedef struct __SdkObject * SdkBaseRef;
    typedef SdkBaseRef SdkCameraRef;

    /*-----------------------------------------------------------------------------
    SdkPropertyEventHandler
    -----------------------------------------------------------------------------*/
    typedef SdkError (SDKCALLBACK * SdkPropertyEventHandler))
    SdkPropertyEvent inEvent,
    SdkPropertyID inPropertyID,
    SdkUInt32 inParam,
    SdkVoid * context);

    Thanks for your help.
    Alejandro

    Andrew_E wrote:

    Hi Rolfk,

    You are absolutely right. This article describes what you were talking about? I'm just trying to get as much information as possible on this thread if the solution is easier to find for the future. Thank you.

    Yes, but I find the idea of using .net to call a LabVIEW VI as callback function C a bit as using a roll of Steam ironing your pants. Why do it? Well the steamroller has extra security guards that make it less likely that you'll break your pants in the process, but it's not elegant IMHO.

    Write a C DLL that translates between a C callback and a user event LabVIEW using the PostLVUserEvent() of the interface of the kernel to run LabVIEW function seems so eleganter for me. Yes, it's a bit of programming in C, but good!

    Rolf Kalbermatter

  • Decode the help of HTML special characters

    Hello

    I use a BrowserField to see others come from HTML content via the server.

    But the data being sent is encrypted (with special characters as "< p & gt")

    So I think I must decode before moving on to the BrowserField.

    Can someone offer me please how to decode?

    See you soon

    http://supportforums.BlackBerry.com/T5/Java-development/BrowserField-help/m-p/1175777#M163832

  • Decode the query help

    Hello
    I'm new to the development of Oracle.
    Oracle 10 g 2

    My original query:

    SELECT APP, count (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    and the APP ("SAPPI", "SAPPI", "SAPR3") and INTERVENE ('9320 ', '9332','1208 ')
    GROUP BY APP TYPE
    order of the APP

    the result of this query:
    SAPPI 100
    SAPPI 600
    SAPR3 440

    My requirement
    And I want to have something like output

    LDCS 100
    TSW 600
    PDC 440

    IE.the APPP and STEP combinations. Must return the specified values
    SAPPI & 9320-> LOC (here SAPPI IE APP is the same for both... but it's a coincidence IE APP can be sliced also)
    SAPPI & 9332-> tsw
    SAPR3 & 1208-> pdc

    Options, I tried:
    Query provided by one of the Forum members...
    SELECT THE CHECK BOX
    WHEN APP = "SAPP1" THEN DECODE (step, '9320', 'LSW', '9332', "TSW")
    WHEN APP = "SAPR3" step = '1208' AND 'PDC '.
    END app
    COUNT (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    AND THE APP ("SAPPI", "SAPPI", "SAPR3")
    AND STEP IN ('9320', '9332', ' 1208')
    GROUP BY APP, STEP
    ORDER OF THE APP.

    EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |


    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')


    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    2. is the right to approach? Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where < COND >

    If Yes can you please provide the query?

    3. ANY other approach / request for my requirement.

    Thanks in advance.

    Hello

    user13517642 wrote:
    ... EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |

    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')

    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    A full table scan might be the fastest way to get results. Do you have any reason to think that it would be faster to go through the index? How selective are the clues? In other words, what is the percentage of rows in the table correspond to each of the values in the WHERE clause?

    2. is the right to approach?

    It depends on what you're trying to do, which is not at all clear to me.

    Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where

    If you use this approach, look out for the problem Ab asse crevit . For example, if you have these 4 rows and 2 columns:

    str1     str2
    ----     ----
    (NULL)     FOO
    F     OO
    FO     O
    FOO     (NULL)
    

    There are 4 values of distict of str1 (counting NULL) and 4 separate values of str2, str1 but | str2 is the same for each of them. In the above example, it there is no way to know, just by looking at the concatenated string, including str1 and str2 ends begins. Maybe it's not the case for your specific data (for example, if the application is still exactly 5 characters long). otherwise, you may need to add some kind of delimiter, like this

    app || '+' || step
    

    where you know that '+' never occurs in one of these columns.

    3. ANY other approach / request for my requirement.

    CASES, as I mentioned in your previous message:
    Decode the help function
    and as you have used above.

    In this thread, you said "I have to use the decode function. Why? It is a competition of school Etudieeo DECODE is explicitly required? Why you don't want in the best way, what that turns out to be?

    Your WHERE clause:

    AND APP IN ('SAPPI', 'SAPPI', 'SAPR3')
    AND STEP IN ('9320', '9332', '1208')
    

    admits 6 possible combinations of APA and step:

    app     step
    -----     ----
    SAPP1     9320
    SAPP1     9332
    SAPP1     1208
    SAPP3     9320
    SAPP3     9332
    SAPP3     1208
    

    but you are looking for only 3 of these combinations in DECODE it or the expression BOX. (Have 2 copies of 'SAPP1' e list won't do any good, but it does hurt real, either.)
    By the way, is "SAPPI" app with the letter 'I' at the end, or "SAPP1", with the number '1' at the end?

    Published by: Frank Kulash, March 24, 2011 19:44

  • With the iPad Pro 9.3.1 running, I do find a way to set the sleep function. I sleep in about two minutes. Help

    With the iPad Pro 9.3.1 running, I do find a way to set the sleep function. I sleep in about two minutes. Help

    (It sleeps)

  • How to use the NVL function in decoding?

    Hi all

    How to use the NVL function in decoding?

    SELECT Decode (Sign (sum (nvl (7), 0)-nvl (sum (5), 0)), - 1, 0, (sum (nvl (7), 0)-nvl (sum (5), 0)) QTY)

    of the double

    Thank you

    You should not do that...

    Greatest (NVL (Sum (Quantity), 0)-NVL (SUM (quantity_received), 0), 0) AS qty_arrival

    will do the same

    HTH

  • Since I use photoshop CC I've not found an easy way to scan by using the discreen function? help please

    Since I use photoshop CC I have not found a way to use the discreen function when you scan... help!

    discreen function?

  • Upgrade to LR5.7 and PS Elements 13.  With the help of an SSD that is more complete! Can I remove older versions of these programs without affecting the functionality of the new programs?

    Upgrade to LR5.7 and PS Elements 13.  With the help of a Solid State Drive, which is more complete! Can I remove older versions of these programs without affecting the functionality of the new programs?

    Yes, there is no need to keep older versions of the software on the SSD (or your computer).

    In addition, you mentioned but if the photos are on the SSD, you must move them off the SSD for a typical hard drive, by following these instructions: Adobe Lightroom - find folders and files moved or missing

  • I'm new to LR and did install you on a Mac desktop computer and laptop.  On the laptop, the basic function under develop simply disappeared.  I'm lost.  Help.

    Question: I'm new to LR and did install you on a Mac desktop computer and laptop.  On the laptop, the basic function under develop simply disappeared.  I'm lost.  Help.

    This is a common problem. The basic Panel is simply hidden.

    Billboards / of masking is actually a function of Lightroom, but it is intuitive--not many people know that there are - for the most newcomers are thrown when a Panel is somehow hidden.

    Right-click anywhere in the area of the Panel on the right hand side and a context menu will appear.

    Click on the basic option to re - appear the basic Panel.

  • need help to get the value using the REGEXP_REPLACE function.

    I am trying to extract the value placed between "< listitems >... < / listitems >" but I am unable to get these value using the REGEXP_REPLACE function.
    select REGEXP_REPLACE('<InputParameters></ParamSet><listitems>14545454</listitems></ParamSet></InputParameters>'
    ,'(<InputParameters>.*<listitems>)(.*)(</listitems>.*<InputParameters>)'
    ,'\2') from dual;
    required output:
     1454554
    Can someone please help me achieve this goal.

    Hello

    You forgot the / before the last InputParameters. If fix you that, your code will work.

    Here is a slightly different way:

    SELECT  REGEXP_REPLACE ( '14545454'
                     , '^.*?(.*?).*$'
                     , '\1'
                     )     AS listitems
    FROM    dual
    ;
    

    Least to type, the less likely you will have to make typos.
    If there are 2 (or more) elements of listitmes, 1 will be returned.

    From Oracle 11.1, you can also use REGEXP_SUBSTR. I have Oracle 10.2 avaialable now, so I can test the following, but I think you'd say:

    SELECT  REGEXP_SUBSTR ( '14545454'
                     , '(.*?)'
                     , 1
                     , 1
                     , NULL
                     , 1
                     )     AS listitems
    FROM    dual;
    

    When it comes with the text that is or looks to, XML, consider using XML functions.

  • help in the application without using the pivot function

    Hi gurus,

    Can you please help write the query without using the PIVOT function.
     WITH indata AS
             (SELECT 1 sn, '123:456,789,323:456,213,344,345:5454' x
                from dual
              UNION ALL
              SELECT 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual),
            instr AS
             (SELECT a.SN,
                     rownum RN,
                     B.column_value || CASE
                       WHEN B.column_value NOT LIKE '%:%' THEN
                        ':'
                     END column_value 
                FROM indata a,
                     TABLE(CAST(multiset
                                (SELECT trim(SUBSTR(x,
                                                    (CASE LEVEL
                                                      WHEN 1 THEN
                                                       1
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL - 1) + 1
                                                    END),
                                                    (CASE instr(x, ',', 1, LEVEL)
                                                      WHEN 0 then
                                                       4000
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL) - 1 -
                                                       (CASE LEVEL
                                                          WHEN 1 THEN
                                                           0
                                                          ELSE
                                                           instr(x,
                                                                 ',',
                                                                 1,
                                                                 level - 1)
                                                        END)
                                                    END)))
                                   FROM dual
                                 CONNECT BY level <=
                                            LENGTH(x) -
                                            LENGTH(REPLACE(x, ',', '')) + 1) AS
                                sys.odcivarchar2list)) b)
            SELECT  col1_val2,
                    col1_val1,
                    col2_val2,
                    col2_val1,              
                   systimestamp
              FROM (select SN,
                          ROW_NUMBER() over(partition by SN order by RN) RN,
                           SUBSTR(column_value, INSTR(column_value, ':') + 1) VAL1,
                           substr(column_value, 1, instr(column_value, ':') - 1) val2
                      FROM instr ) PIVOT(MAX(VAL1) VAL1, MAX(VAL2) VAL2 FOR SN IN(1 as col1,2 as col2));
    Thanks in advance!...

    Any help would be appreciated.

    user590978 wrote:

    Can you please help write the query without using the PIVOT function.

    with indata as (
                    select 1 sn,'123:456,789,323:456,213,344,345:5454' x from dual union all
                    select 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual
                   ),
             t1 as (
                    select  x
                      from  indata
                      where sn = 1
                   ),
             t2 as (
                    select  x
                      from  indata
                      where sn = 2
                   ),
             t3 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col1
                      from  t1
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t4 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col2
                      from  t2
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t5 as (
                    select  lvl,
                            substr(col1,1,instr(col1 || ':',':') - 1) col1_val1,
                            substr(col1,instr(col1 || ':',':') + 1) col1_val2
                      from  t3
                   ),
             t6 as (
                    select  lvl,
                            substr(col2,1,instr(col2 || ':',':') - 1) col2_val1,
                            substr(col2,instr(col2 || ':',':') + 1) col2_val2
                      from  t4
                   )
    select  col1_val1,
            col1_val2,
            col2_val1,
            col2_val2,
            systimestamp
      from      t5
            full join
                t6
            on (
                t6.lvl = t5.lvl
               )
      order by coalesce(t5.lvl,t6.lvl)
    /
    
    COL1_VAL1  COL1_VAL2  COL2_VAL1  COL2_VAL2  SYSTIMESTAMP
    ---------- ---------- ---------- ---------- -------------------------------------
    123        456        abcd       fgrfr      23-OCT-12 11.50.12.015000 AM -04:00
    789                   rfrf                  23-OCT-12 11.50.12.015000 AM -04:00
    323        456        rfred                 23-OCT-12 11.50.12.015000 AM -04:00
    213                   tg         tg         23-OCT-12 11.50.12.015000 AM -04:00
    344                   tg         ophhh      23-OCT-12 11.50.12.015000 AM -04:00
    345        5454       op                    23-OCT-12 11.50.12.015000 AM -04:00
                          vdfgbh     poijn      23-OCT-12 11.50.12.015000 AM -04:00
    
    7 rows selected.
    
    SQL> 
    

    SY.

  • Help please, LCC does offer the same functionality as Adobe Stratus? How?

    I found in the FAQ:


    LCCS provides the same functionality as Adobe Stratus?
    Yes.  LCCS offers the same technology as Stratus today for P2P audio and video streaming.  LCCS also offers a developer, framework and hosted service designed for real-time collaboration as well as the ability and the ability to connect RTMP connections with customers RTMFP.


    The question is how can connect my existing application in Stratus with you CAC?


    I don't want to use LCCS framework, I won't use the RTMFP Protocol as Stratus phone sample video, but in a commercial product, it is possible to supply?

    So, if possible, where I point my connectUrl key and developer of stratus in a supply service?

    Thank you very much.

    Hey elattanzio, I went through the same thing how you feel when I first tried begin with low-COST airlines.   I wanted to create a connection to peer 2 peer between two applications flash with no server involved.   I also moved the example of Stratus to the LCC.

    The short answer is THAT LCCS always uses rooms to connect people.   You can make a direct connection in hand pair using rtmfp in your application.   In this case first of all your users connect to a room on the servers of the LCC, and then they will help you coordinate the rtmfp peer connection as you used with Stratus.   So you end up with all your data flowing between two clients, but both clients are connect to the room in supply.  Your customers must stay connected to companies low-cost for the duration of the video call.    Now if your clients cannot establish a connection to the cause of NAT, firewall or other issues they're going back to rtmp and all traffic will now forward through the servers of the CCA.   You can specify that you do not want your customer to fold well.

    One other important thing to understand is the pricing model.   There is an associated cost just be connected to the servers of CAC.   We found it to be nominal if, but just enough to discourage you to stay connected all the time.   This led me to develop our own system based on jabber, precense to see who was online and to initiate calls, etc..   Secondly the cost to say the audio and video traffic is routed through servers to SUPPLY was too high for our business model so we chose to not allow fall to rtmp.  I think that the cost was reasonable based on the costs of bandwidth, etc., our model just could not bear.

    So here you'll it's my understanding of things that I agonized about how to get good video chat working in our application.   Yes to peer is not 100% free, but the cost isn't too bad and you get the benefits of Adobe running a cluster of servers for you.   So for us the value was there.   Good luck with the project.

    -Eric

  • Adobe still the software that is used to decode the media is not available on this system. install the correct decoders for the file you are editing can help fix the problem

    Hello

    I got this message after the import on ten H.264 files that I coded for Adobe media encoder.  "It is not available on this system from adobe yet the software that is used to decode the media. install the correct decoders for the file you are editing can help fix the problem. »

    The files that we have shot with HD cameras.  Edited in Premiere Pro CS3.  I installed the update 3.0.1 with always the same error.

    I also tried a new project and after about ten or so files imported into a timeline, the breakdown of the system.  I tried twice...

    Thanks in advance

    Please report to us. I don't know the exact specifications. for stills in still, the limit is 4000 pixels in the largest dimension for PrPro.

    Now, I must add that in PS. resizing algorithms are better, in my opinion, than those of PrPro and again. This means that there is nothing to gain and quality of untying, important images much larger than the size of the frame of the project, i.e. of 720 x 480 for NTSC SD projects yet. The size of the image will be the limiting factor, so scratch that.

    Even in projects PrPro, I resize to exactly what I need. If I will not pan on a zoomed image, I resize it to the size of the image of the project. If I move on a zoomed image, I resize just what I need.

    Good luck

    Hunt

Maybe you are looking for

  • HP Deskjet 1510

    Sziasztok! HP Deskjet 1510 operacios rendszer frissites / 32.2.188.4770 - re / Csák es szkenel, szamitogepről NEM nyomtat asztalrol miatt! A WIN XP 98 szamitogepen - like, 32 to 64 van bites! Jol műkodott eddig! Mi a megoldas? Tudom is a kompatibilit

  • How to make a movie for a help file?

    All Howdee. Over the years, I've seen blogs, online Web pages, etc. that animated or movie files to demonstrate how to perform account operations in a program window - such as office, etc... As I thought about it, it seems that it would be necessary

  • Could not locate the trash on laptop

    I sent many fake pictures and files in the trash. I tried to recover a file deleted last night and could not find the Recycle Bin on my laptop. Usually, on my previous dell computers, it's a shortcut icon, not on this one! Can someone help me locate

  • Dell place 8 Pro 3G - Sleep / Wake Up questions

    Hello A few days ago I bought the Dell coming Pro 8 3 G tablet. I have all available Windows Updates, latest drivers and BIOS of 'My Dell'. Unfortunately, my Tablet has some problems with the mode 'sleep'. 1. only the 'Stop' and 'Restart' options are

  • Could not load the steamui.dll

    I have a problem with the steam or games reading/departure by saying: "Failed to load steamui.dll". I contacted Steam support and they gave me a ton of ways to poteancialyy solve the problem, until today, when they told me I had contact Windows It is