Re: Help with erasing a file
Date: Fri, 4 Dec 1998 15:44:21 -0600
Message-ID: <749l5u$jnp$1_at_supernews.com>
IGNORE PREVIOUS MESSAGE. I HAD NOT INITIALIZED the record number I was passing to zero which comes in as [recno]. I did that and it worked perfect.
Thanks anyway,
Ken.
Ken Halsted wrote in message <749jrf$3r3$1_at_supernews.com>...
>I am using TEXT_IO.PUT_LINE to add lines to a text file. I am opening the
>ascii file with a TEXT_IO.fopen('filename','w'); the first time and with an
>'a' every time after that. The idea is to delete the file on the first
>write and to append after that so that I don't have duplicate records. For
>some reason, this is NOT working. How can I get this to work. Any ideas
>welcome at all.
>
>The code is as follows:
>============================
>FUNCTION create_text_file (recno IN NUMBER, /* current record */
> filen IN VARCHAR2, /* filename */
> fname IN VARCHAR2, /* first name */
> lname IN VARCHAR2, /* last name */
> addr1 IN VARCHAR2, /* address line one */
> city IN VARCHAR2, /* city */
> st IN VARCHAR2, /* state */
> zip IN VARCHAR2) /* zip code */
> RETURN NUMBER
>IS
> out_file TEXT_IO.file_type;
>BEGIN
> IF recno = 0 THEN
> MESSAGE('RECORD NUMBER CAN''T BE ZERO');
> RETURN(1); /* FAILED */
> ELSE
> IF recno = 1 THEN
> out_file := TEXT_IO.Fopen(filen,'W');
> ELSE
> out_file := TEXT_IO.Fopen(filen,'A');
> END IF;
>
> TEXT_IO.Put_Line(out_file,chr(34)||fname||chr(34)||','||
> chr(34)||lname||chr(34)||','||
> chr(34)||addr1||chr(34)||','||
> chr(34)||city ||chr(34)||','||
> chr(34)||st ||chr(34)||','||
> chr(34)||zip ||chr(34));
>
> TEXT_IO.fclose(out_file);
> RETURN(0); /* OK */
>
> END IF;
>
>END;
>========================
>
>I'm a novice at this as you can tell but I was hoping for a workaround or
>something.
>
>Thanks,
>
>Ken.
>
>
Received on Fri Dec 04 1998 - 22:44:21 CET