I am writing the below queries in oracle:
DBMS_OUTPUT…..’Ashish’
Select col1 into val1 from tab_1
DBMS_OUTPUT…..’Ubale’
when I run this procedure I get the output as “Ashish” only why?
also what will be the value of v_val1 variable
Note: the table does not contain any records
Since the table is empty, the “select into” statement will raise the NO_DATA_FOUND exception. That’s why you don’t get the second message. val1 will have the same value as before the select – i.e. null if you didn’t previously assign a value.
The fact that you don’t know you got the NO_DATA_FOUND exception suggests that you have made one of the biggest errors PL/SQL developers ever make: