Skip to content
Advertisement

translate query from Oracle to Postgres

I need to translate this query from Oracle to Postgres:

can someone help me?

thanks in advance for your attention and support

Advertisement

Answer

In postgres the operateur ~ performs a regex comparison as thus replaces the Oracle function regexp_like(). Your query therefore becomes.
I would like to alert your attention that the test not upper(location) ~ '^[0-9]{1,5}.* [a-z]' will always be true because the application of upper() makes it impossible to match [a-z].

7 rows affected
location | modelname | location
:------- | :-------- | :-------
12A      | CEDMI     | 74      
12A      | CEDRM     | 598     
12A      | CEDNA     | 768     
12AA     | CEDMI     | 74      
12AA     | CEDRM     | 598     
12AA     | CEDNA     | 768     
null     | null      | null    

db<>fiddle here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement