Sybase 12.4.2 User Manual

Page 199

Advertising
background image

CHAPTER 5 Moving Data In and Out of Databases

179

If a backslash (\) precedes the characters

n

,

x

, or

\

it is considered an

escape character. For this reason, to indicate directory paths in Windows
NT systems, you must represent the backslash character by two
backslashes if the next character is any of those listed. (It is always safe to
double the backslashes.) Therefore, the statement to load data from the file
c:\newinput.dat into the

employee

table is:

LOAD TABLE employee

FROM ’c:\\newinput.dat’ ...

The pathname is relative to the database server, not to the client
application. If you are running the statement on a database server on some
other computer, the directory name refers to directories on the server
machine, not on the client machine. The input file for the load must be on
the server machine.

Named pipes

The file specification can be a named pipe. When you load from a named pipe
(or FIFO) on Windows NT, the program writing to the pipe must close the pipe
in a special way. The pipe writer must call FlushFileBuffers( ) and then
DisconnectNamedPipe( ). (If you do not, Adaptive Server IQ reports an
exception from hos_io::Read( ).) This issues a PIPE_NOT_CONNECTED
error, which notifies Adaptive Server IQ that the pipe was shut down in an
orderly manner rather than an uncontrolled disconnect. See Microsoft
documentation for details on these calls.

Specifying table-wide
format options

You can specify several options that describe the format of input data.

FORMAT option

You can specify a default format for table columns, which

applies if you omit the column-spec. The same formats that can appear in the
column-spec can appear here. If you also omit the

FORMAT

load option, the file

is assumed to be binary.

DELIMITED BY option

If you omit a column delimiter in the column-spec

definition, the default column delimiter character is a comma. You can specify
an alternative column delimiter by providing a string consisting of one to four
ASCII characters, or the hexadecimal representation for a character. The same
formatting requirements apply as to other SQL strings. In particular, to specify
tab-delimited values use the hexadecimal ASCII code of the tab character (9),
as follows:

...DELIMITED BY ’\x09’ ...

To use the newline character as a delimiter, you can specify either the special
combination '\n' or its ASCII value '\x0a'.

Advertising