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 (
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
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
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 THEN result_1WHEN condition_2 THEN result_2...WH
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
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
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
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
block is no longer executed.Case 3: try{} catch () {return;} finally{} return;The program executes the try first, and if an exception is encountered to execute a catch block,Exception: code that executes before return in a catch, including expression operations in a return statement,Then execute all the code in the finally statement, and finally execute the return in the Catch block,The return
You may be familiar with the IF Else statement, which is used to control the process. A CASE statement statement has a similar effect in the world of SQL. The following is a simple introduction to the use of case statements. Consider the following scenario, assuming that the
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
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
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, the Oracle case
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.