pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: PQexecParams, placeholders and variable lists of params
Date: Tue, 23 Nov 2021 12:37:15 +0100
Message-ID: <YZzSa7qRtgg/+oLL@tuxteam.de> (raw)

Hi,

PQexecParams expects a query string with "$1", "$2"... placeholders,
which refer to as many params in the param list. This keeps SQL
injection at bay.

Is there a way to express "variable length" lists? IOW, if I want to do
a query like

  "SELECT * FROM customers WHERE id IN ($1, $2) AND name like $3;"

is there a way to do that without knowing beforehand how many values go
into the IN list?

It would be very welcome for you to rub my nose against the place in The
Fine Manual where I could have found that :-)

Thanks & cheers
 - tomás

Attachments:

  signature.asc (application/pgp-signature, 194B) download

view thread (8+ messages)  latest in thread

Message-ID: <YZzSa7qRtgg/+oLL@tuxteam.de>
Permalink:  ../YZzSa7qRtgg%2F+oLL@tuxteam.de/
Also on:    postgresql.org/message-id/YZzSa7qRtgg/+oLL@tuxteam.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tomas@tuxteam.de
  Subject: Re: PQexecParams, placeholders and variable lists of params
  In-Reply-To: <YZzSa7qRtgg/+oLL@tuxteam.de>
  References: <YZzSa7qRtgg/+oLL@tuxteam.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox