-
Notifications
You must be signed in to change notification settings - Fork 13
Case expression
Tako Lee edited this page Mar 3, 2024
·
9 revisions
- gfmtopt.CaseWhenThenInSameLine, type of boolean, default is true
- gfmtopt.Indent_CaseFromSwitch, type of integer,default is 2
- gfmtopt.Indent_Case_Then, type of integer, default is 0
- gfmtopt.CaseWhenInSamelineAsCase, type of boolean, default is false
- gfmtopt.CaseThenExprInNewline, type of boolean, default is false
- gfmtopt.CaseElseExprInNewline, type of boolean, default is false
- TODO
-
WHEN/THEN keyword in the same line, inner block indent from 0 to n
Option: fmt080_case_indent = n, type: int.
Option: fmt081_case_then_in_newline = false, type: TFmtBoolean.
SELECT productnumber, name, 'Price Range' = CASE WHEN listprice = 0 THEN 'Mfg item - not for resale' WHEN listprice < 50 THEN 'Under $50' WHEN listprice >= 50 AND listprice < 250 THEN 'Under $250' WHEN listprice >= 250 AND listprice < 1000 THEN 'Under $1000' ELSE 'Over $1000' END FROM production.product ORDER BY productnumber;
-
THEN keyword in new line, inner block indent from 0 to n
Option: fmt080_case_indent = n, type: int.
Option: fmt081_case_then_in_newline = true, type: TFmtBoolean.
SELECT productnumber, name, 'Price Range' = CASE WHEN listprice = 0 THEN 'Mfg item - not for resale' WHEN listprice < 50 THEN 'Under $50' WHEN listprice >= 50 AND listprice < 250 THEN 'Under $250' WHEN listprice >= 250 AND listprice < 1000 THEN 'Under $1000' ELSE 'Over $1000' END FROM production.product ORDER BY productnumber;
-
First WHEN keyword in newline
Option: fmt173_case_first_when_in_newline = false, type: TFmtBoolean.
SELECT productnumber, name, 'Price Range' = CASE WHEN listprice = 0 THEN 'Mfg item - not for resale' WHEN listprice < 50 THEN 'Under $50' WHEN listprice >= 50 AND listprice < 250 THEN 'Under $250' WHEN listprice >= 250 AND listprice < 1000 THEN 'Under $1000' ELSE 'Over $1000' END FROM production.product ORDER BY productnumber;
-
THEN/ELSE expression in newline
Option: fmt174_case_then_expr_in_newline = true, type: TFmtBoolean.
Option: fmt175_case_else_expr_in_newline = true, type: TFmtBoolean.
SELECT productnumber, name, 'Price Range' = CASE WHEN listprice = 0 THEN 'Mfg item - not for resale' WHEN listprice < 50 THEN 'Under $50' WHEN listprice >= 50 AND listprice < 250 THEN 'Under $250' WHEN listprice >= 250 AND listprice < 1000 THEN 'Under $1000' ELSE 'Over $1000' END FROM production.product ORDER BY productnumber;