SingleStore exception no_data_found

All we need is an easy explanation of the problem, so here it is.

I’m having difficulty finding the exception no_data_found in singlestore.

In Oracle, we use no_data_found exception.
Is there any alternative solution in singlestore for the no_data_found exception?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

If it is inside a stored procedure, you can use ER_INTO_VARIABLES_NO_ROWS. Example is below:

create table test(id int primary key, descr varchar(10));
insert into test values (1,'one'),(2,'two'),(3,'three');

delimiter $$
create or replace procedure test_sp(inp_id int)
returns void as
declare
      v_descr varchar(10);
begin
       begin
         select descr into v_descr from test where id = inp_id;      
         echo select v_descr;
         exception
           when ER_INTO_VARIABLES_NO_ROWS then 
                echo select 'No rows found';
        end;
end $$
delimiter ;

call test_sp(1); -- returns 'one'
call test_sp(100); -- returns 'No rows found'

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply