oracle - Compare two delimited strings and return corresponding value in PL SQL -
i have 2 columns hashtag delimited value, i.e. email#web#telephone#sms#mms
& 0#0#0#1#0
note each delimited value of second column matches corresponding delimited value in first column, i.e. email = 0
, web = 0
, telephone = 0
, sms = 1
etc. based on parameter, want return matching value of second column. i.e. incoming param = web#telephone#sms
, value want return 0#0#1
.
this need done in pl sql, , have no clue start, explains lack of sample code.
any please?
there couple of useful utility functions in oracle package called apex_util. (this package concerns oracle application express aka apex, can used anywhere). are:
- apex_util.string_to_table
- apex_util.table_to_string
using string_to_table
can convert delimited string table of values:
declare v_table apex_application_global.vc_arr2; -- table type apex_util uses begin v_table := apex_util.table_to_string ('email#web#telephone#sms#mms', '#'); end;
you have array 5 elements ('email', 'web', 'telephone', 'sms', 'mms');
you can same values string table elements ('0', '0', '0', '1', 0'). , can same parameter table elements ('web', 'telephone', 'sms').
you can use pl/sql logic build new array elements values need return, i.e. ('0', '0', '1'). have left part you!
finally can turn delimited string:
return apex_util.table_to_string (v_return_table, '#');
Comments
Post a Comment