Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IS NOT NULL behavior

Status
Not open for further replies.

OraMs

Programmer
Feb 12, 2000
40
US

Thanks in advance for your time.

I declared a variable as ROWTYPE for a given table:

v_rec table%ROWTYPE;

An error occurs with the following statement:

IF v_rec IS NOT NULL
THEN
<<some logic>>
END IF;

If I use a column from the table, script executes w/o problems:

IF v_rec.acolumn IS NOT NULL
THEN
<<some logic>>
END IF;
 
Perhaps someone with more experience writing PL/SQL can give you a better answer, but the behavior you describe seems normal to me. Null or not null is a property of a column, not of a row. Therefore the &quot;vrec.acolumn IS NOT NULL&quot; logic works, but the &quot;vrec IS NOT NULL&quot; doesn't.

What condition are you trying to test with &quot;vrec IS NOT NULL&quot;? If you want at least one column of vrec to be not null you will probably have to write code such as

( vrec.acolumn is not null
or vrec.bcolumn is not null
or ...
or vrec.zcolumn is not null)
 
That is correct, karluk.
And, OraMS, if you just want to know whether something
was selected, you can use the <cursor>%FOUND or
<cursor>%ROWCOUNT attributes. Jim

oracle, vb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top