We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey
I'm trying to figure out the syntax for having postgres functions in my prepared statements. Here's the SQL query:
PREPARE insert (int, timestamp, int, varchar) AS INSERT INTO hours (count, view_period, countable_id, countable_type) VALUES($1, $2, $3, $4); EXECUTE insert(1, date_trunc('hour',timestamp '2012-01-13T20:19:35.945Z'), '1234', 'foo'); // INSERT 0 1
As best as I can tell, the translation of that into node-postgres would be:
var insert = { name: "insert", text: "INSERT INTO hours (count, view_period, countable_id, countable_type) "+ "VALUES ($1,$2,$3,$4);", values: [1, "date_trunc('hour',timestamp '2012-01-13T20:19:35.945Z')", 1234, 'foo'] } client.query(insert, function(e,r){console.log(e)})
However, that returns the following error:
{ [error: invalid input syntax for type timestamp: "date_trunc('hour',timestamp '2012-01-13T20:19:35.945Z')"] length: 157, name: 'error', severity: 'ERROR', code: '22007', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, file: 'datetime.c', line: '3557', routine: 'DateTimeParseError' }
Any ideas what's going on?
The text was updated successfully, but these errors were encountered:
Maybe you can try this one:
var insert = { name: "insert", text: "INSERT INTO hours (count, view_period, countable_id, countable_type) VALUES ($1, date_trunc('hour', $2::timestamp), $3, $4);", values: [1, "2012-01-13T20:19:35.945Z", 1234, "foo"] };
Sorry, something went wrong.
This worked beautifully, thanks!
Remove timed-out checkouts from queue correctly (#86)
1871d0f
* Add failing test for correct removal from checkout queue on timeout * Remove timed-out checkouts from queue correctly Fixes #85.
No branches or pull requests
Hey
I'm trying to figure out the syntax for having postgres functions in my prepared statements. Here's the SQL query:
As best as I can tell, the translation of that into node-postgres would be:
However, that returns the following error:
Any ideas what's going on?
The text was updated successfully, but these errors were encountered: