sql - Replace String in Oracle Procedure -
i have problem oracle procedure,since i'm new in sql language :d, here query
create or replace procedure mondesint.updatecoadescription descript mondes_mstr_chart_of_account.nama_akun%type; begin satu in (select no_akun, nama_akun mondes_mstr_chart_of_account no_akun '4-1-200-2-03-000%') loop select replace(nama_akun,substr(nama_akun,0,33),'utang-dana deposit-usd') descript mondes_mstr_chart_of_account no_akun = '4-1-200-2-03-0009'; update mondes_mstr_chart_of_account set nama_akun = descript no_akun = '4-1-200-2-03-0009'; end loop; end updatecoadescription;
in case, replace string in column on table. column name "nama_akun", replace nama_akun no_akun '4-1-200-2-03-000%'. in code above, try 1 record no_akun = '4-1-200-2-03-0009'.
select replace(nama_akun,substr(nama_akun,0,33),'utang-dana deposit-usd') mondes_mstr_chart_of_account no_akun = '4-1-200-2-03-0009';
...runs well, replace "dollar america" "usd", ie: "bla bla bla-dollar america-bla bla" change "bla bla bla-usd-bla bla"
note : character length before "dollar" equal records.
the problem is...
when execute procedure, result :"bla bla bla-usd" without on next of usd. expected result "bla bla bla-usd-bla bla"
any idea ?
i believe @apc has supplied correct solution. can test without changing data converting update statement select:
select nama_akun, replace(nama_akun, 'dollar america', 'usd') new_nama_akun mondes_mstr_chart_of_account instr(nama_akun, 'dollar america') > 0;
this show current value of nama_akun , how after being converted.
share , enjoy.
Comments
Post a Comment