1

I'm using DB2 version 10. I have a table with a timestamp for updates defined for me as follows in the Create Table statement :

Update_Timestamp             For Column D2TIMSTU Timestamp    DEFAULT  NULL

On initial load of the data to this table, I want to set the value of this column to NULL for all rows, but I have not been successful. I have tried specifying NULL as the insert value and I have even tried specifying DEFAULT.

Both attempts gave the same error :

SQL State: 42703 Vendor Code: -206 Message: [SQL0206] Column or global variable DEFAULT not found. Cause . . . . . . : DEFAULT was not found as a column of table *N in *N and was not found as a global variable in *N.

If the table is *N, DEFAULT is not a column of any table or view that can be reference

Same error for NULL - replacing NULL for DEFAULT in the error message.

I know I can get around this by just not specifying the column name and value, but I'd really like to know why this won't work.

4

1 回答 1

2

首先,您确定允许目标表中的 col3 接受 NULL 值吗?

如果是这样,请尝试这样的事情(我无法测试——我无法再访问 DB2 系统了)

INSERT INTO [Table Name](col1, col2, col3)SELECT Value1, Value2, 
    cast(NULL as timestamp) FROM [Source Table]
于 2013-09-05T14:21:11.680 回答