This must be a common mistake when using dynamic SQL.
Suppose, the value of insertStatement after SET statement.
If, the value of name was 'Warehouse',
insertStatement would be...
Code:
INSERT INTO <insertTable> (PID, PNAME, PVAL)
VALUES (100 , Warehouse, 100 )
(where
<insertTable> is the value of insertTable.)
So, you should include quotation marks around name, like...
SET insertStatement = 'INSERT INTO ' || insertTable
|| ' (PID, PNAME, PVAL)'
|| ' VALUES ('|| CHAR(100) || ',
''' || name || '
'', ' || CHAR(100) || ')';