Issue with UTL FILE use
832779Feb 9 2012 — edited Feb 9 2012Hi Guys
(5) Write a stored procedure that creates a comma separated flat file called ‘GradChallenge’ followed by today’s date formatted ‘yyyymmdd’ and add the extension ‘.txt’.
The file will contain the ID, LOGINNAME, FORENAME and SURNAME of the USERS table. The header will consist of today’s date in the format ‘yyyymmdd’ and the footer will contain a row count.
I just have a little error situated at the end of the code.
crreate or replace
PROCEDURE Grad_Five
IS
--
v_out_eate or replace
PROCEDURE Grad_Five
IS
--
v_out_file UTL_FILE.FILE_TYPE;
--
v_out_directory all_directories.directory_path%type;
v_out_filehandle UTL_FILE.FILE_TYPE := NULL;
v_out_buffer varchar2(32767);
v_header VARCHAR2(32759 BYTE);
r_users varchar2(32759 BYTE);
BEGIN
FOR r_users IN
( SELECT *
FROM users
WHERE directory_name IS NOT NULL
) LOOP
-- Output file
v_out_file := utl_file.fopen (r_users.directory_name, 'GradChallenge' || TRIM(TO_CHAR(SYSDATE,'YYYYMMDD')) || '.txt', 'W');
--
-- Header
v_header := sysdate;
utl_file.PUT_LINE(v_out_file,v_header,TRUE);
--
FOR r_users IN
( SELECT
USERS.ID,
USERS.LOGINNAME,
USERS.FORENAME,
USERS.SURNAME
FROM USERS
)
LOOP
BEGIN
--
UTL_FILE.PUT_LINE (v_out_file,
r_users.ID|| ',' || r_users.LOGINNAME|| ',' ||r_users.FORENAME|| ',' ||r_users.SURNAME);
--
END;
END LOOP;
FOR r_users in
( SELECT COUNT (ID) from Users )
LOOP
BEGIN
--
UTL_FILE.fclose (v_out_file);
END;
END LOOP;
COMMIT;
--
END Grad_Five;
Error(58,5): PLS-00103: Encountered the symbol "GRAD_FIVE" when expecting one of the following: loop
It is situated right at the end
I wonder if anyone can help me on this matter
Thanks :D