For example table Foobars,
CREATE TABLE Foobars(
foo NUMBER,
bar NUMBER
);
How to insert a NULL value from a variable in dynamic PL/SQL procedure?
DECLARE
var_foo NUMBER := 69;
var_bar NUMBER := NULL;
l_insert_statement VARCHAR2(128);
BEGIN
-- Assembles insert statement
l_insert_statement :=
'INSERT INTO Foobars VALUES (' ||
var_foo || ', ' ||
var_bar ||
');';
-- Executes insert statement
EXECUTE immediate (l_insert_statement);
END;
/
The query returns ORA-00936 at the "EXECUTE immediate..." line: missing expression.