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

326
Vistas
Shorter way to INSERT multiple variables into Postgres/SQL?

Picking up SQL and Postgres, is there a shorter way to write the INSERT SQL query than the code below?

Not a problem writing it this way but it's very long and requires lots of scrolling. I could write it as a paragraph with no linebreak after the commas but then it's hard to keep track of which variable/column/value goes with what in VSCODE.

Maybe there's a way to shorten the values variables such as writing something like $1-$39?

 const addItemSql = `
            INSERT INTO users (
                address,
                city,
                state,
                postal,
                description,
                bedrooms,
                bathrooms,
                sqft,
                lotSize,
                .....(20 more items) 
            ) VALUES (
                $1,
                $2,
                $3,
                $4,
                $5,
                $6,
                $7,
                $8,
                $9,
                $10,
                $11,
                $12,
                $13,
                $14,
                $15,
                $16,
                $17,
                $18,
                $19,
                $20,
                $21,
                $22,
                $23,
                $24,
                $25,
                $26,
                $27,
                $28,
                $29,
                $30,
                $31,
                $32,
                $33,
                $34,
                $35,
                $36,
                $37,
                $38,
                $39,
            ) RETURNING *`
    const { rows: addedItem } = await pool.query(addItemSql, [
        address,
            city,
            state,
            postal,
            description,
            bedrooms,
            bathrooms,
            sqft,
            lotSize,
            .....(20 more items) 
    ])
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