File translator

The file translator, known by the type name file, exposes stored procedures to leverage file resources. The translator is typically used with the TEXTTABLE or XMLTABLE functions to consume CSV or XML formatted data.

Table 1. Execution properties
Name Description Default


The encoding that should be used for CLOBs returned by the getTextFiles procedure. The value should match an encoding known to Teiid. For more information, see TO_CHARS and TO_BYTES in String functions.

The system default encoding.


Throw an exception in getFiles or getTextFiles if the specified file/directory does not exist.


For information about how to set properties, see the following example, and Override execution properties in Translators.
Example: Virtual datbase DDL override
CREATE SERVER "file-override"
        Encoding 'ISO-8859-1', "ExceptionIfFileNotFound" false

CREATE SCHEMA file SERVER "file-override";

VDB XML Override Example

<model name="file">
    <source name="file" translator-name="file-override" connection-jndi-name="java:/file"/>

<translator name="file-override" type="file">
    <property name="Encoding" value="ISO-8859-1"/>
    <property name="ExceptionIfFileNotFound" value="false"/>
getFiles(String pathAndPattern) returns
TABLE(file blob, filePath string, lastModified timestamp, created timestamp, size long)

Retrieve all files as BLOBs matching the given path and pattern.

call getFiles('path/*.ext')

If the path is a directory, then all files in the directory are returned. If the path matches a single file, the file is returned.

The * character is treated as a wildcard to match any number of characters in the path name. Zero or matching files will be returned.

If *’ is not used, and if the path doesn’t exist and `ExceptionIfFileNotFound is true, then an exception is raised.

getTextFiles(String pathAndPattern) returns
TABLE(file clob, filePath string, lastModified timestamp, created timestamp, size long)
The size reports the number of bytes.

Retrieve all files as CLOBs matching the given path and pattern.

call getTextFiles('path/*.ext')

Retrieves the same files getFiles, but with the difference that the results are CLOB values that use the encoding execution property as the character set.


Save the CLOB, BLOB, or XML value to given path

call saveFile('path', value)

Delete the file at the given path

call deleteFile('path')

The path should reference an existing file. If the file does not exist and ExceptionIfFileNotFound is true, then an exception will be thrown. An exception is also thrown if the file cannot be deleted.

JCA resource adapter

For configuration information, see File Data Source, the FTP Data Source, and the Administrator’s Guide in general.

Native queries
This feature is not applicable for the File translator.
Direct query procedure
This feature is not applicable for the File translator.

results matching ""

    No results matching ""