Below is my sql query and I am getting error while executing it as ORA-01427: single-row subquery returns more than one row.
Please help with a work around:
SELECT *
FROM TableName err
WHERE ERR.SYSCD IN
(decode(REGEXP_COUNT('TEST1,TEST2', ','), 0, 'TEST3',
(SELECT DISTINCT syscd
FROM TableName
WHERE syscd IN
(SELECT err.syscd
FROM TableName ERR
WHERE ERR.SYSCD NOT IN
(SELECT UPPER(
REGEXP_SUBSTR(
'TEST1',
'[^,]+',
1,
LEVEL))
CNTRY_CD
FROM DUAL
CONNECT BY REGEXP_SUBSTR(
'TEST1',
'[^,]+',
1,
LEVEL)
IS NOT NULL)
)
OR syscd IS NULL)))
SELECT DISTINCT syscd
subquery is the culprit, since it's the only one I see in which you need a single row result. To help you fix it you'd need to explain what you want it to do. – Deltharis