the compiler swears at a site in a function, how to execute a subquery while saving the result to a variable in the else section?

if Cnt > 0 Then tmpVal:='ZERO'; else select myVal into tmpVal from mytable where rownum =1; end if; 

Closed due to the fact that off-topic participants Mike , default locale , andreymal ,, mymedia 11 Oct '17 at 20:00 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Mike, default locale, andreymal,, mymedia
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • How exactly do you curse the compiler? - Viktorov
  • Error: PL / SQL: ORA-00933: SQL command not properly ended Line: 44 Text: END IF; - Paul
  • found an error after your comment, forgot; after the end select in its code - Paul
  • @Paul What is Cnt? I wrote a comment there under the answer, because that decision is not always applicable. If your problem was generally only a semicolon, I would leave everything as is. And the question was deleted, because it was caused by a typo. - Mike
  • @Mike Cnt is a variable that stores the number of records obtained from another query. The system does not allow removing a question from a typo. - Paul

1 answer 1

 SELECT CASE WHEN Cnt > 0 THEN 'ZERO' ELSE myVal END INTO tmpVal FROM mytable WHERE rownum =1;