Oracle case when error: Case not found when Ora-06592 case statement

Source: Internet
Author: User

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.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.