Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
Why is my psql insert statment not working?

I'm new to psql and Im trying to insert a new record but for some reason my date, reported, response, and helpfulness arent being registered. Which seemed to be the fields that Im inserting manually, can someone tell me whats going on? The error I get is syntax error at or near "SELECT"\n. But that select query works when I test it.

CREATE TABLE reviews (
    id SERIAL PRIMARY KEY,
    product_id INT,
    rating INT,
    date BIGINT,
    summary VARCHAR (500),
    body VARCHAR (500),
    recommend BOOLEAN,
    reported BOOLEAN,
    reviewer_name VARCHAR (50),
    reviewer_email VARCHAR (50),
    response VARCHAR (500),
    helpfulness INT DEFAULT 0
);

app.post('/reviews', async (req, res) => {
  const {
    product_id,
    rating,
    summary,
    body,
    recommend,
    name: reviewer_name,
    email: reviewer_email,
    photos,
    characteristics,
  } = req.body;

  const reviewQueryStr = `INSERT INTO reviews (product_id, rating,
    date, summary, body, recommend, reported, reviewer_name, reviewer_email, response, helpfulness) VALUES (${product_id}, ${rating}, SELECT (ROUND(extract(epoch from current_timestamp))), ${summary}, ${body}, ${recommend}, false, ${reviewer_name}, ${reviewer_email}, null, 0);`;

  try {
    await pool.query(reviewQueryStr);
    console.log('Review added');
    res.sendStatus(201);
  } catch (err) {
    console.error(err);
  }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!