pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to pass a parameter in a query to postgreSQL 12
3+ messages / 3 participants
[nested] [flat]
* How to pass a parameter in a query to postgreSQL 12
@ 2021-06-09 19:51 Hassan Camacho Cadre <hccadre@gmail.com>
2021-06-10 17:00 ` Re: How to pass a parameter in a query to postgreSQL 12 Peter J. Holzer <hjp-pgsql@hjp.at>
2021-06-11 08:52 ` Re: How to pass a parameter in a query to postgreSQL 12 Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Hassan Camacho Cadre @ 2021-06-09 19:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hello
I recently installed a postgreSQL v12, in previous version 8.3 in all my
queries I pass parameters using the character :
SELECT
public.tabla.id
FROM
public.tabla
WHERE
public.tabla.id = :a
In the new version when I try to make this query it sends me an error
ERROR syntax error at or near ":"
I tried
?a , ¿a, @a
But I always got an error
I am executing this query on the query editor of pgadmin 4
Could someone help me to know how I can configure the parameter passing
character or, failing that, how I should pass the parameters in this new
version.
Greetings
--
Atentamente Msc. Hassan Camacho.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to pass a parameter in a query to postgreSQL 12
2021-06-09 19:51 How to pass a parameter in a query to postgreSQL 12 Hassan Camacho Cadre <hccadre@gmail.com>
@ 2021-06-10 17:00 ` Peter J. Holzer <hjp-pgsql@hjp.at>
1 sibling, 0 replies; 3+ messages in thread
From: Peter J. Holzer @ 2021-06-10 17:00 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2021-06-09 14:51:46 -0500, Hassan Camacho Cadre wrote:
> I recently installed a postgreSQL v12, in previous version 8.3 in all my
> queries I pass parameters using the character :
>
> SELECT
>
> public.tabla.id
>
> FROM
>
> public.tabla
>
> WHERE
>
> public.tabla.id = :a
That looks Oracle-ish to me.
> In the new version when I try to make this query it sends me an error
>
> ERROR syntax error at or near ":"
>
>
>
> I tried
>
>
>
> ?a , ¿a, @a
>
>
>
> But I always got an error
>
>
> I am executing this query on the query editor of pgadmin 4
I don't use pgAdmin4, and don't know how (and if) it handles
parameters.
Natively, PostgreSQL uses $1, $2, ... for parameters in prepared queries.
AFAIK pgAdmin4 is written in Python, so it is likely that it supports
the parameter binding of the Python PostgreSQL library in use (most
likely psycopg2). That would be %s for unnamed parameters and %(name)s
for named parameters.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to pass a parameter in a query to postgreSQL 12
2021-06-09 19:51 How to pass a parameter in a query to postgreSQL 12 Hassan Camacho Cadre <hccadre@gmail.com>
@ 2021-06-11 08:52 ` Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jehan-Guillaume de Rorthais @ 2021-06-11 08:52 UTC (permalink / raw)
To: Hassan Camacho Cadre <hccadre@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On Wed, 9 Jun 2021 14:51:46 -0500
Hassan Camacho Cadre <hccadre@gmail.com> wrote:
> Hello
>
>
> I recently installed a postgreSQL v12, in previous version 8.3 in all my
> queries I pass parameters using the character :
>
> SELECT
>
> public.tabla.id
>
> FROM
>
> public.tabla
>
> WHERE
>
> public.tabla.id = :a
>
> In the new version when I try to make this query it sends me an error
>
> ERROR syntax error at or near ":"
> [...]
> I am executing this query on the query editor of pgadmin 4
The :varname syntaxe is only understood by psql, which parse it and replace
it with the value BEFORE sending the query to postgres. pgAdmin doesn't know
this syntaxe.
If you need to parameterize a query in pure SQL, use PREPARE/EXECUTE.
Regards,
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-06-11 08:52 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 19:51 How to pass a parameter in a query to postgreSQL 12 Hassan Camacho Cadre <hccadre@gmail.com>
2021-06-10 17:00 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2021-06-11 08:52 ` Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
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