General information
Category:
Coding, syntax & commands
>>I am trying to extract data from a table to a flat file.
>>The one way that works is to SELECT .. INTO CUSOR x and
>>then COPY TO the contents of 'x'.
>>
>>I'd like to bypass the COPY TO and utilize the SELECT ...
>>TO FILE. However, when I do this even with NOCONSOLE and
>>PLAIN (to eliminate field titles) the output file contains
>>two blank lines at the top. Is there an easy way to remove
>>the two blank lines or should I simply use the COPY TO
>>method?
>
>You can always manipulate file using low-level functions:
>select .... to file c:\temp\test.txt noconsole plain
>nHandle=fopen('c:\temp\test.txt')
>=fseek(n,4) && skip first two lines
>set compatible on
>nSize=fsize('c:\temp\test1.txt')
>cString=fread(nHandle,nSize)
>=fclose(nHandle)
>nHandle=fcreate('c:\temp\test1.txt')
>=fwrite(nHandle,cString)
>=fclose(nHandle)
>modi file c:\temp\test1.txt
I think COPY TO is a lot easier to maintain and probably faster than
this approach. I was trying to eliminate the need to call a routine
twice - SELECT, COPY TO... I was hoping I could use one of the _P????
type system variables to eliminate the two blank lines...
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only