Re: How to pass a parameter in a query to postgreSQL 12

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How to pass a parameter in a query to postgreSQL 12
Date: 2021-06-10 17:00:59
Message-ID: 20210610170059.GA18883@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2021-06-10 18:39:21 Re: Implicit table removal from logical replication publication
Previous Message Avi Weinberg 2021-06-10 16:33:37 Implicit table removal from logical replication publication