The problem in this case is not related to the fact that v.ra
be or not NULL
, is only a syntax error.
Most likely the error message you received is as follows:
ORA-06550: line 3, column 1: PLS-00221: 'RA' is not a Procedure or is
Undefined ORA-06550: line 3, column 1: PL/SQL: Statement Ignored
Often the error messages are not very clear on the reason of the error, but in this case the reason seems to be clear: v.ra;
is not a procedure or code block that can be executed.
I didn’t quite understand your purpose with that instruction, but the variable v
has a type that depends on the table structure teste
, wherefore v.ra
should probably be a NUMBER, CHAR, BLOB, DATE or other type commonly used to define a column of a table. It will therefore not be possible to "execute" the expression v.ra;
When you changed the instruction to v.ra := 0
passed or compiler an instruction he understands. In this case, it is an assignment. Hence your code has run without error.
To show that the problem had nothing to do with NULL, see the following anonymous block, with no assignment, working on SQL Fiddle.
declare v teste%rowtype;
begin
select ra into v.ra from teste where nome = 'Danilo';
dbms_output.put_line(v.ra);
end
;
/