Difference between decode nad replace

can you plz highlight the difference between decode and replace.. am using oracle10g r2 on solaris....
these r the 2 quereies...
select count(DECODE(EMAIL_L,'%@yahoo.com%','%@thoyahoo.com%')) FROM SIEBEL.MAIL
i understand here if EMAIL_L is like @yahoo.com then it returns @thoyahoo.com
select count(REPLACE(EMAIL_L,'%@yahoo.com%','%@thoyahoo.com%')) FROM SIEBEL.MAIL
and here also if EMAIL_L has @yahoo.com then it returns @thoyahoo.com
But when i try and execute each of them i dont get any output in the decode query....
Any explainations???

decode and literals match the exact literals within column not part of string
SQL> select ename,decode(ename,'MI','IM') from emp
  2  /
ENAME      DE
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME      DE
JAMES
FORD
MILLER
14 rows selected.
SQL> select ename,decode(ename,'MILLER','MILLIONAIRE') from emp
  2  /
ENAME      DECODE(ENAM
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME      DECODE(ENAM
JAMES
FORD
MILLER     MILLIONAIRE
14 rows selected.Khurram

Similar Messages

  • Difference between compare nad compareTo method

    difference between compare nad compareTo method

    compareTo is a method of the Comparable interface; it takes one argument and compares the current object to that argument; it provides a default ordering of the objects of this class
    compare is a method of the Comparator interface; it takes two arguments and compares them; it is used to provide an external ordering, either for things that don't already have an ordering, or to provide a different ordering than the one they already have

  • Difference between Decode If else If

    What is the main difference between decode and If else if

    John Spencer wrote:
    does require a context switchOf course there is a context switch. And, yes, they are somewhat costly. But not that costly to avoid them at all costs :)
    Say you have this very piece of code (select decode) in your PL/SQL procedure. Let's say the procedure is run one million times per day.
    It doesn't take long to see how much time that would take.
    declare
        x number := 1;
        y number;
    begin
       for i in 1000000 loop
          select decode(x, 1,1, 2,2, 3) into y from dual;
       end loop;
    end;
    /On my test server the above code took about 20 seconds. That's on one core. Given that some "nothing special" production environment is 16-32 cores these days, the loop effectively took about a second.
    There are 86,400 seconds in 24 hours. Which means that, massive thanks to the context switches, we have wasted a whopping *0.001%* of our CPU time.
    William Robertson wrote:
    The OP asked about the difference between the two, and the fact that they belong to two separate languages strikes me as one rather large difference.Well, trains and buses are two types of public transport.
    If the OP asked you what would be the best to catch to get to the city, bus or train, would you tell him that buses are more frequent, but can get stuck in traffic, whereas trains run on dedicated tracks so they are more reliable, but not as frequent, and are also slightly more expensive.
    OR, would you tell him that those are different types of transportation and they can't therefore be compared.

  • Diff between decode and case

    Hi
    I need small clarification about difference between decode and case
    Thanks who visit my thread

    And for those people who can't be ar$ed to follow links...
    Decode allows for conditional output where the conditions are straightforward matches between values.
    Case allows for regular conditions to be used such as greater than, less than etc.
    Some of the things done by case can be achieved through decode as well but in a more convoluted manner than simply using case.
    ;)

  • Difference between CASE and DECODE

    Hi All,
    Could you please explain me the basic differences between the CASE and DECODE, which performs fast...?
    DECODE is Oracle one, and the CASE is ANSI standard.
    As per my knowledge, CASE is a statement and DECODE is a function which was defined in the Standard package.
    If we use DECODE, the package has to load first, so it will take a little longer than the CASE. CASE is a simple statement which is ANSI standard.
    We can use the CASE in the where clause and can not use the DECODE in the where clause.
    Please clarify me and correct me if anything wrong.
    Thanks,

    IMO, the main important point is the way CASE and DECODE handles NULL
    SQL> select ename,comm,
      2         decode(comm,300,'A',null,'B','C') dcd,
      3         case comm when 300 then 'A'
      4                   when null then 'B'
      5                   else 'C'
      6         end cs
      7  from emp;
    ENAME            COMM D C
    SMITH                 B C --"DECODE treats NULL=NULL. But for CASE, NULL is not equal to "another" NULL
    ALLEN             300 A A
    WARD              500 C C
    JONES                 B C
    MARTIN           1400 C C
    BLAKE                 B C
    CLARK                 B C
    SCOTT                 B C
    KING                  B C
    TURNER              0 C C
    ADAMS                 B C
    JAMES                 B C
    FORD                  B C
    MILLER                B C
    14 rows selected.
    {code}
    Edited by: jeneesh on Jun 3, 2013 1:13 PM
    Note: in CASE, you should use IS NULL
    {code}
    case when comm=300 then 'A'
           when comm is null then 'B'
          else 'C'
    end
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Pls tell me difference between case and decode

    Hi all
    pls tell me difference between case and decode
    regards

    Well not entirely true when you consider working with
    sign and decode together. Your example could be
    written with decode and sign like this:
    decode(sign(sal-1000),1,sal+comm,-1,sal,0)But the case expression reads more easily, I admit.Rob it was just example you considered it special case ,BTW can you do it for me by DECODE function.
    SQL> SELECT sal,comm,CASE WHEN sal>1000 AND sal<1300 THEN sal+comm ELSE 0 END
      2    FROM emp
      3  /
           SAL       COMM CASEWHENSAL>1000ANDSAL<1300THENSAL+COMMELSE0END
          5000                                                          0
          2850                                                          0
          2450                                                          0
          2975                                                          0
          1250       1400                                            2650
          1600        300                                               0
          1500          0                                               0
           950                                                          0
          1250        500                                            1750
          3000                                                          0
           800                                                          0
           SAL       COMM CASEWHENSAL>1000ANDSAL<1300THENSAL+COMMELSE0END
          3000                                                          0
          1100
          1300                                                          0
    14 rows selected.Note for OP CASE can be used within PL/SQL witing ORACLE 9i or later release
    but DECODE function can only be used within SQL.
    Khurram

  • I have bought an iPhone 4S in Brazil and I would like to know if I can replace my old iPhone for a new one (iPhone 5S), at some Apple Store in USA, if I pay just the difference between both values.

    I have bought an iPhone 4S in Brazil and I would like to know if I can replace my old iPhone for a new one (iPhone 5S), at some Apple Store in USA, if I pay just the difference between both values.

    You're welcome.
    I would advise against that for the reasons I provided.
    Could I have my iPad 2 for the new one paying the difference between their values?
    No. Sell the existing yourself and use the proceeds to purchase a new iPad.

  • What is the difference between "Replace" and "Replace by Security"

    Hi all,
    I am implementing FDM to Load data to HFM, I set them up with a proper security on the shared service and FDM. When I load data to HFM from FDM, there are 4 options to load data. (Replace, Merge, Accumulate, Replace by Security)
    A document states that
    Replace: Clears all account values from the target application, and replaces that the data in the application with the data in the load file.
    Replace by Security: Loads data to the target application only for members to which you have access.
    However, even if I used “Replace”, it worked with security which I set.
    Does anyone know what the difference between “Replace” and “Replace by Security”?
    Is there any way that FDM works without security?
    Thanks in advance
    taku

    The fact both methods are producing the same results will either be coincidence or perhaps because you are mis-interpreting the difference between the 2. When you run a Replace HFM will clear out all data based on the combination of Scenario, Year, Period, Entity and Value dimensions it does not care if you have set up security classes which may restrict access to any of the other dimensions i.e. Account, Custom1 thru 4. When you use Replace By Security HFM will still clear on the original criteria but it will respect security class restrictions set up on the other dimensions e.g. if you are assigned to a security class which is restricted to accessing only a certain subset of accounts, HFM will not clear data fro the accounts you don't have access to when you use Replace By Security

  • Difference between the Creative Decoder DDTS-100 & Creative Home Theater Connect DTS-

    I've had the Klipsch ProMedia Ultra 5. System for years now for my PC with a Sound Blaster card, and I just got a MacBook.
    http://www.klipsch.com/products/details/promedia-ultra-5-.aspx
    I've asked on the Klipsch message board about a digital decoder. I was recommended the Creative Decoder DDTS-00
    http://us.creative.com/products/product.asp?category=4&subcategory=36&product=9468
    but I also found the Creative Home Theater Connect DTS-60 for less money, any idea what the difference between the two would be?
    http://us.creative.com/products/product.asp?category=&subcategory=6&product=49

    No, for the reason mentionned in the stickies. But since you seems not knowing much on digital sound let me explain.
    Digital means it's coded with 0 and , and therefor only cable is sufficient. You might know there is many sound formats for home cinema, like Dolby Digital and DTS. And a digital decoder need to be input a compatible sound stream to be able to decode it. Which means the soundcard MUST be able to convert it's output sound in one receiver compatible format.
    Creative cards cannot do this kind of thing.
    Another thing: current home theater sound format are limited to 6. (DD-EX and DTS-ES). So you would not be able to achieve more than 6..
    THX isn't a sound format, only a certification. The THX calibrator is a must have component to correctly calibrate your speakers to enhance you sound experience.
    If you need to have TRUE surround up to 7. channels you don't need to use digital connection because it's simply useless.

  • Difference between translate & replace

    could please any one list me the difference between translate & replace function?
    thanks in adavnce
    by
    ravikumar

    http://www.psoug.org/reference/translate_replace.html
    Translate and replace are very similar in their appearance but can produce very different results.
    Translate replaces by position, the first character of the list to match is replaced by the first character of the replacement list.
    The second character with the second, and if there are characters in the list to match that do not have positional equivalents in the replacements list they are dropped.
    Replace replaces the string to match with the replacement string.
    The replacement of a single character is the same as that of TRANSLATE.

  • Difference between Replacement with a query and Replacement from Variable

    Hi Gurus
    Would explain the difference between the Replacement Path: Replacement with a query and Replacement Path: Replacement from Variable with scenarios.
    Thanks in advance,
    Aravind.S

    Hi,
    If you are using Replacement with query, the given query output will be used as input your variable. For example if you want to display the product details, which can be find our from a query.
    And Replacement with Variable will be used  when you want to give the same input  in two different fields. for example if you want to see the records from sending location and not the records from recived location at the same time. Here once you give the sending location id, it will be taken as the same input for received location.
    Regards,
    Vishnu

  • Difference between refurbished ipad and replacement ipad

    Whats the difference between the refurnished ipads sold on the online store and the replacement ipad you get when you take your ipad in for service with a defect, which is apparently also refurbished.  Are they the same thing?

    I think perhaps the most significant difference is the warranty (which has nothing to do with the device quality). If you buy a refurbished device from the Online Store, as I did with my MacBook Air (saved $200!), you get the same one year warranty you would get if you bought a brand new device. If Apple swaps out your device under warranty, you will have the remainder of your original warranty or 90 days, which ever is longer, if I recall correctly.
    If you buy a device online, you get a brown box but all of the same accessories as you would with a new one. If your device is replaced under warranty, they hand you a naked device, no accessories, no box.
    I've had one iPod, one iPhone and now, one iPad replaced under warranty. The devices were indistinguishable from new.

  • Decoding Query Plan XSD (RelOp)- what is the difference between OutputList and DefinedValues

    under http://schemas.microsoft.com/sqlserver/2004/07/showplan/showplanxml.xsd
    we have 
    <xsd:complexType name="RelOpType">
    <xsd:sequence>
    <xsd:elementname="OutputList" type="shp:ColumnReferenceListType"
    />
    <xsd:complexType name="RelOpBaseType">
    <xsd:sequence>
    <xsd:elementname="DefinedValues" type="shp:DefinedValuesListType"
    minOccurs="0" maxOccurs="1" />
    which is defined as
    <xsd:complexType name="DefinedValuesListType">
    <xsd:sequence>
    <xsd:element name="DefinedValue" minOccurs="0"
    maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:choice>
    <xsd:element name="ValueVector">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element
    name="ColumnReference" type="shp:ColumnReferenceType"
    minOccurs="2" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element
    name="ColumnReference" type="shp:ColumnReferenceType"
    />
    </xsd:choice>
    <xsd:choice minOccurs="0" maxOccurs="1">
    <xsd:element
    name="ColumnReference" type="shp:ColumnReferenceType"
    minOccurs="1" maxOccurs="unbounded" />
    <xsd:element
    name="ScalarOperator" type="shp:ScalarType"
    />
    - <!--
    unbounded for union case
    -->
    </xsd:choice>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    I can't seem to find a difference between the data in OutputList and DefinedValues. what am I missing? What is DefinedValues supposed to be? TIA.
    Mordechai Danielov

    Consider this batch (which happened to be in my SSMS window from another forum question):
    DECLARE @TempData as TABLE (
    Name nvarchar(1111) NOT NULL,
    Month char(6) NOT NULL PRIMARY KEY,
    CountName int NOT NULL
    SELECT Name, convert(datetime, Month + '01')
    FROM @TempData
    Look at the execution plan as XML and you find:
    <RelOp ... PhysicalOp="Compute Scalar">
    <OutputList>
    <ColumnReference Column="Name" />
    <ColumnReference Column="Expr1003" />
    </OutputList>
    <ComputeScalar>
    <DefinedValues>
    <DefinedValue>
    <ColumnReference Column="Expr1003" />
    <ScalarOperator ScalarString="CONVERT(datetime,[Month]+'01',0)">
    <Convert DataType="datetime" Style="0" Implicit="false">
    <ScalarOperator>
    <Arithmetic Operation="ADD">
    <ScalarOperator>
    <Identifier>
    <ColumnReference Column="Month" />
    </Identifier>
    </ScalarOperator>
    <ScalarOperator>
    <Const ConstValue="'01'" />
    </ScalarOperator>
    </Arithmetic>
    </ScalarOperator>
    </Convert>
    </ScalarOperator>
    </DefinedValue>
    </DefinedValues>
    OutputList is the values passed out from the operator to the next guy to the left. DefinedValues are values that are defined in the operator. As you see only one value is defined in the CompuateScalar operator, Expr1003.
    For the other operator in the plan, we have:
    <OutputList>
    <ColumnReference Column="Name" />
    <ColumnReference Column="Month" />
    </OutputList>
    <IndexScan Ordered="false" ForcedIndex="false" NoExpandHint="false">
    <DefinedValues>
    <DefinedValue>
    <ColumnReference Column="Name" />
    </DefinedValue>
    <DefinedValue>
    <ColumnReference Column="Month" />
    </DefinedValue>
    Here DefinedValues and OutputList are the same. But note that Name is only a defined value in this operator; it is not a defined value in the ComputeScalar operator.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • What is the difference betwee decode & case function

    Hi
    What is the difference betwee decode & case function
    1.decode can't used in pl/sql 1) case can be user
    2.in decode we can't use (>,<,>=) 2) we can use
    any other do u have....
    thanks in advance....

    DECODE works with expressions which are scalar values.
    CASE can work with predicates and subqueries in searchable form.
    There is one more Important difference between CASE and DECODE
    DECODE can be used Only inside SQL statement....
    But CASE can be used any where even as a parameter of a function/procedure
    Eg:-
    SQL> create or replace procedure pro_01(n number) is
      2  begin
      3  dbms_output.put_line(' The number  = '||n);
      4  End;
      5  /
    Procedure created.
    SQL> set serverout on
    SQL> var a varchar2(5);
    SQL> Begin
      2  :a := 'ONE';
      3  End;
      4  /
    PL/SQL procedure successfully completed.
    SQL> Begin
      2   pro_01(Decode(:a,'ONE',1,0));
      3  End;
      4  /
    pro_01(Decode(:a,'ONE',1,0));
    ERROR at line 2:
    ORA-06550: line 2, column 9:
    PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
    statement only
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    SQL> Begin
      2    pro_01(case :a when 'ONE' then 1 else 0 end);
      3  End;
      4  /
    The number  = 1
    PL/SQL procedure successfully completed.Message was edited by:
    Avi
    Message was edited by:
    Avi

  • Need to find the Difference between two table

    Hello ,
    I have stucked in program as below scenario:-
    I have two tables of huge data of same structure in a same schema.I need to find the difference exact values in tables.
    By using MINUS we can find the difference between two table ,i need to find the what exact difference in the there values with colunm and value at that column.
    Example TableA
    Col1 col2 col3 col4 col5.... col50
    10 ABC 2001 EE 444 TT
    40 XYZ 3002 RR 445 TT3
    80 DEF 6005 YY 446 YY8
    TableB
    Col1 col2 col3 col4 col5.... col50
    10 ABC 2001 EE 444 TT
    40 XYZ 3002 RR 445 TT3
    81 DEF 6005 Yu 447 YY8
    I need to the out put like this :-
    The Diffence between two table is
    TableA.COL1=80 TableB.Col1=81, Different
    TableA.Col4=YY TableB.col4=Yu,Different
    TableA.Col5=446TableB.col5=447,Different
    Please suggest me to write the pl/sql program for the same
    thanx in advance
    KK

    Thanx friends for all your efforts
    I have a sample code for the same,this will compare the two tables for single row in each table .
    what r the modification needed for the multiple rows of values in the two tables??
    Please suggest!!
    CREATE OR REPLACE PROCEDURE test_compare
    IS
    TYPE t_col
    IS
    TABLE OF VARCHAR2 (30)
    INDEX BY PLS_INTEGER;
    l_col t_col;
    j NUMBER := 0;
    l_sql VARCHAR2 (2000);
    col1 VARCHAR2 (30);
    col2 VARCHAR2 (30);
    val1 NUMBER;
    val2 NUMBER;
    status VARCHAR2 (30);
    CURSOR c1
    IS
    SELECT column_id, column_name
    FROM all_tab_columns
    WHERE table_name = 'TEST1';
    BEGIN
    FOR i IN c1
    LOOP
    j := j + 1;
    l_col (j) := i.column_name;
    END LOOP;
    FOR k IN 1 .. j
    LOOP
    l_sql :=
    'SELECT '
    || ''''
    || l_col (k)
    || ''''
    || ', '
    || 'TEST2.'
    || l_col (k)
    || ', '
    || ''''
    || l_col (k)
    || ''''
    || ', '
    || 'TEST1.'
    || l_col (k )
    || ', '
    || 'DECODE(TEST2.'
    || l_col (k)
    || ' -TEST1.'
    || l_col (k)
    || ', 0, ''NO CHANGE'', ''CHANGED'') FROM TEST2, TEST1';
    EXECUTE IMMEDIATE l_sql INTO col1, val1,col2, val2, status;
    IF status = 'CHANGED'
    THEN
    DBMS_OUTPUT.put_line( 'TEST2.'
    || col1
    || '='
    || val1
    || ', TEST1.'
    || col2
    || '='
    || val2
    || ', '
    || status);
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('Error:- ' || SQLERRM);
    END;
    /

Maybe you are looking for

  • MiniSAP 6.20: ALV tree not working in background

    Good day! SAP provides a sample ALV tree program, BCALV_TREE_DEMO, which could be submitted in the background. However, it does not work in MiniSAP 6.20. It's kind of bizarre as it works in our Test system. Does anyone has any idea what's happening.

  • Is an imac right for me?

    Hi there. I currently have a black 13" macbook that has introduced into the world of mac!! However, I am considering purchasing an imac, more than likely one of the 17" or 20" models. I have a couple of questions that I hope people can answer for me

  • Parallel approval workflow, end process

    Hi everyone I have a approval workflow that has 3 users approvers with a parallel approval.  I want to end the workflow (Approved or rejected) when ONE OF THIS USERS complete your task  Does anyone know a way to do it ? Thanks in advance! Regards

  • Dynamic Columns in TreeTable

    I am trying to create a treetable with some dynamic columns. The extra columns I need to show have been added as attributes to the node. So within the facet "nodeStamp" I display the label and need to add other columns dynamically reading the attribu

  • Install Issue with 1st Cloud Program

    I run Win 8.1 (64-bit) on a laptop with 12 GB ram. Boiling it all down, to solve this problem,I uninstalled ALL Adobe applications that ran fine prior to CC membership. Then, I installed the cloud dektop app, and attempted to install InDesign. The in