Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compare comma separated string from table in IF statement

user6314670Mar 11 2019 — edited Mar 11 2019

Hi All, I do have a table, which have comma separated string (e.g ‘2802,1680,2950,1987’) value. Would like to read this and compare into PL/SQL block using the IF condition.

create table test (parameter_name varchar2(30),value varchar2(200);

insert into test values ('FUL_DEL_CLNTS','2802,1680,2950,1987');

DECLARE 

l_clnt_id NUMBER := 2802; 

l_val    VARCHAR2(200);

BEGIN 

SELECT VALUE   INTO  l_val   FROM  test   WHERE  parameter_name = 'FUL_DEL_CLNTS'; 

dbms_output.put_line('Client value -' || l_val); 

IF l_clnt_id IN l_val --‘2802,1680,2950,1987’ 

THEN   

dbms_output.put_line('Value exists - ' || l_clnt_id);    

--some calculation 

ELSE   

dbms_output.put_line('Value do not exists - ' || l_clnt_id);   

--some calculation 

END IF;

END;

This post has been answered by Bala Narendra K CH on Mar 11 2019
Jump to Answer
Comments
Post Details
Added on Mar 11 2019
5 comments
1,007 views