Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda