Here's an example of a simple connection and it's responses:
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp)
User: <your-sybase-user-id> # remember, we're a front end to sybase
Password: <your-sybase-password> # so your sybase id is what you'll need here.
230 User <your-sybase-user-id> logged in. # and it tells you when you've logged in.
ftp> quit
221 Goodbye. # and says goodbye when you leave.
To specify a database (Use a database, in SQL parlance) you would use
the cd command, just as you were changing a directory in a remote file
system when using ftp. Here we also illustrate listing the available databases
on a given server that we've connected to. (See the note in
Concerning Novell's DOS based FTP client).
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp) User: <your-sybase-user-id> # remember, we're a front end to sybase Password: <your-sybase-password> # so your sybase id is what you'll need here. 230 User <your-sybase-user-id> logged in. # and it tells you when you've logged in. ftp> dir .... (list of databases is returned) ftp> cd model # equivalent to "use model".author's note: The dir function may not work with all clients.
Wouldn't you know it? You've used a database, and now you've forgotten
the name of the table you were going to select from. Here's an example
of how you can see all the objects within a database:
The ls command is actually mapped to an "sp_help" command. It returns
not only the name, but the type of the object, for greater clarification. Note
that some ftp clients insist on mapping the ls command so that it performs the
same function as a dir command. An example of how to get around this is
shown in Hints and Things to Keep In Mind
Second, the get statement looks strange. That's because it is. This is
the method of translating a remote filename into a Transact SQL statement.
The quotes around the SQL statement are required! Also note that the
statement needs to be as short as possible. Finally, you'll need to provide
a filename on your local host for the data to be stored in. Most systems
won't be able to create a file called select * from view_name, and
the client will likely tell you so, hence we've told the client to store the
data in a local file called xyz.txt.
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp)
User: <your-sybase-user-id> # remember, we're a front end to sybase
Password: <your-sybase-password> # so your sybase id is what you'll need here.
230 User <your-sybase-user-id> logged in. # and it tells you when you've logged in.
ftp> ls
.... (list of database objects is returned)
author's note: The ls function may not work with all clients.
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp)
User: <your-sybase-user-id> # we've been here before, haven't we?
Password: <your-sybase-password>
230 User <your-sybase-user-id> logged in.
ftp> ascii
ftp> get "select * from view_name" sql.txt
220 PORT command succesful. # ftp informational messages
150 Opening ASCII mode data connection for SQL results.
226 Transfer complete.
xxxxxx bytes received in x.yyyy seconds (...) # more information messages.
ftp> quit
There's a lot packed into that one simple example. First, we gave the
command ascii. When the sqlftp server returns it's results, it
may not be compatible with the client's method of terminating lines. To
prevent problems with this, the ascii mode is generally compatible with
most systems method of line-delimiters (cr/lf, or newline). If your system
can't deal with a cr/lf combination, use the keyword binary instead.
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp)
User: <your-sybase-user-id> # we've been here before, haven't we?
Password: <your-sybase-password>
230 User <your-sybase-user-id> logged in.
ftp> ascii
ftp> get "select * from vew_name" sql.txt
220 PORT command succesful. # ftp informational messages
211- SQL Server message: 208 # notice the SQL Server message portion.
Server: sybasedev # and more detail concerning the error.
Message: Invalid object name 'vew_name'. # oops. Misspelled the view name.
550 SQL Error # more detail.
211 End of SQL Server Messages. # and the closing detail line.
ftp> quit
If you intend to give the server a query which might take some time to complete,
you'll need to set the timeout parameter on the server. The default timeout is
currently only 5 minutes, and it will be easy to overrun that. To change the timeout
value for the server (before it assumes you're done and forgot to log out), the
command is idle <number-of-seconds>. For example:
ftp sybasedev.acs.ncsu.edu 9220 # connect to port 9220 on sybasedev (sqlftp)
User: <your-sybase-user-id>
Password: <your-sybase-password>
230 User <your-sybase-user-id> logged in.
ftp> idle # display the current timeout value.
200 Current IDLE time limit is 300 seconds; max 7200
ftp> idle 1800 # set the timeout to one-half hour.
200 Maximum IDLE time set to 7200 seconds
Using the OpenServer from within your query stored procedure is
possible but requires some non-standard workarounds. For more information
on this procedure see Hints: Using OpenServer
calls in your query stored procedure.