I need to select into a local variable only if there exists data.
SELECT column1 INTO local_variable FROM table1 where column2 = <condition>;
Here if there is no data matching the condition I get a no data found error.
I need to select into the local variable only if there is some data matching the condition. Is there a simple query that will solve my problem.
Probably the best way is to handle no_data_found
Also, if you are selecting with primary key /unique key (that is column2 is unique) then there is a trick you can do