Home > Software engineering >  regexp_substr equivalent in postgresql
regexp_substr equivalent in postgresql

Time:12-15

I have this code in oracle PLSQL:

select * from con_transaccioncabecera c
where c.cab_estadocon in
(select regexp_substr('S-C-I-A','[^-] ',1,level) from dual
connect by regexp_substr('S-C-I-A','[^-] ',1,level) is not NULL)

I typed the string 'S-C-I-A', but actually, there would go a variable.

I need an equivalent in plpgsql.

CodePudding user response:

This is much easier in Postgres (no PL/pgSQL required)

select * 
from con_transaccioncabecera c
where c.cab_estadocon = any (string_to_array('S-C-I-A','-'))
  • Related