Re: libpq PQexecParams & value placeholders

From: Oleg <lego12239(at)yandex(dot)ru>
To: Dmitry Igrishin <dmitigr(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: libpq PQexecParams & value placeholders
Date: 2018-12-14 12:09:19
Message-ID: 20181214120919.GB4644@legohost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Dec 14, 2018 at 02:47:12PM +0300, Dmitry Igrishin wrote:
> пт, 14 дек. 2018 г. в 14:33, Oleg <lego12239(at)yandex(dot)ru>:
> >
> > Hi, all.
> >
> > Do we really need a numeric value placeholders like $1 in command string?
> It's a syntax defined at the backend side.
> (https://www.postgresql.org/docs/current/sql-prepare.html)

I know this, but i can't understand why this approach is used.

> > Construction of such string for complex non-static queries is very annoying.
> That's why there are libraries like Pgfe
> (https://github.com/dmitigr/pgfe) or libpqtypes

This is C++ :-(.

> (http://libpqtypes.esilo.com/)

This is great! PQexecf() is what i need. Why this api is not the part of libpq?
Thank you for the link!

> > Why do we can't simply use $$ placeholder, which take the next value from an
> > array of values?
> Because $$ means a dollar-quoted opening tag
> (https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING)

Ok. We can use any other placeholder string for such purpose. But not numeric
placeholders - these are not convenient.

--
Олег Неманов (Oleg Nemanov)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2018-12-14 18:28:59 loading jdbc Driver in servlet
Previous Message Dmitry Igrishin 2018-12-14 11:47:12 Re: libpq PQexecParams & value placeholders