WriteFile
Summary
The WriteFile
function allows developers to use an xSQL SELECT query or expression to create a CSV file on Connect’s SFTP file system.
Syntax
WriteFile(FilePath=<path to file>, Input=<XSQL SELECT or expression> [, FirstLineNames=< true | false >] [, Separator=<string>] [, Quote=<string>] [, Trim=< true | false >]) |
Parameters
Parameter | Description |
---|---|
FilePath | (Required) WriteFile will output query results to the SFTP directory path and file name specified. |
Input | (Required) The XSQL expression or SELECT statement to generate the result set. |
Append | (Optional) True appends the result set to the target file (if it exists). False overwrites the file or creates a new one. The default is false. |
FirstLineNames | (Optional) Specifies whether the column names from the result set should be written to the file as column headers on the first line. The default is true. |
Separator | (Optional) The character string delimiter that separates columns within the target file. The default is ‘,’ (comma). |
Quote | (Optional) The string that surrounds each data field. The default is blank (meaning that values are not quoted). |
Trim | (Optional) Specifies whether all values are to be trimmed of leading and trailing whitespace. Default is false. |
Return Type
In addition to creating the target CSV file, WriteFile
returns a status result set indicating success or failure of file creation.
Details
Connect is integrated with Xactly’s SFTP server, connectftp.xactlycorp.com. Connect’s file commands can read and write files and manipulate directory structures located on the SFTP file system. An SFTP account is not required to use these functions. However, one is required to access the file system via SFTP clients. Contact Xactly Customer Support to setup an SFTP account if your business does not already have one.
WriteFile will overwrite the target CSV file if it already exists on the SFTP file system. Customers may use an SFTP client to download the target CSV file from the Xactly SFTP server. Valid SFTP login credentials are required to transfer files via SFTP. Connect users do not need SFTP credentials to use Connect’s file functions on files located on the SFTP server.
Example
call WriteFile(FilePath='/extracts/payfile.csv', Input=(select period_name, sum(amount) from xactly.xc_payment), FirstLineNames=true, Separator='|', Quote='"', Append=true, Trim=true);
Related Functions