Switch syntax
The code is as follows
Copy Code
switch (expression){case constant Expression 1: statement 1;....Case constant Expression 2: statement 2;Default: statement;}
Default is to execute it if it is not matched, and default is no
The CASE expression is added to SQL in Oracle8i, and Oracle9i extends it so that the CASE expression and CASE statement can be used in PLSQL. The value matches the CASE expression.
The CASE expression is added to SQL in Oracle8i,
In summary, the use of switch is to determine if the expression after the case matches the expression after switch, and once the case is matched, the subsequent program code is executed, regardless of whether the following case matches until the break was met . Do not match to find default. No matter where default is placed. As soon as a junction (
Tags: Linux shell1.case structural Conditional statement syntaxThe case statement is actually the canonical multi-branch if statementCase "string variable" inValue 1) Instruction 1 ...;;Value 2) Instruction 2 ...;;*) Instruction 3 ...EsacChinese programming Syntax:Case "Find a girlfriend condition" inHave a room) to ma
look at this. When this value is set to 0 o'clock, a table with a self-increasing field inserts the behavior of a row of data:
1) Apply for Auto_inc lock
2) Get the current AUTO_INCREMNT value N, give auto_increment plus 1
3) Perform the insert operation and fill n into the new row corresponding field
4) Release Auto_inc lock
We see this process, although innodb in order to reduce the size of the lock, the execution of the statement is released
Case has two formats. Simple case functions and case search functions.
-- Simple case Function Case Sex When '1' Then Male' When '2' Then Female' Else 'Others' End -- Case search function
If statements process two branches, the IF-else-If structure must be used when processing multiple branches. However, if there are many branches, the more nested if statement layers,ProgramIt is not only huge but also difficult to understand. Therefore, the C language provides a conditional selection statement specifically used to process multi-branch structures, calledSwitch
Select Case statement
Execute several sets of statements based on the expression value.
Select Case testexpression[Case expressionlist-n[statements-n]] . . .[Case Else expressionlist-n[elsestatements-n]]End SelectParameters
Testexpression
Any number or string expression.
Exp
label: des Io ar uses on art log EF as
For such a combined logic circuit [email protected] (x) Case (x) x1: X2 :...... Endcase if the branch item contains all the values of variable X and does not overlap with each other, there is no need to use a comprehensive command in this case. (1) Some books in "// synthesis parallel_case" are used to introduce case statem
SQL server's case when then statement, sqlcase
-- Select DataName,-- Case Code---- When 'w01' then 'male'---- When 'w07 'then' female'---- Else 'others'---- End as Code-- From dbo. HistoryData
Select DataName,(CaseWhen Code = 'w01' then 'male'When Code = 'w07 'then' female'Else 'others'End)From HistoryData
The access database has SQL server-like
. Otherwise, execute action.
Instance (testuntil. Sh ):
#! /Bin/sh
A = 10;
Until [[$ A-lt 0]; do
Echo $;
(-));
Done;
Result:
Sh testuntil. Sh
109876543210
Iii. Shell selection statement (case and select usage)
Use Case/esac)
Syntax structure
Case $ ARG inPattern | sample) # ARG in pattern or sample;;Pa
If testexpression matches any of the case expressionlist expressions
, execute the statement between this case clause and the next one, for the last
clause, the statement is executed between the clause and the end Select, and the control
The statement that is transferred
;
Check whether the problem is resolved.
1.4Reference informationSuppose you want to track a session. Only need to open the session level, after tracking please close.· turn on session level tracking:Sql> alter session Set sql_trace = Ture;· To turn off session level tracking:Sql> alter session Set Sql_trace = FALSE; Copyright notice: This article Bo Master original article. Blog, not reproduced without consent. Oracle Database
Next we will talk about the mysql stored procedure case statement syntax and instance tutorial. on the home page, let's take a look at the simple description of the case statement, and then explain the specific usage of the case with examples.
Next we will talk aboutMysql tu
One of the SQL statement judgment methodsCase has two formats. Simple case functions and case search functions.-- Simple case FunctionCase sexWhen '1' then 'male'When '2' then 'female'Else 'others' end-- Case search functionCase when sex = '1' then 'male'When sex = '2' then
(" has a great website ") Case
" Tim Cook ":
println (" CEO of Apple Inc. ")
Default:
println ("Someone Else")
}
In addition to being able to use a switch for strings, note here are some interesting things to do. Did not see the break. Because the execution of a case statement in the switch is not done down. No more chance to appear bug!
And for insta
Keyword: case
Case has two formats. Simple Case functions and Case search functions.
-- Simple Case Function
CASE sex
WHEN '1' THEN 'male'
WHEN '2' THEN 'female'
ELSE 'others' END
-- Case
The CASE expression is added to SQL in Oracle8i, and Oracle9i extends it so that the CASE expression and CASE statement can be used in PL/SQL.CASE expression for value matchingThe CASE expression is more flexible than the DECODE function. In its simplest application method,
The switch case where you learned the choice statement today is a multi-select scenario that you can use.Case:Enter the month and the number of the output is how many days this yearThe 1,3,5,7,8,10,12 month is 31 days a year.This year's February is 28 days the other is 30 intM1 = to, M2 = -, M3 = to, M4 = -, M5 = to, M6 = -, M7 = to, M8 = to, M9 = -, M10 = to, M11 = -; ----don't need t
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.