![]() Why will I tell you that case is an extended version of DECODE. In this section, you can easily understand the basic difference between CASE and DECODE. Difference Between CASE and DECODE in Oracle The below comparison will help you out which is good for use. The DECODE function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i. It is used to work as an IF-THEN-ELSE statement. So I have also explained the difference between Case and Decode in Oracle. DECODE is an advanced function that the Oracle database supports. Now most the people ask me then what will we use for Decode or Case. We are taking same example for the simple understanding. We can say it is an extended version of Decode. It is same as decode for perform IF-THEN-ELSE logic.Ĭase was introduced in Oracle 8.1. It is also perform transfer your data to the another data. The above query statement behaves in the same manner as shown in the below program of PL/ SQL of If else if ladder. ![]() SELECT DECODE (500, 600, 'Six Hundred', 500, 'Five Hundred') FROM dual The output of the execution of the above query statement is as shown below. Question 1:- What is Case in Oracle?Ĭase is a statement in Oracle. Let us try executing the following query statement of decode function. Now let's take some questions with answer on the Case Statement in Oracle. DECODE has some strange behavior: 'In a DECODE function, Oracle considers two nulls to be equivalent.' That behavior is not mentioned in the TechOnTheNet. ![]() You are usually better off with the official documentation, and the page for DECODE is a good example of why. May be, Now above questions with answer will help you out for the better understanding about the Decode Function. But I disagree about using TechOnTheNet as your primary source of information. 10 is search value and Oracle is result.Let's understand in details if dept_no is 10 then decode function return Oracle, If dept_no is 20 then decode function return java same as for all and last is default if 10,20,30,40 dept_no is not found then decode function return TI support. In the above example dept_no is expression. ) Question 3:- Example of Decode Function in Oracle Question 2:- Syntax of the Decode FunctionĭECODE (expression, search, result. but in this case I will obtain an 'a' when idsegmento is equal to '1', I need it to be 'a' even when the string idSegmento contains the '1', kind of like and like statment. SELECT idsegmento AS Segmento, Decode (idsegmento, '1', 'a', 'b' ) FROM gmento. Decode helps to perform IF-THEN-ELSE logic in the SQL query. Using Decode as a like statement in oracle. Question 1:- What is Decode in Oracle?ĭecode is a function in Oracle which helps to transfer your data to the another data. In this blog post, we will understand some basic difference between Case and Decode in Oracle with the help of some questions and answer. In this SQL Tutorial, We will explore about the Difference between Case and Decode in Oracle.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |