Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select to a File?
Message
From
14/07/1998 11:25:47
 
 
To
14/07/1998 11:09:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00117141
Message ID:
00117175
Views:
15
>>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
Map
View

Click here to load this message in the networking platform