With a standard ftp session, you would issue a get command to transfer a file from the remote file system to the local file system. You can specify a filename for the remote file, or if you leave it blank it will use the filename from the remote file system. However, under SQL-ftpd, this command is being mapped to a SQL server database and hence requires a few operating changes. A synopsis of those changes is given below:
ftp> get "<sql-statement>" <local file name>This will execute <sql-statement> on the SQL server, and return the results into the file named <local-file> on your local system.
Different systems use different variations on this command. The IBM mainframe, for example, requires that you encapsulate your sql-statement inside of single quotes (') instead of double quotes ("). Other systems may have other differences.
An example of this command's usage is given below:
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> 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>In the preceeding example, the sql-statement select * from view_name is executed on the remote SQL server, returning the results into the local file sql.txt.
If you're query requires quoted information as part of the select statement, you simply reverse the option of single quotes versus double quotes. For example, if you encapsulate the sql-statement in double quotes, encapsulate your quoted data in single quotes, contained within the double quoted sql-statement.
Note that on some systems, you may have to allocate space for the local file or dataset, before issuing the get command.
If you wish to retrieve the data without delimiters, you may change this behaviour by using the site command to toggle the tabs delimiter. Your choices are to have tabs as delimiters or have no delimiters at all.
You should also consult the Data Output Format pages for information on how the result data will be formatted (according to the column type).