File pointers

swakoo

Member²
Hi
I am passing around file pointers to functions. I cant find the proper declarations for pointers and addressing in PL/SQL.

function write_file(
p_file_name varchar2,
p_file_ext varchar2,
p_file_ptr utl_file.file_type,
p_write_line varchar2)
return boolean is
begin

v_error_msg := 'Error -- while writing to ' || p_file_name || '.' || p_file_ext;

if utl_file.is_open(p_file_ptr) then
utl_file.putf(v_file_ptr, '%s\n', p_write_line);
utl_file.fflush(p_file_ptr);
end if;
return true;
end;

Calling function -- >
if ( v_file_name, 'abc', v_file_ptr, v_abc )

The first file call gives the correct output but subsequent function call by other files give error. Can anyone please explain why? Thanks
 
Hi,
you need
not to work with Pointers like in C/C++;
The open-routine of utl_file gives you a handle (int value) to the file, every action on the file needs this handle.
The context is important too.

You need an environment to define the handle outside of the function:

DECLARE
-- here you declare our local vars like file handle
BEGIN

-- here you open the file
-- here you call the function with handle

-- and here you close the file

END;
/

Regards
Carl r.
 
Back
Top