CASE Statements and expressions Flashcards

1
Q

The Oracle/PLSQL CASE statement has the functionality of an ____

A

IF-THEN-ELSE statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What types of datatypes can a case statement return?

A

Any type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can different cases in a case statement return different datatypes?

A

No, all results must be the same datatype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What will the case statment return if all of the conditions are false and there is no else clause?

A

NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 2 types of case statements?

A
  • Simple CASE statement

- Searched CASE statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a simple CASE statement do?

A

Evaluates a single expression

Compares the result with some values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the syntax for a simple CASE statement?

A
CASE selector
WHEN selector_value_1 THEN
    statements_1
WHEN selector_value_1 THEN 
    statement_2
...
ELSE
    else_statements
END CASE;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

PL/SQL will implicitly use if you do not provide an else clause?

A

ELSE

RAISE CASE_NOT_FOUND;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a searched CASE statement do?

A

Evaluates multiple Boolean expressions

Executes the sequence of statements associated with the first condition that evaluates to TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax for a searched CASE statement?

A
CASE
WHEN condition_1 THEN statements_1
WHEN condition_2 THEN statements_2
...
WHEN condition_n THEN statements_n
[ ELSE
  else_statements ]
END CASE;]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In a searched CASE statement what order are the conditions in the WHEN clauses evaluated?

A

Top to bottom

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In a searched CASE statement which condition fires if there are multiple WHEN clause whose condition evaluates to true?

A

The first one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a CASE expression?

A

A CASE expression evaluates a list of conditions and returns one of multiple possible result expressions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly