plsql - Assigning a string value to a variable of type NUMBER in pl/sql procedure not throwing any error -
i have started working on pl/sql recently. still not clear concepts. writing stored procedure has input values. using thses input values keys,i create cursor.
after iterate through cursor output , , call insert statement each row fetched. before calling insert, doing few data manipulations.
- splitting string '4564:0:75556' considering : delimiter. using substr , instr functions
my actual question starts here. output of substr string value. assigning value variable of type number declared in proc.
i expecting error while compiling proc or atleast when test it.
strangely didnt error, proc works fine.
is expected behaviour?
can assign string value variable of type number? in proc assignin output of substr variables d_c1_subscr_no, d_c1_account_no, d_c1_subscr_no_resets number
my stored proc:
create or replace procedure p4_update_bill_period_bulk(oldperiod in varchar, newperiod in varchar, accountno in varchar) d_c1_subscr_no number; d_c1_account_no number; d_c1_subscr_no_resets number; d_first_occ number; d_second_occ number; cursor c1_active_subs select ciem.external_id occ_ext_id, ciem.subscr_no fx_subscr_no, ciem.subscr_no_resets fx_subscr_no_resets customer_id_equip_map ciem, service s ciem.subscr_no = s.subscr_no , s.parent_account_no = to_number(accountno) , ciem.subscr_no_resets = s.subscr_no_resets , ciem.external_id_type = 6 , ciem.active_date < sysdate , (ciem.inactive_date null or ciem.inactive_date > sysdate); d_subscriber c1_active_subs%rowtype; begin open c1_active_subs; loop fetch c1_active_subs d_subscriber; exit when c1_active_subs%notfound; if c1_active_subs%found d_first_occ := instr(d_subscriber.occ_ext_id, ':', 1, 1); d_second_occ := instr(d_subscriber.occ_ext_id, ':', 1, 2); d_c1_subscr_no := substr(d_subscriber.occ_ext_id, 1, d_first_occ - 1); d_c1_subscr_no_resets := substr(d_subscriber.occ_ext_id, d_first_occ + 1, d_second_occ - d_first_occ - 1); d_c1_account_no := substr(d_subscriber.occ_ext_id, d_second_occ + 1); insert p4_bulk_data (batch_id, status, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) values (10300, 0, accountno, d_subscriber.fx_subscr_no, d_subscriber.fx_subscr_no_resets, d_c1_account_no, d_c1_subscr_no, d_c1_subscr_no_resets, oldperiod, newperiod); end if; end loop; close c1_active_subs; end;
oracle database conduct implicit conversions between many data types. clarified in link provided in comment, oracle implicitly converts varchar2 number , vise versa. said, not recommended approach rely on oracle implicit conversions. better use rich library of conversion functions provided oracle. example:
using concatenation operator (||) concatenate string , arithmetic expression can produce error, can prevent using to_char function convert arithmetic expression string before concatenation
relying on language settings in database format of date value can produce unexpected results, can prevent using to_char function , specifying format want
Comments
Post a Comment