PL/SQL check if query returns empty

前端 未结 4 1735
闹比i
闹比i 2021-01-03 19:58

I\'m writing a procedure, and i need to check whether my select query returned an empty record or not. (In this example whether there is no x,y shelf)

How can i do t

4条回答
  •  失恋的感觉
    2021-01-03 20:38

    Use an exception handler

    Begin
      select column
      into variable
      from table
      where ...;
    
      -- Do something with your variable
    
    exception
     when no_data_found then
        -- Your query returned no rows --
    
     when too_many_rows
        -- Your query returned more than 1 row --
    
    end;
    

提交回复
热议问题