0

I use variable in psql like: \set user_id 10;

When i want use this variable in query like select * from users where user_id = :user_id; - it's ok

But when i use this for ltree column i have a problem select * from accounts where customer_id <@ :user_id?

Can you help me?

Аушев
  • 35
  • 3

1 Answers1

1

You need a string literal, so you have to quote the value:

select * from accounts where customer_id <@ :'user_id';

That will become

select * from accounts where customer_id <@ '10';
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263