Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: UTL_FILE question - ALMOST DONE
I got the procedure to write files as I want it - Thanks Connor!, except that data for last month in the range selected isn't being written - file is empy.Here is the code:
CREATE OR REPLACE
PROCEDURE get_holidays_broken_monthly (
out_sql_code OUT NUMBER,
out_sql_error_message OUT VARCHAR2
)
IS
/* Local variables */
l_holidays holidays%ROWTYPE; l_monthly_date CHAR (6); l_filedir VARCHAR2 (100) DEFAULT '/usr01/oracle'; l_filename VARCHAR2 (100) DEFAULT 'holidays'; l_procedure_called VARCHAR2 (100); prev_mth number := -1; v_filehandle UTL_FILE.file_type;/* Cursor declarations: */
SELECT * FROM holidays where holiday_date >= '01/01/1999' and holiday_date <= '12/31/2004' ;BEGIN
All data is written to files, except Dec 2004, which is the last month data. What am I missing?
Thanks again!
Viktor <stant_98_at_yahoo.com> wrote:
Thanks Connor,
I'll give it a try. but i am still not quite sure how i can manipulate the file name so that for month1, filename is month2 -
Thanks again for your help!
Connor McDonald wrote:
declare
prev_mth number := -1;
begin
for i in my_big_24mth_cursor loop
if to_number(to_char(i.date_of_interest,'MM')) != prev_mth then
if utl_file.is_open(f) then
close file;
end if;
open file;
prev_mth := to_number(to_char(i.date_of_interest,'MM'));
end if;
write line to file
end loop;
end;
or thereabouts
hth
connor
Co-author: "Mastering Oracle PL/SQL - Practical Solutions" - available now web: http://www.oracledba.co.uk web: http://www.oaktable.net
"GIVE a man a fish and he will eat for a day. But TEACH him how to fish, and...he will sit in a boat and drink beer all day"
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Sun Feb 01 2004 - 13:35:20 CST
![]() |
![]() |