Reputation: 13
I am having a syntax error on a psql query which is really strange, as my syntax seems right
INSERT INTO functionMonitoring (function, startDate, endDate, type, severity, status, text) values('test', 2019-07-16 17:04:53.866, 2019-07-16 17:04:53.866, 'process', 'INFORMATION', 'OK', 'Some random stuff');
This is my query, but typing it in my psql console gives this :
ERROR: syntax error at or near "17"
LINE 1: ...severity, status, text) values('test', 2019-07-16 17:04:53.8...
^
I don't understand why this happens. It is not a type problem as I already checked for each column's type and my table already holds similar data. Here is one exemple line already in my table
id | function | startdate | enddate | type | severity | status | text
----+----------------+------------------------------+------------------------------+---------+----------+--------+----------------------------------------
4 | DBReaderWindow | Tue Jul 16 16:15:41.144 2019 | Tue Jul 16 16:15:42.779 2019 | process | LOW | OK | Function fully executed with no errors
I hope I gave enough information to resolve the problem, thank you for your help !
Upvotes: 1
Views: 1332
Reputation: 246493
You are missing a single quote to start the string literal that contains your timestamp:
INSERT ... VALUES ('test', '2019-07-16 17:04:53.8', ...)
^ ^
Without them, PostgreSQL interprets 2019-07-16
as an arithmetic expression (equivalent to 1996) and does not expect the following 17
.
Upvotes: 1