'); when ' Green light ' thenDbms_output.put_line (' line '); when ' Yellow light ' ThenDbms_output.put_line (' et '); ELSEDbms_output.put_line (' The information you entered is incorrect. ‘); END case;END; --for Loop ( Note: BEGIN end,loop. EXIT when TRUE: END LOOP)BEGIN LOOPDbms_output.put_line (' information ... '); EXIT when TRUE; END LOOP;END;--Let the above loop execute 5 timesDECLAREV_i Number (10): = 0;BEGIN LOOPDbms_outp
One, if statementIn PL/SQL, keywords such as if, then, else, elsif, endif are used to perform conditional logicSyntax format:if conditions 1 Then Statement 1elsif conditions 2 Then Statement 2Else Statement 3End If; Example 1: Practice If structureSolution: Note the program in:Second, Case statementSyntax structure:
Case statements and case expressions are an important part of plsql Process Control. Although they are easy to use, they are easy to confuse. This article describes the case statement and case expression, and provides a demonstration to better understand the similarities and
Oracle experiences 1 -- oracle introduction @ basic SQL statement @ conditional query @ sort data theory and case studies1. Oracle IntroductionOracle is the first word for English translation of oracle (
The Oracle case statement is one of the most commonly used statements. The following describes the syntax of the Oracle case statement and provides an example to help you.
When multiple condition branch statements are executed, th
cannot give the literal value null to EXPRESSION1,2. Coalesce[,k??? ' Les] FunctionsThe COALESCE function compares each expression in the expression list to null and returns the value of the first non-null expression. The COALESCE function has the following structureCOALESCE (Expression1,expression2,........., expressionn)If expression1 equals null, EXPRESSIOIN2 is computed. If the expression2 evaluates to NULL, the function returns EXPRESSION2 and returns null if the result of all expressions
This article will introduce the usage of the oracle/plsql case Condition Statement, which is similar to mysql mssql. If you need to learn more, let's take a look.
Statement syntax
The Code is as follows:
Copy code
CASE [expression]WHEN condition_1 THE
Oracle Decode () functions and case statements are all common use, so what is the difference between them? Here's a detailed description of
The difference between the Oracle Decode () function and the case statement for your reference.
First, give 2 simple examples to comp
1. The case-when expression has two forms
Copy Code code as follows:
--Simple Case function
Case Sex
When ' 1 ' THEN ' male '
When ' 2 ' THEN ' woman '
Else ' other ' end
--case search function
Case
When sex = ' 1 ' THEN ' male '
When sex = ' 2
WHEN salary> 500 AND salary WHEN salary> 600 AND salary WHEN salary> 800 AND salary Else null end;
3. Other IF-THEN-ELSE implementations3.1 DECODE () functionCopy codeThe Code is as follows: select decode (sex, 'M', 'male', 'F', 'female ', 'unknown ')From employees;
It seems that only Oracle provides this function, and ansi SQL is not supported, and the syntax is not CASE WHEN clear, which is not recommend
Grammar:Case SelectorWhen Exp1 then Res1When Exp2 then Res2When Exp3 then Res3...[ELSE RESN]EndSql> Declare2 Mygrade char (1): = ' A ';3 res varchar2 (20);4 begin5 Res: =6 Case Mygrade7 when ' A ' and ' The mark is 90-100 '8 when ' B ' and ' The mark is 80-90 '9 when ' C ' and ' The mark is 70-80 'When ' D ' and ' The mark is 60-70 'Once ' E ' then ' the mark is 0-60 'The END;Dbms_output.put_line (RES);The end;15/The Mark is 90-100PL/SQL procedure suc
Tags: style cas double quote Log ACL query table SEL statementExample 1: A) double quotation marks are required for column names that begin with "_" in the Query column. b) Use the "case" keyword to determine whether the pass is directly based on the score. create table Tbl_score (id number (4 ), -- id name" Span style= "COLOR: #0000ff" >varchar2 (30 ), -- name score number3 ), -- fraction otherscore number (3 ) -- other scores ); sel
statement syntax
The code is as follows
Copy Code
case [Expression]When Condition_1 THEN result_1When Condition_2 THEN result_2...When Condition_n THEN result_nELSE resultEnd
expression is optional. It's worth the list of conditions that you compare. (ie: condition_1,condition_2, ... condition_n)
Condition_1 to Condition_n must be of the same data type. The order that
UpdateHr_user uSetU.is_approve=( Case whenu.curr_org_idinch (Selectt.org_id fromhr_organization t start witht.org_id= 10001263Connect byPrior org_id=T.org_id_parent) Then 'N' ELSE 'Y' END); UpdateHr_user uSetU.is_approve=( Case whenu.curr_org_idinch (Selectt.org_id fromhr_organization t start witht.org_id= 10001263Connect byPrior or
A simple case expression that uses an expression to determine the return value.
Grammar:
The code is as follows
Copy Code
Case Search_expressionWhen Expression1 THEN RESULT1When Expression2 THEN result2...When Expressionn THEN ResultnELSE Default_result
Search the case expression, using criteria to determine the return valu
Oneexec While Read lineDo? InstructionsDoneMethod TwoCat File|while Read LineDo? InstructionsDoneMethod ThreeWhile Read lineDo? InstructionsDoneUntil syntaxUntil Do? directive:DoneNote: The condition will not be established, the execution of the cycle, the condition is set to stopFor syntax1 for variable name in variable listDo? directive:Done2 for ((EXP1;EXP2;EXP3))Do? directive:DoneDescriptionThe for is followed by 3 expressions, the first is the variable initialization, the second is the ran
$a=5;switch($a){ case 6: echo "\$a is 6"; case 5: echo "\$a is 5"; case 4: echo "\$a is 4";}
As in the above example, my understanding is that each time $ A is compared to the value of the case, the output statement is the same, and the non-conformance is the nex
Case statements and case expressions are an important part of PLSQL Process Control. Although they are easy to use, they are easy to confuse. This article describes the case statement and the case expression, and provides an example
This helps you better understand the simil
PL/SQL daily question: the difference between a CASE statement and a CASE expression: there are many different types of guinea pigs in the world, some of which have identifiable characteristics. For example, the "Abyssinians" skin has a pleated garlands www.2cto.com "Texels" with long curly hair. In contrast, the White Crested Guinea Pig on the header contains a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.