SQL Reference

Chapter 2 | Supported standards 16
Retrieving the contents of a container field: CAST() function and GetAs() function
You can retrieve binary data, file reference information, or data of a specific file type from a
container field.
If file data or JPEG binary data exists, the SELECT statement with GetAS(field name,
'JPEG') retrieves the data in binary form; otherwise, the SELECT statement with field name
returns NULL.
To retrieve file reference information from a container field, such as the file path to a file, picture,
or QuickTime movie, use the CAST() function with a SELECT statement. For example:
SELECT CAST(Company_Brochures AS VARCHAR) FROM Sales_Data
In this example, if you:
1 Inserted a file into the container field using FileMaker Pro but stored only a reference to the file,
the SELECT statement retrieves the file reference information as type SQL_VARCHAR.
1 Inserted the contents of a file into the container field using FileMaker Pro, the SELECT
statement retrieves the name of the file.
1 Imported a file into the container field from another application, the SELECT statement displays
'?' (the file displays as Untitled.dat in FileMaker
Pro).
To retrieve data from a container field, use the GetAs() function. You may use the DEFAULT
option or specify the file type. The DEFAULT option retrieves the master stream for the container
without the need to explicitly define the stream type:
SELECT GetAs(Company_Brochures, DEFAULT) FROM Sales_Data
To retrieve an individual stream type from a container, use the GetAs() function with the file’s
type based on how the data was inserted into the container field in FileMaker Pro. For example:
1 If the data was inserted using the Insert > File command, specify 'FILE' in the GetAs()
function. For example:
SELECT GetAs(Company_Brochures, 'FILE') FROM Sales_Data
1 If the data was inserted using the Insert > Sound command (Standard sound — MAC OS X
raw format), specify 'snd'
in the GetAs() function. For example:
SELECT GetAs(Company_Meeting, 'snd ') FROM Company_Newsletter