jhamm
jhamm

Reputation: 25032

How do I query for a specific uuid in postgres?

I am trying to query for a uuid in my Postgres db. Here is my table schema:

        Column        |      Type       |              Modifiers              
----------------------+-----------------+-------------------------------------
 casefile_id          | uuid            | not null default uuid_generate_v1()
 org_id               | uuid            | 
 casefile_template_id | uuid            | 
 casefile_status      | casefile_status | 

I try to query with

select * from casefile where casefile_id = 'e0da8698-32e6-11e7-a8de-985aeb8b64f';

And get the error:

ERROR: invalid input syntax for uuid: "e0da8698-32e6-11e7-a8de-985aeb8b64f"

I then look on SO and see this syntax:

select * from casefile where casefile_id = ANY('{e0da8698-32e6-11e7-a8de-985aeb8b64f}');

But still get the error:

ERROR: invalid input syntax for uuid: "e0da8698-32e6-11e7-a8de-985aeb8b64f"

What am I missing? How do I filter by UUID? Why can't I query as I would any other primary key?

Upvotes: 3

Views: 16949

Answers (1)

Marat Safin
Marat Safin

Reputation: 1909

You have wrong UUID - it misses one symbol in last symbols group

Upvotes: 14

Related Questions