I try to print something to a file. The file has header, body, footer and each of them has some function in it respectively. Is there a way I can separate it into each procedure then combine them as one procedure?
For instance, I made a procedure with open, write, close file process, and then I put the header procedure, body, footer procedure inside it,
Code idea demonstrates like below, but the error message said ORA-06550
and PLS-00222: no function with name 'header' exists in this scope
.
This is why I want to know if SQL could do this way?
procedure print_document is
-- Variables for writing data to file
v_file utl_file.file_type;
v_utlDir VARCHAR2(35) := get_dir('Directory','Dir');
v_utlFileName VARCHAR2(35);
Begin
--Open file and Write to file
SELECT test.dat' into v_utlfilename from dual;
v_file := utl_file.fopen(v_utlDir, v_utlFileName, 'W');
--print header, body, footer
utl_file.put_line(v_file,header); -- the header is a procedure
utl_file.put_line(v_file,body);
utl_file.put_line(v_file,footer);
utl_file.fclose(v_file);
--
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error in SQL. The error is');
DBMS_OUTPUT.PUT_LINE(SQLERRM);
End;
Ideally, if I call print_document
procedure then it will print all the lines to the cmd console.