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

324
Visualizações
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 à 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