LuisFerchx
LuisFerchx

Reputation: 47

regexp_substr equivalent in postgresql

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.

Upvotes: 0

Views: 1041

Answers (1)

user330315
user330315

Reputation:

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','-'))

Upvotes: 2

Related Questions