Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda