Question

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

Was it helpful?

Solution

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:

EXCEPTION
    -- Never do this in real code!!!
   WHEN OTHERS THEN NULL;
END;

OTHER TIPS

Did you get error? If the table doesn't have rows in it. You might get no_data_found exception.

By the way, where is your entire code?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top