Common pl/SQL judgment statements and plsql statements
Statement 1: IF-THEN
IF condition THEN
Execution statement
End if;
Statement 2: IF-THEN-ELSE
IF condition THEN
Execution statement
ELSE
Execute other statements
End if;
Statement 3: IF-THEN-ELSIF
IF condition 1 THEN
Execute Statement 1
ELSIF condition 2 THEN
Execute Statement 2
ELSE
Execute other statements
End if;
The SQL judgment statement is queried by PL/SQL based on the field value to display the corresponding Chinese Characters
Run: select decode (STATUS, 0, 'invalid', 1, 'saved ', 2, 'submitted for approval', 3, 'approval not passed', 4, 'approved ', 5, 'terminated') from table where a = 'a203'
How does PL/SQL determine whether data exists in the database?
Can you describe clearly?
1. Whether to determine whether there is any value in the database. Is there any rule for the determination? For example,
A) define a variable using a simple value assignment method and use exception:
Select ___ into vvariable from table where ...... This sentence is assigned when there is a value, and when there is no data, add another
Exception
When NO_DATA_FOUND then
The statement you want to output
End;
B) The value is still assigned, but count is used.
Select count (*, or the column name you want) into vvariable
From table
Where ......;
If vvariable = 0 then
Statement 1;
Else
Statement 2;
End if;
----------------------------------
The above two methods may be used in the stored procedure, and the other method is to use only SQL statements, which requires you to describe your problem in more detail.