I am working on node.js and postgresql and I got an error :
error: syntax error at or near "s"
How can I solve it ?
I am working on node.js and postgresql and I got an error :
error: syntax error at or near "s"
How can I solve it ?
Did you paste this from somewhere? Check and replace your quote character, you're using an invalid character (e.g. ’
instead of '
) for quoting.
In the INSERT query, add the string values in quotes
const insertData = `
INSERT INTO authors (id, author_name, author_slug)
VALUES
('${authorID}', '${authorName}', '${authorSlug}');`; // added the quotes
I found the error. It's not the query but the error was my setup of pool.query. I just forget adding comma after the query and before the values. hehe stupid me before: pool.query(query[.. after: pool.query(query,[..
Aliasing the table you're inserting into was only added in Postgres 9.5 (compare Postgres 9.5's documentation to 9.4's documentation. Since the columns in the returning
clause refer to the inserted table anyway, you could just as easily do without it:
insert into "public"."mission_batches"
("micro_task_id", "is_active", "created_at", "updated_at")
values
('7e1cc9e8-fc11-409b-865e-3bf08e6ca924', false,
timestamp '2016-10-05 21:47:13.061', timestamp '2016-10-05 21:47:13.061')
returning
"id", "micro_task_id", "is_active", "created_at", "updated_at"