Yesterday I encountered a very depressing problem. I wrote an oracle function SQL statement as follows:
Code
1 Create Or Replace Function Calcs1 (LF Number )
2 Return Number As
3 S1 Number ;
4 K Number ;
5 Begin
6 Case
7 When Lf > 0.92 Then K: = 0 ;
8 When Lf > 0.75 And Lf <= 0.92 Then K: = ( 1.257407 - 2.44079 * Lf + 1.320967 * Lf * Lf );
9 When Lf <= 0.75 Then K: = 0.17 ;
10
Else K: =0; -- This was added later
11 End Case ;
12 S1: = ( 1 + K * ( 0.92 - Lf) / Lf );
13 -- Dbms_output.put_line ('lf = '| LF | 'K =' | K | 's1 = '| S1 );
14 Return S1;
15 Exception
16 When Invalid_number Then
17 Return 0 ;
18 End ;
After writing, the test passes, but such errors always occur during the call.
I haven't found any problem with case when after reading it for a long time. The problem lies in the column.
The answer http://www.error-code.org.uk/view.asp found here? E = ORACLE-ORA-06592
Case when requires else
I don't understand why the test result is also calculated after I successfully created it, that is, this error occurs during the call.
write it down to avoid making such a mistake in the future.