WUC-14 And WUC-12 While Writing Many Lines by CLIENT_TEXT_IO
WUC-14 And WUC-12 While Writing Many Lines by CLIENT_TEXT_IO
Titleimage
Posted by Patrick Hamou on 2016:04:20 02:08:58
Applies to
Oracle Forms - Version 10.1.2 and later
Information in this document applies to any platform.
checked relevance 20-June-2007
Checked for relevance 16-Jul-2012
Symptoms
While writing more than approximately 10922 lines into a text file to the client machine using "CLIENT_TEXT_IO" package of webutil, it throws the following error in java console with no error in forms:
ERROR>WUC-14 [getFromObjectCache] Object Cache Error: Specified object handle -1 not found in the cache
ERROR>WUC-12 [FileFunctions.put()] Object Cache Error: Object is not the expected BufferedWriter type
If writing 10920 or lesser lines to the text file using CLIENT_TEXT_IO.PUT_LINE, it works fine and no errors in the java console or form.
If writing 10921 or 10922 lines to the text file using CLIENT_TEXT_IO.PUT_LINE, the form crashes with FRM-92101 error.
If writing more than 10922 lines to the text file using CLIENT_TEXT_IO.PUT_LINE, then the chunk(s) of 10923 lines is(are) overwritten by next set of lines and java console shows the above mentioned error but no error in the form.
Cause
There is already a bug logged on this issue. It is Bug:4726166 - Webutil : Cannot Output Many Lines Using Client_Text_Io.Put_Line .
It seems that "CLIENT_TEXT_IO" package of webutil is writing to the text file(on the client box) in chunks of approx 10920 lines. Thus if more than 10920 lines are written then these lines are overwritten by the next chunk of lines.
Solution
Use one of the following two workarounds :
- Write the required data into a text file on the Application Server machine using "TEXT_IO" package. Then transfer the text file to client machine using "WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT" function.
Or
- Add synchronize after every 10000 lines written to the text file on the client machine using "CLIENT_TEXT_IO" package.of webutil Please refer the following example code :
Note: Depending on the execution timing of your code and your environment, the frequency of the synchronize command may be more or less than mentioned here. In some case, it may need to be every 1000 lines or even more often. Since the synchronize command can impact performance, you should use it as infrequently as possible but as frequently as necessary.
declare
v_errmsg varchar2(300);
v_Val INTEGER;
v_Filename client_text_io.file_type;
i number := 0;
CURSOR cur_emp IS
select rpad(EMPNO,10,' ')|| rpad(ENAME,20,' ') || rpad(JOB,20,' ')|| rpad(MGR,20,' ') ||
rpad(to_char(HIREDATE,'dd-Mon-yyyy hh24:mi:ss'),25,' ') || rpad(to_char(SAL),10,' ')||
rpad(to_char(COMM),10,' ') || rpad(to_char(DEPTNO),10,' ') as emp_info
from emp
order by empno,mgr,deptno;
begin
v_filename := client_text_io.fopen('C:\all_emps.txt','W');
FOR v_cursor in cur_emp
LOOP
client_text_io.PUT_LINE(v_filename,v_cursor.emp_info);
-- the following 4 lines of code are added as a workaround to the above mentioned bug.
i := i + 1;
if mod(i,10000) = 0 then
synchronize;
end if;
END LOOP;
client_text_io.FCLOSE(V_FilePointer);
EXCEPTION
WHEN OTHERS THEN
client_text_io.FCLOSE(V_FilePointer);
v_errmsg := SQLERRM;
message('v_errormsg = '||v_errmsg);
END;
Posted by Patrick Hamou on 2016:04:20 02:08:58