yes we can definitely do that but before that let us add debug/log messages to the function code as well to unerstand which line is giving the error.. Use the below code an perform the test again and give me the log message output what you are getting on the screen.
CREATE OR REPLACE PROCEDURE GEO_COUNT_DB_LONG_SIZE
is
cursor log_id_cursor is
select to_char(log_id) from logs
where sti_casetype in (
select sti_casetype
from ford_acs_casetypes
where transition_phase = 'DB'
);
local_log_id number;
/* long_desc_length number(20,0); */
long_desc_length number;
my_err varchar2(100);
begin
open log_id_cursor;
fetch log_id_cursor into local_log_id;
my_err :='after fetch';
while log_id_cursor%found
loop
my_err:='before function call to get length';
select find_length3(local_log_id) into long_desc_length from logs WHERE LOG_ID = local_log_id;
my_err:='after function call to get length';
insert into geo_field_count2 (case_no, field_size) values (local_log_id, long_desc_length);
my_err:='after insert to other table';
commit;
fetch log_id_cursor into local_log_id;
end loop;
exception when others then
dbms_output.put_line('i am in exception:'|| my_err);
dbms_output.put_line('error:'||sqlerrm);
dbms_output.put_line('error code:' || sqlcode);
end;
/
create or replace function Find_Length3 (geo_log_id number)
return number
is
x clob;
y long;
my_err varchar2(100);
begin
dbms_lob.createtemporary(x, false);
my_err:='FUNCTION:after createtemporary';
select long_desc into y from logs where log_id = geo_log_id;
my_err:='FUNCTION:after select';
x:= to_clob(y);
my_err:='FUNCTION:after to_clob';
return dbms_lob.getlength(x);
my_err:='FUNCTION:after getlength';
dbms_lob.freetemporary(x); --> note, this will not get executed as
-- this is after return statement.
exception
when others then
dbms_output.put_line('inside function exception:'|| my_err);
dbms_output.put_line('inside function error:'||sqlerrm);
dbms_output.put_line('inside function error code:' || sqlcode);
end;
/