Reputation: 4350
I have a rpg program that contains a routine that updates a db2 table.
I have declared a local var in the program
myvar
If <condition>
%nullind(myvar) = *on
it complains that the field is not capable of null.
I use this variable in an SQL update statement
UPDATE TABLE
SET X=:myvar
how can I set X to null?
Upvotes: 2
Views: 4018
Reputation: 41188
Internally defined fields are not null capable but you can use an externally described data structure to import the table definitions and enable nulls for database fields.
H ALWNULL(*USRCTL)
D TABLE E DS EXTNAME(TABLE) QUALIFIED
/FREE
if <condition>;
%nullind(table.x) = *on;
endif;
exec sql update table
set x = :table.x
where <condition>;
/END-FREE
Upvotes: 7