I have a PL/SQL script where I load data from a stored procedure into bind variables. Then, I insert that data from the bind variables into an Oracle table with a simple insert statement.
The execution of the stored procedure and the insert are in a FOR-LOOP.
[code=oracle]
insert into ccd_t
(acct_id,
acct_seq_no,
acct_btn)
values
(to_number(v_ac ct_id),
to_number(v_acc t_seq_no),
substr(v_acct_b tn,1,10)
)
[/code]
After exiting the for-loop, I do a commit. Everything works great unless there is an exception. When an exception occurs (unless it is ORACLE not available) the rows get inserted, but the v_acct_btn is NULL.
There is a WHEN OTHERS for exception processing that prints out the error.
I am thinking the acct_id and acct_seq_no are inserting valid values because of the conversion function, to_number. Since substr is a character function, the v_acct_btn is not dynamic?
Does that make sense? Can anyone verify my conclusion?
The stored procedure always returns an acct_btn, not NULLs so it is not from the stored procedure. Acct_id and acct_seq_no always return numbers.
Or is there some other reason for this odd behavior?
field: acct_id number(10)
field acct_seq_no number(3)
field: acct_btn varchar2(10)
field: v_acct_id varchar2(10);
field: v_acct_seq_no varchar2(3);
field: v_acct_btn varchar2(20);
Thanks.
The execution of the stored procedure and the insert are in a FOR-LOOP.
[code=oracle]
insert into ccd_t
(acct_id,
acct_seq_no,
acct_btn)
values
(to_number(v_ac ct_id),
to_number(v_acc t_seq_no),
substr(v_acct_b tn,1,10)
)
[/code]
After exiting the for-loop, I do a commit. Everything works great unless there is an exception. When an exception occurs (unless it is ORACLE not available) the rows get inserted, but the v_acct_btn is NULL.
There is a WHEN OTHERS for exception processing that prints out the error.
I am thinking the acct_id and acct_seq_no are inserting valid values because of the conversion function, to_number. Since substr is a character function, the v_acct_btn is not dynamic?
Does that make sense? Can anyone verify my conclusion?
The stored procedure always returns an acct_btn, not NULLs so it is not from the stored procedure. Acct_id and acct_seq_no always return numbers.
Or is there some other reason for this odd behavior?
field: acct_id number(10)
field acct_seq_no number(3)
field: acct_btn varchar2(10)
field: v_acct_id varchar2(10);
field: v_acct_seq_no varchar2(3);
field: v_acct_btn varchar2(20);
Thanks.
Comment