Обсуждение: Checking for valid UUID values?

Поиск
Список
Период
Сортировка

Checking for valid UUID values?

От
Wells Oliver
Дата:
Hi: we have a vendor who despite their best intentions will sometimes generate invalid UUIDs. I would like to ignore these records.

I am trying to insert their data into my table and with a programming language I'd use some sort of try/catch to try casting their UUIDs to actual UUIDs: does PSQL offer any kind way of doing this?

INSERT INTO mytable SELECT uuid FROM vendor WHERE ..... is_valid_uuid(uuid) IS NOT NULL? Or something?

Which would essentially try/catch casting to UUID and returning NULL if it's bad. At which point I send a politely worded letter to my vendor.

--

Re: Checking for valid UUID values?

От
Imre Samu
Дата:
Which would essentially try/catch casting to UUID and returning NULL if it's bad.

see:   uuid_or_null()     https://stackoverflow.com/a/46433640
 
Best,
  Imre

 

Re: Checking for valid UUID values?

От
Wells Oliver
Дата:
Bravo, thanks!

On Fri, Jul 24, 2020 at 10:20 AM Imre Samu <pella.samu@gmail.com> wrote:
Which would essentially try/catch casting to UUID and returning NULL if it's bad.

see:   uuid_or_null()     https://stackoverflow.com/a/46433640
 
Best,
  Imre

 


--