Reputation: 93
I am trying to take info from my json field, which is created using c#, enter image description here
SELECT "Price"->>'TotalPrice' FROM "Table"
but I have error in postgres
ERROR: operator does not exist: text ->> unknown LINE 1: SELECT "Price"->>'Price' FROM "ReadModel"... No operator matches the given name and argument types. You might need to add explicit type casts.
Upvotes: 6
Views: 20975
Reputation:
The error message is pretty obvious: your column is defined as text
not as jsonb
or json
. But the ->>
operator only works with a jsonb
or json
column, so you will need to cast it:
SELECT "Price"::jsonb ->> 'TotalPrice'
FROM "ReadModel"."MyListingDto"
Unrelated to your problem, but: you should really avoid those dreaded quoted identifiers. They are much more trouble than they are worth it.
Upvotes: 12