UTL_FILE output from PL/SQL package
GQSep 4 2003 — edited Sep 5 2003Hi,
Can any one tell me how I can generate a text file to see the variables of a package body. IS the following format correct where I have declared a file and then wrote a very simple statement. When I debug this package it generates an exception when it reached at
fileHandler := UTL_FILE.FOPEN('\users', 'myoutput', 'W');
I have initialised initDBNAME.ora file with utl_file_dir='Path to your directory' also. Any solution or correction in my code please.
PROCEDURE a1fdm_msql_admin_insert (
in_id IN NUMBER,
in_user IN VARCHAR2,
out_status OUT NUMBER
) IS
/* Declare criteria */
v_err_point VARCHAR2(10);
v_lIdAdmin NUMBER;
v_iStatus NUMBER;
v_sTimestamp DATE;
fileHandler UTL_FILE.FILE_TYPE;
/* Cursor to retrieve latest reading details. */
CURSOR c_get_admin_values IS
SELECT Status,
TO_DATE(Timestamp, 'DD:MM:YYYY HH24:MI:SS'),
id
FROM dbo_tbl_admin
WHERE id = v_lIdAdmin
AND status = 1;
BEGIN
v_lIdAdmin := in_id;
fileHandler := UTL_FILE.FOPEN('\users', 'myoutput', 'W');
UTL_FILE.PUTF(fileHandler, 'Look , I am writing to a file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT = "DD:MM:YYYY HH24:MI:SS" ';
OPEN c_get_admin_values;
FETCH c_get_admin_values INTO
v_iStatus,
v_sTimestamp,
v_lIdAdmin;
INSERT INTO dbo_tbl_admin@MSQL
VALUES
(v_iStatus,
v_sTimestamp,
v_lIdAdmin);
CLOSE c_get_admin_values;
v_err_point := '1';
out_status := 0;
EXCEPTION
WHEN OTHERS THEN
/*
Unexpected error, make up error text string and call error handler.
*/
DECLARE
v_err_stext t_error.err_stext%TYPE;
BEGIN
v_err_stext := 'p_a1fdm.a1fdm_msql_admin_insert point ' ||
v_err_point ||
' ORA' ||
to_char(SQLCODE);
p_error.log ( in_user, v_err_stext );
END; -- end nested block in when others exception handler
out_status := 99999;
END a1fdm_msql_admin_insert; -- procedure complete
Best regards,
Ghulam