Convert function from Oracle to MySQL
Hi,
I need to convert a function from Oracle to MySQL however it using a lot of Oracle specifics (I am familiar with SQL but this is a bit out of my expertise). Any one hints, tips to create the same functionality on MySQL? Here is the function:
create or replace type vartabletype as table of varchar2(4000);
/
create or replace function str2varlist(p_string in varchar2) return vartabletype is
v_str varchar2 default p_string || ',';
v_n varchar2(4000);
v_date vartabletype := vartabletype();
begin
loop
v_n := instr(v_str,',');
exit when (nvl(v_n,0) = 0);
v_date.extend;
v_date(v_date.count) := ltrim(rtrim(substr(v_str,1,v_n-1)));
v_str := substr(v_str,v_n+1);
end loop;
return(v_date);
end str2varlist;
/
Used in the sql statement as follows:
select A2.ID, A2.ADDRESS, A2.ADDRESS_TYPE, A2.DESCRIPTION, A1.type BWLIST_TYPE, A3.LIST_LEVEL, A3.SC_ID, A3.SP_PK, A3.APP_ID
from BWLIST A1, BWLISTXADDRESS A2, BWLISTXAPPLICATION A3, TABLE(STR2VARLIST(?)) A4
where A1.id = A2.BWLIST_ID and A2.BWLIST_ID = A3.BWLIST_ID and A2.ADDRESS = A4.COLUMN_VALUE and A3.SP_PK = ? and A3.APP_ID = ?
Thanks for your support!
Harald