SQL-ftpd ftp server for SQL Server data retreival

Implementation


The FTP server known as SQL-ftpd has been implemented using the Berkeley 5.60 version of a standard File Transfer Protocol server daemon and the File Transfer Protocol RFC (RFC859). Many of the commands have been disabled, for simplicity and their possible danger, but the protocol has been retained for compatibility with most clients. GUI clients however will likely fail at this type of implementation, due to their processing of input and output, and the sidestepping of the ftp protocol that is often done with GUI clients.

To use the SQL-ftpd server, your client must allow you to specify a port to connect with. Since this is not the standard ftp server, it is implemented using a TCP/IP socket, residing on port 9220. If your client insists on using the standard ftp port number, it will be of no use to you (such as Novell's RapidFiler).

There are a couple of other requirements your client must be able to handle as well, such as allowing you to "quote" the remote filename you wish to receive. Since you'll use the client's get command to receive the SQL statement results, the SQL statement will need to be placed within quotes, unless you are using a non- parameterized stored procedure. Stored procedures do not require quotes, unless you give them a parameter. Note that The IBM MVS ftp client differs in the types of quotes necessary. For more information on using the IBM MVS ftp client with quoted strings see Hints: IBM MVS Client differences with quoted strings.

Also, your client will need to allow you to specify a file name to store the returned data in. Typically most clients allow this, so that you can rename the file as you bring it over the network.

The SQL-ftpd server returns data much like BCP extracts data from a table (or view). Columns are tab-delimited, and are the same length as their definition on the SQL server. This should make it easy for the application programmer to parse the returned data, since it will be in a fixed format, with tabs (ascii 9, control-I) delimiting the columns. As long as you know the column length of the sybase table column you've selected from, your application program should have little difficulty in parsing the data. You can optionally choose to remove the tab-delimiters and send the data in fixed width columns. For information on removing the tab delimiters, see Hints: Retrieving data without tab delimiters.

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.

The ftp protocol command structure has been mapped into Transact SQL as best as possible. This means some small changes in what you're used to issuing as ftp commands. Generally most clients will support the basic requirements, however, you'll need to learn how to use the commands differently in order to use SQL-ftpd.

A synopsis of usage is:

The hostname maps to the host where the SQL server is running. This may change later, or additional port numbers may be added in the case of multiple servers running on a single host, however for now, the list is as follows: Additionally the following ports are available for testing the latest release of the software.

There is no test server available for the AppsDocs dataserver, nor are there any plans to ever create one. The high-availability, high-visibility nature of the AppsDocs cabinet and the imaging system precludes itself from any sort of test activity. If you must test against an imaging system dataserver, you will have to use DEMO instead.

The server commands supported are listed below. Note that these commands are what the client sends to the SQL-ftpd server, not commands you would issue to the client. A list of translations and commands which apply to most clients is provided along with the server commands, as well as a short description of their function.

  Server Command	Client Translation	Function
  ------------------------------------------------------------------
  USER			user			set the username
  PASS			<no translation>	set the password
  QUIT			quit			quit the connection
  PORT			<no translation>	establish a data connection
  PASV			passive			set passive mode
  TYPE			type			set file transfer type	*
  STRU			stru			set file transfer structure *
  MODE			mode			set file transfer mode *
  RETR			get			retrieve data ***
  CWD			cd			change (use) database
  LIST			dir			list available databases
  NLST			ls			list database objects
  SITE			site			set site params *
  SYST			system			set remote system type *
  STAT			status			show local client status
  STAT			rstatus			show remote server status **
  HELP			rhelp			show server help **
  NOOP			<no translation>	do nothing
  PWD			pwd			show current database

Notes:


SQL Server messages are passed back to the client using the STAT RFC code (211). Errors returned from the SQL server will appear to the client as illustrated below: Note that SQL server Print statements are not returned to the client.


Forward to the Examples Page
Return to the SQL-ftpd Contents