I've two update statements launched by an "Execute Immediate" function. One works ok but the other throws an "SQL command not properly ended" error.
Statement working fine:
EXECUTE IMMEDIATE 'UPDATE myTable SET column_xpto = ' ||my_var|| ' WHERE myTable.name_table = '''||nameT||'''';
Statement NOT working:
EXECUTE IMMEDIATE 'UPDATE myTable SET column_X = ' ||my_other_var|| ' WHERE myTable.name_table = '''||nameT||'''';
The variable 'my_var' is a NUMBER type while the variable 'my_other_var' is a timestamp(6), initializated with CURRENT_TIMESTAMP.
desc myTable
Name Null Type
---------------- -------- -------------
NAME_TABLE NOT NULL VARCHAR2(200)
column_xpto NUMBER
column_X TIMESTAMP(6)
Does anyone know why the second statement gives an error?
... SET column_x = ''' ||my_other_var|| ''' ...worked for me.