0

I am trying to insert a blank into a timestamp field. In the table, it is defined as updt_ts timestamp NULL. But, I am still getting the below error:

ERROR:  invalid input syntax for type timestamp: ""
CONTEXT:  COPY dt_acct_stat_dim, line 1, column updt_ts: ""

Any fix for this error?

2
  • 1
    When you say "blank", do you mean NULL, or an empty string? Because for a field of type TIMESTAMP, the first should work (if the field is nullable), but the second won't. Are you running this query manually, or getting the input from somewhere (that might be sending empty string)? Commented Jul 25, 2018 at 14:21
  • Show us your insert statement. But try INSERT VALUES(id, NULL) instead of INSERT VALUES(id, '') Commented Jul 25, 2018 at 14:24

1 Answer 1

1

By your error message, you're using the copy command.

When using the copy command, one of the options available to you is to specify a null string:

copy
    table_name
from
    '/my/file.csv'
with (
    format csv,
    null ''
);

Full docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.