Beruflich Dokumente
Kultur Dokumente
2004-2009 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker, the file folder logo, Bento and the Bento logo are either trademarks or registered trademarks of FileMaker, Inc. in the U.S. and other countries. Mac and the Mac logo are the property of Apple Inc. registered in the U.S. and other countries. All other trademarks are the property of their respective owners. FileMaker documentation is copyrighted. You are not authorized to make additional copies or distribute this documentation without written permission from FileMaker. You may use this documentation solely with a valid licensed copy of FileMaker software. All persons, companies, email addresses, and URLs listed in the examples are purely fictitious and any resemblance to existing persons, companies, email addresses or URLs is purely coincidental. Credits are listed in the Acknowledgements documents provided with this software. Mention of third-party products and URLs are for informational purposes only and constitutes neither an endorsement nor a recommendation. FileMaker, Inc. assumes no responsibility with regard to the performance of these products. For more information, visit our website at www.filemaker.com. Edition: 01
Contents
Chapter 1 Introduction
About this guide Using a FileMaker database as a data source Accessing a hosted FileMaker Pro database Limitations with third-party tools Networking requirements Updating files from previous versions Installing current drivers 7 7 8 8 8 9 9
Using the JDBC client driver About the JDBC client driver Using a JDBC URL to connect to your database Specifying driver properties in the URL subname Verifying access via JDBC
21 21 22 24 25
| Contents
Chapter 6 Mapping FileMaker fields to ODBC data types Chapter 7 Mapping FileMaker fields to JDBC data types Chapter 8 ODBC and JDBC error messages
ODBC error messages ODBC driver error messages ODBC Driver Manager error messages SequeLink Client error messages SequeLink Server error messages Data source error messages JDBC error messages JDBC driver error messages SequeLink Server error messages Data source error messages 51 51 51 51 52 52 52 52 52 53 55
Index
Chapter 1 Introduction
This guide explains concepts and details to help you share FileMaker data with other applications using ODBC (Open Database Connectivity) and JDBC (Java Database Connectivity). This guide also documents how the ODBC and JDBC client drivers, when used with FileMaker Pro and FileMaker Server Advanced, support the industry standards for ODBC, JDBC, and SQL (Structured Query Language). You can use FileMaker Pro, FileMaker Pro Advanced, or FileMaker Server Advanced to create and test your database solution. You can then share your FileMaker database solution as a data source with ODBC- and JDBC-compliant applications. You must install the FileMaker ODBC and JDBC drivers on the machine where your third-party application is installed. Important This guide describes using FileMaker software as a data source. For step-by-step information on using FileMaker Pro as an ODBC client application, see FileMaker Pro Help. The following table gives an overview of how to use ODBC and JDBC with FileMaker software.
What do you want to do? Use FileMaker Pro as a data source/share FileMaker Pro data Use FileMaker Pro as an ODBC client/access ODBC data How do you do it? 1. SQL queries 2. ODBC and JDBC See This guide
1. Interactively via the relationships graph FileMaker Pro Help 2. One-time, static via ODBC import or File menu > Open. Also, the Import Records script step and the Execute SQL script step
1 This guide assumes that you are familiar with the basics of using ODBC and JDBC, and constructing
SQL queries. Refer to a third-party book for more information on these topics.
1 This guide uses FileMaker Pro to refer to both FileMaker Pro and FileMaker Pro Advanced, unless
describing specific FileMaker Pro Advanced features. Note You can download PDFs of FileMaker documentation from www.filemaker.com/documentation. Any updates to this document are also available from the website.
SQL is passed through the ODBC and JDBC interfaces to the FileMaker host of the data source, performing queries such as SELECT first_name, last_name FROM customers WHERE city='Paris' and making updates such as the creation of a new record with INSERT INTO customers (first_name, last_name) VALUES ('Jane','Smith').
Up to 50 connections and supports local access (same computer) and remote access (both for middleware such as web servers, and for remote client access from desktop productivity applications). Up to nine connections and supports local access (same computer) only.
FileMaker Pro
The ODBC and JDBC plug-in components you need for sharing your data with other applications is installed with FileMaker Server Advanced and FileMaker Pro. To access a hosted FileMaker database file, you need to install the corresponding ODBC or JDBC client driver. Install the client driver on the machine on which the third-party application is installed. See chapter 2, Installing FileMaker ODBC and JDBC client drivers for information on installing the driver files needed for accessing a FileMaker data source. If your FileMaker database solution uses more than one FileMaker database file, all of the database files must be on the same computer. Chapter 5, Supported standards, describes the SQL statements that the ODBC and JDBC client drivers support when used with FileMaker Pro and FileMaker Server Advanced. Important If you disable ODBC/JDBC sharing after it's already been on, a data source hosted by FileMaker Server Advanced or FileMaker Pro immediately becomes unavailable. The database administrator doesnt have the capability to alert ODBC and JDBC client applications about the data sources availability (the administrator can communicate only with FileMaker database file clients). No errors are reported, and the client application should notify users that the data source is not available and transactions cannot be completed. If a client application attempts to connect to an unavailable FileMaker database file, a message explains that the connection failed.
1 Microsoft Access: In a FileMaker data source, you cannot access table or column names that use High
ASCII or double-byte characters.
Networking requirements
You need a TCP/IP network when using FileMaker Server Advanced to host a FileMaker database file as a data source over a network. FileMaker Pro supports local access (same computer) only.
Chapter 1
Introduction
10
12
To find which version of Java youre running, open a command window (Windows) or Terminal window (Mac OS) and type java -version.
Networking requirements
If youll be accessing a FileMaker data source hosted on another computer, youll need network access via TCP/IP.
Chapter 2
13
Note If you logged in using an account that has administrator privileges, then no changes to permissions are necessary after you create the /ODBC folder. The ODBC folder must have the following permissions:
1 Owned by root, admin group 1 Read/Write/Execute permissions for root and admin 1 Read/Execute permissions for other accounts
This client driver has been tested with ODBC Administrator 1.0.2 (available with Mac OS 10.4.11) and ODBC Administrator 1.1 (available with Mac OS 10.5.4). Important Use the ODBC Administrator bundled with the ODBC driver manager software recommended for your client application.
14
2. Click Next. Review the license agreement. 3. If the license agreement is acceptable, select I accept the terms of the license agreement, then click Next. A window of installation options appears. 4. Select Install Developers Tools. The tools include JDBCTest, which helps you verify your JDBC connections. 5. Enter an Install Directory.
1 Windows: Enter a path that includes your Java executable file (java.exe). 1 Mac OS: Enter /Library/Java/Extensions (or another location included in the ClassPath of your Java
application). 6. Click Next. 7. Confirm your installation selections, then click Install. 8. When the installation is complete, click Finish. The JDBC client driver is now available for you to configure for accessing a FileMaker data source.
1 Windows: The FileMaker ODBC client driver is DataDirect 32-BIT SequeLink 5.5. 1 Mac OS: The FileMaker ODBC client driver is ivslk20.dylib.
Note You can also use FileMaker Pro as a client application, interacting with records from another data source via ODBC using SQL. See FileMaker Pro Help for details about accessing an external data source via ODBC.
About ODBC
ODBC is an API that enables applications to access data from many database management systems. ODBC gives client applications a common language for interacting with data sources and database services. All applications that support ODBC recognize a common subset of statements. SQL lets you use other applications (like spreadsheets, word processors, and reporting tools) to view, analyze, and modify FileMaker data. See chapter 5, Supported standards, for the SQL statements, functions, and expressions that the ODBC client driver supports. Your application can talk directly to a FileMaker database file by using the ODBC client driver. Your SQL statements are delivered to the FileMaker host of the database file and the results of those statements are sent back to you. If you use FileMaker Server Advanced to host a FileMaker database file as a data source, the database file can be located on another machine (the server machine) connected to the network, while your client application is located on your machine (the client machine). This is referred to as a client/server configuration.
Client Application
Driver Manager
Oracle
FileMaker
16
1 1 1 1
perform mail merges with Microsoft Word create charts with Microsoft Excel move FileMaker data to a DBMS like Microsoft SQL Server further analyze your FileMaker data with query or reporting tools to create charts, construct ad-hoc queries, and perform drill-down analysis
1 create a Microsoft Visual Basic application that shares information with FileMaker Pro
To share a FileMaker database file as a data source, use FileMaker Pro to define accounts that need access to the database file. Then, control access to the database file by assigning privilege sets to the accounts, including the extended privilege of access via ODBC/JDBC. Finally, enable the FileMaker Server Advanced or FileMaker Pro host application to share data via ODBC/JDBC. For details, see FileMaker Pro or FileMaker Server Help. Important The ODBC client driver replaces the FileMaker Pro ODBC driver released with a previous version of FileMaker. If you have previously set up access to a FileMaker data source using the older driver, youll need to re-define access by using and configuring the new driver. Note To confirm that the SequeLink Server is currently running, you can use the Activity Monitor on Mac OS or the Task Manager on Windows to check the status of the ddfmsoc process. When the process is started, it is named FMSocket_SL55, and events are logged by that name. The SequeLink Server process is separate from the FileMaker Server process.
Chapter 3
17
5. Construct and execute an SQL query in the client application. Each FileMaker database file that is open and set up for access is a separate data source (you create a DSN for each FileMaker database file you want to access as a data source). Each database can have one or more tables. FileMaker fields are represented as columns. The complete field name, including any non-alphanumeric characters, displays as the column name. Note In Windows, Microsoft Access can import only 32 or fewer fields at one time via ODBC from a FileMaker database file. If your database file has more than 32 fields, import them in increments of 32.
18
6. For Data Source Name, type a name that will be meaningful to others accessing the FileMaker data source. An additional Description is optional. Be sure Use LDAP is cleared. No translator .DLLs are included with the ODBC client driver (so clicking Translate will not allow you to configure an ODBC translator). 7. For SequeLink Server Host, enter the location of your data source. If youre connecting to a FileMaker database file hosted by FileMaker Pro on your local machine, type localhost (or 127.0.0.1). If youre connecting to a FileMaker database file hosted by FileMaker Server Advanced over a network, type the IP address of FileMaker Server. 8. For SequeLink Server Port, type 2399. Important When configuring a FileMaker data source, you must specify 2399 as the SequeLink Server Port. 9. For Server Data Source, type the filename of the FileMaker database file youre using as a data source (dont type the filename extension). 10. If youve enabled sharing via ODBC/JDBC in the host application, click the button to the right of Server Data Source to display the filenames of currently open FileMaker database files for you to choose from. If your database name contains spaces, replace them with the escape characters %20. For example, MY%20DATABASE. 11. Click OK to save your data source information. If youre sharing another FileMaker database file, return to step 3 and set up the database file as a data source. 12. Click OK to close the ODBC Data Source Administrator dialog box.
Chapter 3
19
5. Click Test Connect. You are prompted to enter your FileMaker account name (in Database User Name) and password (in Database Password). If the connection is OK, youll receive the message Connection test was successful. If the connection fails:
1 Make sure the FileMaker database file is hosted and available. 1 Update or correct your connection information. 1 Make sure your FileMaker account uses a privilege set with the extended privilege of Access via ODBC/
JDBC.
1 Verify that the FileMaker Pro or FileMaker Server host application has been set up for sharing via
ODBC/JDBC.
The ODBC Administrator also allows you to optionally define keywords and a Setup File path, but the client driver does not need that information.
Specifying ODBC client driver properties for a FileMaker DSN (Mac OS)
Create a DSN for each FileMaker database file you want to access as a data source. The DSN identifies the FileMaker ODBC client driver, the location of the FileMaker host application, and the FileMaker database file youre accessing as a data source. Important The ODBC client driver for Mac OS does not support upper-ASCII, double-byte, or Japanese characters in database names or table names. If your FileMaker database file uses these characters, create a second database and use only ASCII characters for the filename and table names. In the second database, create a data source reference that points to the data in your original database file. Share both files with ODBC/JDBC, but use the second database file when defining the DSN.
20
Additionally, youll need to specify these keyword values for the DSN:
Keyword Host Value If youre connecting to a FileMaker database file hosted by FileMaker Pro on your local machine, type localhost (or 127.0.0.1). If youre connecting to a FileMaker database file hosted by FileMaker Server Advanced over a network, type the IP address or hostname of FileMaker Server. Type 2399. Type the filename of the FileMaker database file youre using as a data source (dont type the filename extension). If your database name contains spaces, replace them with the escape characters %20. For example, ServerDataDource=MY%20DATABASE. Double-byte characters are not supported.
Port ServerDataSource
About JDBC
JDBC is a Java API for executing SQL statements, the standard language for accessing relational databases. JDBC is a name and not an acronym although it is thought of as standing for Java Database Connectivity because it is the Java equivalent for ODBC. JDBC is a low-level interface, which means that it is used to call SQL commands directly. It is also designed to be used as a base for higher level interfaces and tools. Your Java applet or application can talk directly to a FileMaker database file by using the JDBC client driver. Your SQL statements are delivered to the FileMaker host of the database file and the results of those statements are sent back to you. If you use FileMaker Server to host, the FileMaker database file youre using as a data source can be located on another machine (the server machine) connected to the network, while your Java applet or client application is located on your machine (the client machine). This is referred to as a client/server configuration.
FileMaker
Client machine
Database server
1 Savepoint support 1 Retrieval of auto-generated keys 1 Passing parameters to a callable statement object by name
22
1 1 1 1 1 1 1 1
Holdable cursor support Making internal updates to the data in Blob and Clob objects Retrieving and updating the object referenced by a Ref object Updating of columns containing BLOB, CLOB, ARRAY and REF data types Boolean data type DATALINK data type Transform groups and type mapping Relationship between the JDBC SPI and the Connector architecture
For additional details, see www.filemaker.com/support/technologies. Also see the SequeLink Developers Reference available at www.datadirect.com for information about JDBC compatibility and developing JDBC applications for SequeLink. The JDBC client driver has been tested against the Java Development Kit (JDK) 1.5 (Mac OS) and 1.6 (Windows). It is a Type 4 driver a native protocol, pure Java driver that converts JDBC calls directly into the network protocol used by FileMaker. This type of driver offers all the advantages of Java including automatic installation (for example, downloading the JDBC driver with an applet that uses it). The driver works with JDK 1.3 and Java 2 as long as you only use JDBC 1.2 calls in a Java 2 environment. The driver class and main entry point for the driver is named: com.ddtek.jdbc.sequelink.SequeLinkDriver Important The JDBC client driver replaces the FileMaker JDBC driver released with a previous version of FileMaker. If you have previously set up access to a FileMaker data source using the older driver, youll need to re-define access by using and configuring the new driver. Note To confirm that the SequeLink Server is currently running, you can use the Activity Monitor on Mac OS or the Task Manager on Windows to check the status of the ddfmsoc process. When the process is started, it is named FMSocket_SL55, and events are logged by that name. The SequeLink Server process is separate from the FileMaker Server process.
Chapter 4
23
2. Establishes a connection with the FileMaker data source (the JDBC URL is jdbc:sequelink:// 17.184.17.170:2399). 3. Returns error codes.
import java.sql.*; class FMPJDBCTest { public static void main(String[ ] args) { // register the JDBC client driver try { Driver d = (Driver)Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver").newInstance(); } catch(Exception e) { System.out.println(e); } // establish a connection to FileMaker Connection con; try { con = DriverManager.getConnction(jdbc:sequelink://17.184.17.170:2399; user=some user;password=some password;serverDataSource=database); } catch(Exception e) + ";serverdatasource=" + dbName{ System.out.println(e); } // get connection warnings + ";serverDataSource=" + dbName SQLWarning warning = null; try { warning = con.getWarnings(); if (warning == null) { System.out.println("No warnings"); return; } while (warning != null) { System.out.println("Warning: "+warning); warning = warning.getNextWarning(); } } catch (Exception e) { Sysem.out.println(e); } } }
24
1 user: an account in the FileMaker database file that uses a privilege set with the extended privilege
Access via ODBC/JDBC
1 password: the password for the account in the FileMaker database file
Basic JDBC URL connection Format: jdbc:sequelink://<sequelink host IP address>:<port> This is the URL to connect to the FileMaker database file with no passwords. The port number is always 2399 (you cant change the JDBC sharing to a different port). If you are executing the JDBC URL connection on the same machine where the file is located, you can use jdbc:sequelink://localhost:2399 Example: jdbc:sequelink://17.184.17.170:2399 JDBC URL connection with user name and password defined in the URL Format:
jdbc:sequelink://<sequelink host IP address>:<port>;user=<userName>;password=<password>
Example: jdbc:sequelink://17.184.17.170:2399;user=phil;password=jsp JDBC URL connection with the database name specified in the URL Format:
jdbc:sequelink://<sequelink host IP address>:<port>; serverDataSource=<databasename>
Example: jdbc:sequelink://17.184.17.170:2399;serverDataSource=publications If your database name contains spaces, replace them with the escape characters %20. Example: jdbc:sequelink://17.184.17.170:2399;serverDataSource=MY%20DATABASE JDBC URL connection with the database name, user name, and password specified in the URL Format 1 (using the data store user name and password): jdbc:sequelink://<sequelink host IP address>:<port>;serverDataSource=<databasename>;DBUser=<databaseusername>; DBPassword=<databasepassword> Format 2 (using the host user name and password): jdbc:sequelink://<sequelink host IP address>:<port>;serverDataSource=<databasename>;HUser=<username>;HPassword=<pa ssword>
Chapter 4
25
If your FileMaker database solution uses many FileMaker database files, create an additional database file that contains all the necessary external data source references, table occurrences, and relationships for your solution. Then define this additional database file as your data source in the JDBC URL. All of the FileMaker database files must be on the same computer. Note Secure Socket Layer (SSL) encryption is not supported. To create a more secure JDBC solution, set up an environment such as .ASP or .JSP, where the web server is hosting via https and communicating with the FileMaker database file behind a firewall.
1 The FileMaker database file is hosted and available. 1 Your FileMaker account uses a privilege set with the extended privilege of Access via ODBC/JDBC. 1 The FileMaker Pro or FileMaker Server Advanced host application has been set up for sharing via
ODBC/JDBC. To share a FileMaker database file as a data source, use FileMaker Pro to define accounts that need access to the database file. Then, control access to the database file by assigning privilege sets to the accounts, including the extended privilege of access via ODBC/JDBC. Finally, enable the FileMaker Server Advanced or FileMaker Pro host application to share data via ODBC/JDBC. For details, see FileMaker Pro Help.
1 The JDBC client driver registration and the JDBC URL are correct (the driver can be included inside the
Java Application or located on the client machine). For additional information on using JDBC to share FileMaker data, see www.filemaker.com/support/ technologies.
26
SQL statements
The ODBC and JDBC client drivers provide support for the following SQL statements:
SELECT (see below) CREATE TABLE (page 34) DELETE (page 33) ALTER TABLE (page 35) INSERT (page 33) CREATE INDEX (page 35) UPDATE (page 34) DROP INDEX (page 36)
The client drivers also support FileMaker data type mapping to ODBC SQL and JDBC SQL data types. See appendix 6, Mapping FileMaker fields to ODBC data types and appendix 7, Mapping FileMaker fields to JDBC data types for data type conversions. For more information on constructing SQL queries, refer to a third-party book. Note The ODBC and JDBC client drivers recognize only the first repetition in a repeating field. Also, the drivers do not support portals in FileMaker Pro.
SELECT statement
Use the SELECT statement to specify which columns you're requesting. Follow the SELECT statement with the column expressions (similar to field names) you want to retrieve (for example, last_name). Expressions can include mathematical operations or string manipulation (for example, SALARY * 1.05).
28
Items in brackets are optional. Note SELECT * on larger databases and SELECT statements that use table aliases or literals in the projection list might not function correctly. To avoid potential confusion, avoid wildcards and specify table and column names without aliases.
column_alias can be used to give the column a more descriptive name, or to abbreviate a longer column name. For example, to assign the alias department to the column dept: SELECT dept AS department FROM emp
Field names can be prefixed with the table name or the table alias. For example, EMP.LAST_NAME or E.LAST_NAME, where E is the alias for the table EMP. The DISTINCT operator can precede the first column expression. This operator eliminates duplicate rows from the result of a query. For example:
SELECT DISTINCT dept FROM emp
SQL clauses
The ODBC and JDBC client drivers provide support for the following SQL clauses.
Use this SQL clause FROM (see below) WHERE (page 29) GROUP BY (page 29) To Indicate which tables are used in the SELECT statement. Specify the conditions that records must meet to be retrieved (like a FileMaker Pro find request). Specify the names of one or more fields by which the returned values should be grouped. This clause is used to return a set of aggregate values by returning one row for each group (like a FileMaker Pro subsummary). Specify conditions for groups of records (for example, display only the departments that have salaries totaling more than $200,000). This clause is only valid if you have already defined a GROUP BY clause. Combine the results of two or more SELECT statements into a single result. Indicate how the records are sorted To perform Positioned Updates or Positioned Deletes via SQL cursors
UNION (page 29) ORDER BY (page 30) FOR UPDATE (page 30)
Note If you attempt to retrieve data from a table with no columns, the SELECT statement fails.
Chapter 5
Supported standards
29
FROM clause
The FROM clause indicates the tables that are used in the SELECT statement. The format is:
FROM table_names [table_alias] table_names can be one or more simple table names in the current working directory or complete pathnames. table_alias can be used to give the table a more descriptive name, or to abbreviate a longer table name.
Field names can be prefixed with the table name or the table alias. For example, given the table specification FROM employee E, you can refer to the LAST_NAME field as E.LAST_NAME. Table aliases must be used if the SELECT statement joins a table to itself. For example:
SELECT * FROM employee E, employee F WHERE E.manager_id = F.employee_id
The equal sign (=) includes only matching rows in the results. If you are joining more than one table, and you want to discard all rows that dont have corresponding rows in both source tables, you can use INNER JOIN. For example:
SELECT * FROM Salespeople INNER JOIN Sales_Data ON Salespeople.Salesperson_ID = Sales_Data.Salesperson_ID
WHERE clause
The WHERE clause specifies the conditions that records must meet to be retrieved. The WHERE clause contains conditions in the form:
WHERE expr1 rel_operator expr2 expr1 and expr2 can be field names, constant values, or expressions. rel_operator is the relational operator that links the two expressions. For example, the following
SELECT statement retrieves the names of employees who make $20,000 or more.
SELECT last_name,first_name FROM emp WHERE salary >= 20000
Note If you use fully qualified names in the SELECT (projection) list, you must also use fully qualified names in the related WHERE clause.
GROUP BY clause
The GROUP BY clause specifies the names of one or more fields by which the returned values should be grouped. This clause is used to return a set of aggregate values. It has the following format:
GROUP BY column_expressions column_expressions must match the column expression used in the SELECT clause. A column
expression can be one or more field names of the database table separated by commas, or one or more expressions separated by commas. The following example sums the salaries in each department.
SELECT dept_id, SUM (salary) FROM emp GROUP BY dept_id
This statement returns one row for each distinct department ID. Each row contains the department ID and the sum of the salaries of the employees in the department.
30
HAVING clause
The HAVING clause enables you to specify conditions for groups of records (for example, display only the departments that have salaries totaling more than $200,000). This clause is valid only if you have already defined a GROUP BY clause. It has the following format:
HAVING expr1 rel_operator expr2 expr1 and expr2 can be field names, constant values, or expressions. These expressions do not have to match a column expression in the SELECT clause. rel_operator is the relational operator that links the two expressions. The following example returns only
UNION operator
The UNION operator combines the results of two or more SELECT statements into a single result. The single result is all of the returned records from the SELECT statements. By default, duplicate records are not returned. To return duplicate records, use the ALL keyword (UNION ALL). The format is:
SELECT statement UNION [ALL] SELECT statement
When using the UNION operator, the select lists for each SELECT statement must have the same number of column expressions, with the same data types, and must be specified in the same order. For example:
SELECT last_name, salary, hire_date FROM emp UNION SELECT name, pay, birth_date FROM person
This example has the same number of column expressions, and each column expression, in order, has the same data type. The following example is not valid because the data types of the column expressions are different (SALARY from EMP has a different data type than LAST_NAME from RAISES). This example has the same number of column expressions in each SELECT statement, but the expressions are not in the same order by data type.
SELECT last_name, salary FROM emp UNION SELECT salary, last_name FROM raises
ORDER BY clause
The ORDER BY clause indicates how the records are to be sorted. The format is:
ORDER BY {sort_expression [DESC | ASC]}, ... sort_expression can be field names, expressions, or the positional number of the column expression to use. The default is to perform an ascending (ASC) sort.
For example, to sort by last_name then by first_name, you could use either of the following SELECT statements:
SELECT emp_id, last_name, first_name FROM emp ORDER BY last_name, first_name
or
SELECT emp_id, last_name, first_name FROM emp ORDER BY 2,3
In the second example, last_name is the second column expression following SELECT, so ORDER BY 2 sorts by last_name.
Chapter 5
Supported standards
31
column_expressions is a list of field names in the database table that you intend to update, separated by a comma. column_expressions is optional.
The following example returns all records in the employee database that have a SALARY field value of more than $20,000. When each record is fetched, it is locked. If the record is updated or deleted, the lock is held until you commit the change. Otherwise, the lock is released when you fetch the next record.
SELECT * FROM emp WHERE salary > 20000 FOR UPDATE OF last_name, first_name, salary
Additional examples:
Using text constant numeric constant date constant time constant timestamp constant text column numeric column date column time column timestamp column BLOBa column Wildcard * Sample SQL
SELECT 'CatDog' FROM Salespeople SELECT 999 FROM Salespeople SELECT DATE '2004-06-05' FROM Salespeople SELECT TIME '02:49:03' FROM Salespeople SELECT TIMESTAMP '2004-06-05 02:49:03' FROM Salespeople SELECT Company_Name FROM Sales_Data SELECT DISTINCT Company_Name FROM Sales_Data SELECT Amount FROM Sales_Data SELECT DISTINCT Amount FROM Sales_Data SELECT Date_Sold FROM Sales_Data SELECT DISTINCT Date_Sold FROM Sales_Data SELECT Time_Sold FROM Sales_Data SELECT DISTINCT Time_Sold FROM Sales_Data SELECT Timestamp_Sold FROM Sales_Data SELECT DISTINCT Timestamp_Sold FROM Sales_Data SELECT Company_Brochures FROM Sales_Data SELECT GETAS(Company_Logo, 'JPEG') FROM Sales_Data SELECT * FROM Salespeople SELECT DISTINCT * FROM Salespeople
Notes from the examples A column is a reference to a field in the FileMaker database file (the field can contain many distinct values). The asterisk (*) wildcard character is shorthand for everything. For the example SELECT * FROM Salespeople, the result is all the rows in the Salespeople table. For the example SELECT DISTINCT * FROM Salespeople, the result is all the unique rows in the Salespeople table (no duplicates). Note SELECT * statements on larger databases might not function correctly. To avoid potential confusion, avoid wildcards and specify table and column names (without aliases). 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. To retrieve binary data, use a standard SELECT statement. For example:
SELECT Company_Brochures FROM Sales_Data
32
If file or JPEG data exists, the SELECT statement retrieves the data in binary form; otherwise, the SELECT statement 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(NNN)) FROM Sales_Data
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 and specify the files type depending on how the data was inserted into the container field in FileMaker Pro.
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 raw format),
specify 'snd' in the GetAs function. For example:
SELECT GetAs(Company_Meeting, 'snd') FROM Company_Newsletter
1 If the data was inserted using the Insert > Object command (OLE container data), specify 'EMBO' in the
GetAs function. For example:
SELECT GetAs(Company_Results, 'EMBO') FROM Annual_Report
1 If the data was inserted using the Insert > Picture command, drag and drop, or paste from the clipboard,
specify one of the file types (case sensitive) listed in the following table. For example:
SELECT GetAs(Company_Logo, 'JPEG') FROM Company_Icons
File type 'EMF+' 'EPS ' 'FPix' 'FORK' 'GIFf' 'JPEG' 'JP2 ' 'META' 'METO' 'moov'
Description Windows Enhanced Metafile Plus Embedded PostScript Flash (FPX) Resource fork (Mac OS) Graphics Interchange Format Photographic images JPEG 2000 Windows Metafile (enhanced) Windows Metafile (original) Old QuickTime format (Mac OS)
File type 'PDF ' 'PICT' 'PNGf' 'PNTG' 'qtif' '.SGI' 'TIFF' 'TPIC' 'XMLO' '8BPS'
Description Portable Document Format Mac OS (does not have 512-byte file-based header) Bitmap image format MacPaint QuickTime image file Generic bitmap format Raster file format for digital images Targa Layout objects PhotoShop (PSD)
Chapter 5
Supported standards
33
DELETE statement
Use the DELETE statement to delete records from a database table. The format of the DELETE statement is:
DELETE FROM table_name [ WHERE { conditions } ]
Note The WHERE clause determines which records are to be deleted. If you dont include the WHERE keyword, all records in the table are deleted (but the table is left intact). An example of a DELETE statement on the Employee table is:
DELETE FROM emp WHERE emp_id = 'E10001'
Each DELETE statement removes every record that meets the conditions in the WHERE clause. In this case, every record having the employee ID E10001 is deleted. Because employee IDs are unique in the Employee table, only one record is deleted.
INSERT statement
Use the INSERT statement to create records in a database table. You can specify either:
1 A list of values to be inserted as a new record 1 A SELECT statement that copies data from another table to be inserted as a set of new records
The format of the INSERT statement is:
INSERT INTO table_name [(column_name, ...)] VALUES (expr, ...) column_name is an optional list of column names that provides the name and order of the columns whose values are specified in the VALUES clause. If you omit column_name, the value expressions (expr) must provide values for all columns defined in the table and must be in the same order that the columns are defined for the table. expr is the list of expressions giving the values for the columns of the new record. Usually the expressions are constant values for the columns (but they can also be a subquery). You must enclose character string values in pairs of single quotation marks ('). To include a single quotation mark in a character string value enclosed by single quotation marks, use two single quotation marks together (for example, 'Don''t'). Date, time, and timestamp values must be enclosed in braces {}. Logical values that are characters must be enclosed in periods (for example, .T. or .F.). Subqueries must be enclosed in parentheses.
Each INSERT statement adds one record to the database table. In this case a record has been added to the employee database table, EMP. Values are specified for five columns. The remaining columns in the table are assigned a blank value, meaning Null. Note In container fields, you can INSERT only text. The SELECT statement is a query that returns values for each column_name value specified in the column name list. Using a SELECT statement instead of a list of value expressions lets you select a set of rows from one table and insert it into another table using a single INSERT statement. Here's an example of an INSERT statement that uses a SELECT statement:
INSERT INTO emp1 (first_name, last_name, emp_id, dept, salary) SELECT first_name, last_name, emp_id, dept, salary from emp WHERE dept = D050
34
In this type of INSERT statement, the number of columns to be inserted must match the number of columns in the SELECT statement. The list of columns to be inserted must correspond to the columns in the SELECT statement just as it would to a list of value expressions in the other type of INSERT statement. For example, the first column inserted corresponds to the first column selected; the second inserted to the second, and so on. The size and data type of these corresponding columns must be compatible. Each column in the SELECT list should have a data type that the ODBC or JDBC client driver accepts on a regular INSERT/UPDATE of the corresponding column in the INSERT list. Values are truncated when the size of the value in the SELECT list column is greater than the size of the corresponding INSERT list column. The SELECT statement is evaluated before any values are inserted.
UPDATE statement
Use the UPDATE statement to change records in a database table. The format of the UPDATE statement is:
UPDATE table_name SET column_name = expr, ... [ WHERE { conditions } ] column_name is the name of a column whose value is to be changed. Several columns can be changed in
one statement.
expr is the new value for the column. Usually the expressions are constant values for the columns (but they can also be a subquery). You must enclose character string values in pairs of single quotation marks ('). To include a single quotation mark in a character string value enclosed by single quotation marks, use two single quotation marks together (for example, 'Don''t'). Date, time, and timestamp values must be enclosed in braces {}. Logical values that are characters must be enclosed in periods (for example, .T. or .F.). Subqueries must be enclosed in parentheses.
The WHERE clause is any valid clause. It determines which records are updated. An example of an UPDATE statement on the Employee table is:
UPDATE emp SET salary=32000, exempt=1 WHERE emp_id = 'E10001'
The UPDATE statement changes every record that meets the conditions in the WHERE clause. In this case the salary and exempt status are changed for all employees having the employee ID E10001. Because employee IDs are unique in the Employee table, only one record is updated. Here's an example using a subquery:
UPDATE emp SET salary = (SELECT avg(salary) from emp) WHERE emp_id = 'E10001'
In this case, the salary is changed to the average salary in the company for the employee having employee ID E10001. Note In container fields, you can UPDATE only with text.
Within the statement, you specify the name and data type of each column.
table_name and table_element_list have a 100 character limit. Defining a column to be NOT NULL
automatically selects the Not Empty Validation Option for the corresponding field in the FileMaker database file. The field is flagged as a Required Value in the Fields tab of the Manage Database dialog box in FileMaker Pro.
Chapter 5
Supported standards
35
Examples
Using text column text column, NOT NULL numeric column date column time column timestamp column BLOB column Sample SQL
CREATE TABLE T1 (C1 VARCHAR, C2 VARCHAR (50), C3 VARCHAR (1001), C4 VARCHAR (500276)) CREATE TABLE T1NN (C1 VARCHAR NOT NULL, C2 VARCHAR (50) NOT NULL, C3 VARCHAR (1001) NOT NULL, C4 VARCHAR (500276) NOT NULL) CREATE TABLE T2 (C1 DECIMAL, C2 DECIMAL (10,0), C3 DECIMAL (7539,2), C4 DECIMAL (497925,301)) CREATE TABLE T3 (C1 DATE, C2 DATE, C3 DATE, C4 DATE) CREATE TABLE T4 (C1 TIME, C2 TIME, C3 TIME, C4 TIME) CREATE TABLE T5 (C1 TIMESTAMP, C2 TIMESTAMP, C3 TIMESTAMP, C4 TIMESTAMP) CREATE TABLE T6 (C1 BLOB, C2 BLOB, C3 BLOB, C4 BLOB)
You must know the tables structure and how you want to modify it before using the ALTER TABLE statement. Examples
To add columns remove columns Sample SQL
ALTER TABLE Salespeople ADD C1 VARCHAR ALTER TABLE Salespeople DROP C1
CREATE INDEX is supported for a single column (multi-column indexes are not supported). Indexes are not allowed on columns that correspond to container field types, summary fields, fields that have the global storage option, or unstored calculation fields in a FileMaker database file. Creating an index for a text column automatically selects the Storage Option of Minimal in Indexing for the corresponding field in the FileMaker database file. Creating an index for a non-text column (or a column formatted as Japanese text) automatically selects the Storage Option of All in Indexing for the corresponding field in the FileMaker database file. Creating an index for any column automatically selects the Storage Option of Automatically create indexes as needed in Indexing for the corresponding field in the FileMaker database file. Example
CREATE INDEX myIndex ON Salespeople.Salesperson_ID
36
Remove an index when your database file is too large, or you dont often use a field in queries. If your queries are experiencing poor performance, and youre working with an extremely large FileMaker database file with many indexed text fields, consider dropping the indexes from some fields. Also consider dropping the indexes from fields that you rarely use in SELECT statements. Dropping an index for any column automatically selects the Storage Option of None and clears Automatically create indexes as needed in Indexing for the corresponding field in the FileMaker database file. The PREVENT INDEX CREATION attribute is not supported. Example
DROP INDEX ON Salespeople.Salesperson_ID
In this example, only unique last name values are counted. Important Use uppercase letters for SQL function names (some are case sensitive).
Returns The total of the values in a numeric field expression. For example, SUM(SALARY) returns the sum of all salary field values. The average of the values in a numeric field expression. For example, AVG(SALARY) returns the average of all salary field values. The number of values in any field expression. For example, COUNT(NAME) returns the number of name values. When using COUNT with a field name, COUNT returns the number of non-null field values. A special example is COUNT(*), which returns the number of records in the set, including records with null values. The maximum value in any field expression. For example, MAX(SALARY) returns the maximum salary field value. The minimum value in any field expression. For example, MIN(SALARY) returns the minimum salary field value.
MAX MIN
Chapter 5
Supported standards
37
Examples
SELECT SUM (Sales_Data.Amount) AS agg FROM Sales_Data SELECT AVG (Sales_Data.Amount) AS agg FROM Sales_Data SELECT COUNT (Sales_Data.Amount) AS agg FROM Sales_Data SELECT MAX (Sales_Data.Amount) AS agg FROM Sales_Data WHERE Sales_Data.Amount < 3000 SELECT MIN (Sales_Data.Amount) AS agg FROM Sales_Data WHERE Sales_Data.Amount < 3000
SQL expressions
Use expressions in WHERE, HAVING, and ORDER BY clauses of SELECT statements to form detailed and sophisticated database queries.Valid expression elements are:
Field names Constants and literals Exponential notation Numeric operators Character operators Date operators Relational operators Logical operators Functions
Field names
The most common expression is a simple field name, such as calc or Sales_Data.Invoice_ID.
38
Constant Time
Acceptable syntax (examples) TIME '14:35:10' { T '14:35:10' } {14:35:10} TIMESTAMP '2005-06-05 14:35:10' { TS '2005-06-05 14:35:10'} { 06/05/2005 14:35:10 } {2005-06-05 14:35:10} { 06/05/05 14:35:10 } Make sure Strict data type: 4-Digit Year Date is not selected as a validation option in the FileMaker database file for a field using this 2-digit year syntax.
Timestamp
When entering date and time values, match the format of the database file locale. For example, if the database was created on an Italian language system, use Italian date and time formats. Logical values that are characters must be enclosed in periods. The logical constants are .T. and 1 for True and .F. and 0 for False. For portability, use 1 and 0.
Exponential/scientific notation
You can include exponential notation. Example
SELECT column1, 3.4E+7 FROM table1 WHERE calc < 3.4E-6 * column2
Numeric operators
You can include the following operators in number expressions: +, -, *, /, and ^ or ** (exponentiation). You can precede numeric expressions with a unary plus (+) or minus (-).
Character operators
You can concatenate characters. Examples In the following examples, last_name is 'JONES ' and first_name is 'ROBERT ':
Operator + Concatenation Keep trailing blank characters Move trailing blank characters to the end Example first_name + last_name first_name - last_name Result 'ROBERT JONES ' 'ROBERTJONES '
Chapter 5
Supported standards
39
Date operators
You can modify dates. Examples In the following examples, hire_date is {01/30/2004}.
Operator + Effect on date Add a number of days to a date Find the number of days between two dates, or subtract a number of days from a date Example hire_date + 5 hire_date - {01/01/2004} hire_date - 10 Result {02/04/2004} 29 {01/20/2004}
Additional examples:
SELECT Date_Sold, Date_Sold + 30 AS agg FROM Sales_Data SELECT Date_Sold, Date_Sold - 30 AS agg FROM Sales_Data
Relational operators
Operator = <> > >= < <= LIKE NOT LIKE IS NULL IS NOT NULL BETWEEN IN NOT IN EXISTS ANY ALL Meaning Equal Not equal Greater than Greater than or equal to Less than Less than or equal to Matching a pattern Not matching a pattern Equal to Null Not equal to Null Range of values between a lower and upper bound A member of a set of specified values or a member of a subquery Not a member of a set of specified values or a member of a subquery True if a subquery returned at least one record Compares a value to each value returned by a subquery (operator must be preceded by =, <>, >, >=, <, or <=); =Any is equivalent to In Compares a value to each value returned by a subquery (operator must be preceded by =, <>, >, >=, <, or <=)
Examples
SELECT Sales_Data.Invoice_ID FROM Sales_Data WHERE Sales_Data.Salesperson_ID = 'SP-1' SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Invoice_ID <> 125 SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount > 3000
40
SELECT Sales_Data.Time_Sold FROM Sales_Data WHERE Sales_Data.Time_Sold < '12:00:00' SELECT Sales_Data.Company_Name FROM Sales_Data WHERE Sales_Data.Company_Name LIKE '%University' SELECT Sales_Data.Company_Name FROM Sales_Data WHERE Sales_Data.Company_Name NOT LIKE '%University' SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount IS NULL SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount IS NOT NULL SELECT Sales_Data.Invoice_ID FROM Sales_Data WHERE Sales_Data.Invoice_ID BETWEEN 1 AND 10 SELECT COUNT(Sales_Data.Invoice_ID) AS agg FROM Sales_Data WHERE Sales_Data.INVOICE_ID IN (50,250,100) SELECT COUNT(Sales_Data.Invoice_ID) AS agg FROM Sales_Data WHERE Sales_Data.INVOICE_ID NOT IN (50,250,100) SELECT COUNT(Sales_Data.Invoice_ID) AS agg FROM Sales_Data WHERE Sales_Data.INVOICE_ID NOT IN (SELECT Sales_Data.Invoice_ID FROM Sales_Data WHERE Sales_Data.Salesperson_ID = 'SP-4') SELECT * FROM Sales_Data WHERE EXISTS (SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Salesperson_ID IS NOT NULL) SELECT * FROM Sales_Data WHERE Sales_Data.Amount = ANY (SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Salesperson_ID = 'SP-1') SELECT * FROM Sales_Data WHERE Sales_Data.Amount = ALL (SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Salesperson_ID IS NULL)
Logical operators
You can combine two or more conditions. The conditions must be related by AND or OR, such as:
salary = 40000 AND exempt = 1
The logical NOT operator is used to reverse the meaning, such as:
NOT (salary = 40000 AND exempt = 1)
Examples
SELECT * FROM Sales_Data WHERE Sales_Data.Company_Name NOT LIKE '%University' AND Sales_Data.Amount > 3000 SELECT * FROM Sales_Data WHERE (Sales_Data.Company_Name LIKE '%University' OR Sales_Data.Amount > 3000) AND Sales_Data.Salesperson_ID = 'SP-1'
Chapter 5
Supported standards
41
Functions
The ODBC and JDBC client drivers support many functions you can use in expressions. Some of the functions return characters strings, some return numbers, and some return dates. Important Use uppercase letters for SQL function names (some are case sensitive).
Functions that return character strings CHR RTRIM TRIM LTRIM UPPER LOWER LEFT RIGHT SUBSTR
Description Converts an ASCII code to a one-character string Removes trailing blanks from a string Removes leading and trailing blanks from a string Removes leading blanks from a string Changes each letter of a string to uppercase Changes each letter of a string to lowercase Returns leftmost characters of a string Returns rightmost characters of a string
Example
CHR(67) returns C RTRIM('ABC ') returns ABC TRIM(' ABC ') returns ABC LTRIM(' ABC') returns ABC UPPER('Allen') returns ALLEN LOWER('Allen') returns allen LEFT('Mattson',3) returns Mat RIGHT('Mattson',4) returns tson
Returns a substring of a string, with parameters of the SUBSTR('Conrad',2,3) returns onr string, the first character to extract, and the number of SUBSTR('Conrad',2) returns onrad characters to extract (optional) Generates a string of blanks Converts a value of any type to a character string
SPACE(5) returns '
SPACE STRVAL
'
STRVAL('Woltman') returns Woltman STRVAL(5 * 3) returns 15 STRVAL(4 = 5) returns 'False' STRVAL({12/25/2004}) returns 12/25/2004
TIME USERNAME
Returns the time of day as a string Returns the login ID specified at connect time
Examples
SELECT CHR(67) + SPACE(1) + CHR(70) FROM Salespeople SELECT RTRIM(' ' + Salespeople.Salesperson_ID) AS agg FROM Salespeople SELECT TRIM(SPACE(1) + Salespeople.Salesperson_ID) AS agg FROM Salespeople SELECT LTRIM(' ' + Salespeople.Salesperson_ID) AS agg FROM Salespeople SELECT UPPER(Salespeople.Salesperson) AS agg FROM Salespeople SELECT LOWER(Salespeople.Salesperson) AS agg FROM Salespeople SELECT LEFT(Salespeople.Salesperson, 5) AS agg FROM Salespeople SELECT RIGHT(Salespeople.Salesperson, 7) AS agg FROM Salespeople SELECT SUBSTR(Salespeople.Salesperson_ID, 2, 2) + SUBSTR(Salespeople.Salesperson_ID, 4, 2) AS agg FROM Salespeople SELECT SUBSTR(Salespeople.Salesperson_ID, 2) + SUBSTR(Salespeople.Salesperson_ID, 4) AS agg FROM Salespeople SELECT SPACE(2) + Salespeople.Salesperson_ID AS Salesperson_ID FROM Salespeople SELECT STRVAL('60506') AS agg FROM Sales_Data WHERE Sales_Data.Invoice_ID = 1
42
SELECT TIME() AS agg FROM Sales_Data WHERE Sales_Data.Invoice_ID = 1 SELECT USERNAME() AS agg FROM Sales_Data WHERE Sales_Data.Invoice_ID = 1
Functions that return numbers MOD LEN MONTH DAY YEAR MAX DAYOFWEEK MIN POW INT X B ROUND
Description Divides two numbers and returns the remainder of the division Returns the length of a string Returns the month part of a date Returns the day part of a date Returns the year part of a date Returns the larger of two numbers Returns the day of week (1-7) of a date expression Returns the smaller of two numbers Raises a number to a power Returns the integer part of a number Returns the decimal equivalent of a hexadecimal number Returns the decimal equivalent of a binary number Rounds a number
Example
MOD(10,3) returns 1 LEN('ABC') returns 3 MONTH({01/30/2004}) returns 1 DAY({01/30/2004}) returns 30 YEAR({01/30/2004}) returns 2004 MAX(66,89) returns 89 DAYOFWEEK({05/01/2004}) returns 7 MIN(66,89) returns 66 POW(7,2) returns 49 INT(6.4321) returns 6 X'b9' returns 185 B'1001' returns 9 ROUND(123.456,0) returns 123 ROUND(123.456,2) returns 123.46 ROUND(123.456,-2) returns 100 NUMVAL('123') returns 123 VAL('123') returns 123
NUMVAL VAL
Converts a character string to a number; if the character string is not a valid number, returns 0 Converts a character string to a number; if the character string is not a valid number, returns 0
Operator precedence
As expressions become more complex, the order in which the expressions are evaluated becomes important. This table shows the order in which the operators are evaluated. The operators in the first line are evaluated first, and so on. Operators in the same line are evaluated left to right in the expression.
Precedence 1 2 3 4 5 Operator Unary '-', Unary '+' ^, ** *, / +, =, <>, <, <=, >, >=, Like, Not Like, Is Null, Is Not Null, Between, In, Exists, Any, All
Chapter 5
Supported standards
43
Precedence 6 7 8
Because AND is evaluated first, this query retrieves employees in department D101 hired after January 30, 2004, as well as every employee making more than $40,000, no matter what department or hire date. To force the clause to be evaluated in a different order, use parentheses to enclose the conditions to be evaluated first. For example:
WHERE (salary > 40000 OR hire_date > {01/30/2004}) AND dept = 'D101'
retrieves employees in department D101 that either make more than $40,000 or were hired after January 30, 2004.
1 1 1 1 1
SQLTables - catalog information is stored and reported as single part names (table name only). SQLColumns SQLColumnPrivileges SQLDescribeCol SQLGetTypeInfo
44
Reserved keywords
ABSOLUTE ACTION ADD AFTER ALIAS ALL ALLOCATE ALTER AND ANY ARE AS ASC ASSERTION ASYNC AT AUTHORIZATION AVG BEFORE BEGIN BETWEEN BIT BIT_LENGTH BOOLEAN BOTH BREADTH BY CALL CASCADE CASCADED CASE CAST CATALOG CHAR CHARACTER CHARACTER_LENGTH CHAR_LENGTH CHECK CHR CLOSE COALESCE COLLATE COLLATION COLUMN COLUMNS COMMIT COMPLETION CONCAT CONNECT CONNECTION CONSTRAINT CONSTRAINTS CONTINUE CONVERT CORRESPONDING COUNT CREATE CROSS CURDATE CURRENT CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CURTIME CYCLE DATA DATE DAY DAYOFMONTH DAYOFWEEK DEALLOCATE DEC DECIMAL DECLARE DEFAULT DEFERRABLE DEFERRED DELETE DEPTH DESC DESCRIBE DESCRIPTOR DIAGNOSTICS DICTIONARY DISCONNECT DISTINCT DOMAIN DOUBLE DROP EACH ELSE ELSEIF END END_EXEC EQUALS ESCAPE EXCEPT EXCEPTION EXEC EXECUTE EXISTS EXTERNAL EXTRACT FALSE FETCH FIRST FLOAT FLOOR FOR FOREIGN FOUND FROM FULL GENERAL GET GLOBAL GO GOTO GRANT GROUP HAVING HOUR IDENTIFY IF IFNULL IGNORE IMMEDIATE IN INDEX INDICATOR INITIALLY INNER INPUT INSENSITIVE INSERT INT INTEGER INTERSECT INTERVAL INTO IS ISOLATION JOIN KEY LANGUAGE LAST LCASE LEADING LEAVE LEFT LEN LENGTH LESS LEVEL LIKE LIMIT LOCAL LOOP LOWER LTRIM MATCH MAX MIN MINUTE MOD MODIFY MODULE MONTH NAMES NATIONAL NATURAL NCHAR NEW
45
Reserved keywords
NEXT NO NONE NOT NOW NULL NULLIF NUMERIC OBJECT OCTET_LENGTH OF OFF OID OLD ON ONLY OPEN OPERATION OPERATORS OPTION OR ORDER OTHERS OUTER OUTPUT OVERLAPS PAD PARAMETERS PARTIAL PENDANT POSITION POW POWER PRECISION PREORDER PREPARE PRESERVE PRIMARY PRIOR PRIVATE PRIVILEGES PROCEDURE PROTECTED PUBLIC RCASE READ REAL RECURSIVE REF REFERENCES REFERENCING RELATIVE REMOVE REPLACE RESIGNAL RESTRICT RETURN RETURNS REVOKE RIGHT ROLE ROLLBACK ROUND ROUTINE ROW ROWS RTRIM SAVEPOINT SCHEMA SCROLL SEARCH SECOND SECTION SELECT SENSITIVE SEQUENCE SESSION SESSION_USER SET SIGNAL SIMILAR SIZE SMALLINT SOME SPACE SQL SQLCODE SQLERROR SQLEXCEPTION SQLSTATE SQLWARNING STATISTICS STRUCTURE SUBSTR SUBSTRING SUM SYSTEM_USER TABLE TEMPORARY TEST THEN THERE TIME TIMESTAMP TIMEZONE_HOUR TIMEZONE_MINUT E TO TRAILING TRANSACTION TRANSLATE TRANSLATION TRIGGER TRIM TRUE TYPE UCASE UNDER UNION UNIQUE UNKNOWN UPDATE UPPER USAGE USER USERNAME USING VALUE VALUES VARCHAR VARIABLE VARYING VIEW VIRTUAL VISIBLE WAIT WHEN WHENEVER WHERE WHILE WITH WITHOUT WORK WRITE YEAR ZONE
46
number
SQL_DOUBLE
date time
SQL_DATE SQL_TIME The FileMaker time field type can contain the time of day or a time interval. A time interval is returned as a time of day, unless it is less than 0 or greater than 24 hours (both return a value of 0).
SQL_TIMESTAMP SQL_LONGVARBINARY You can retrieve binary data, file reference information, or data of a specific file type from a container field. Within a SELECT statement, use the CAST function to retrieve file reference information, and use the GetAs function to retrieve data of a specific file type. The result is mapped to the corresponding ODBC data type.
calculation
String length is optional in table declarations. All strings are stored and retrieved in Unicode. Notes
1 You can SELECT up to 170 fields at one time from a FileMaker database file; you can UPDATE up to
100 fields at one time.
1 FileMaker supports repeating fields (array data types), but ODBC does not. FileMaker exports
repetitions to tab-delimited or comma-delimited files and separates each repetition with a group separator (Unicode decimal value 29). Text columns separated with the group separator are concatenated. All other data types return only the first repetition.
48
The JDBC client driver converts the FileMaker calculation data type to the JDBC SQL type matching the calculations result. For example, the JDBC client driver converts a FileMaker calculation that results in a timestamp data type to java.sql.Types.TIMESTAMP.
50
52
1 JDBC driver errors 1 SequeLink Server errors 1 the data source or database management system
Chapter 8
53
54
Index
A
Access via ODBC/JDBC extended privilege 16 accounts and privileges 16 aggregate functions in SQL 36 aliases with SELECT statement 28, 31 ALL operator 39 ALTER TABLE (SQL statement) 35 AND operator 40 ANY operator 39 APIs 7 ARRAY data type 22 auto-generated keys 21 ODBC data type mapping 47 with INSERT statement 33 with SELECT statement 31 with UPDATE statement 34 CREATE INDEX (SQL statement) 35 CREATE TABLE (SQL statement) 34 cursors in JDBC 22 in ODBC 30
D
data source configuring for access via JDBC 24 configuring for access via ODBC (Mac OS) 19 configuring for access via ODBC (Windows) 17 disabling a shared FileMaker database file 8 one DSN for each FileMaker database file 9 using FileMaker as 7 verifying access via JDBC 25 verifying access via ODBC (Windows) 18 data source names. See DSNs data type mapping JDBC client driver 49 ODBC client driver 47 database connections, number supported 8 database name considerations Mac OS 19 Windows 18 DATALINK data type 22 DATE function 42 date operators in SQL expressions 39 DATEVAL function 42 DAY function 42 DAYOFWEEK function 42 DELETE (SQL statement) 33 disabling a shared FileMaker database file 8 DISTINCT operator 28 driver properties JDBC client driver 24 ODBC client driver (Mac OS) 19 ODBC client driver (Windows) 17 drivers installing FileMaker JDBC 13 installing FileMaker ODBC 12 uninstalling old 9 DROP INDEX (SQL statement) 36
B
B function 42 BETWEEN operator 39 bitmap files in container fields 32 blank characters 38 blank space in database name 20, 24 blank value in columns 33 BLOB data type JDBC limitation 22 use in CREATE TABLE 35 use in SELECT 31 Boolean data type 22
C
CAST function 32, 47 catalog functions for ODBC 43 character operators in SQL expressions 38 CHR function 41 client application, using FileMaker as 7 client drivers. See drivers CLOB data type 22 column aliases 28 column names 17 configuring a FileMaker data source via JDBC 24 via ODBC (Mac OS) 19 via ODBC (Windows) 17 connections, database 8 constants in SQL expressions 37 container field JDBC data type mapping 49
56
DSNs creating (Mac OS) 19 creating (Windows) 17 keyword values for (Mac OS) 20 one per file 9
FileMaker JDBC client drivers 13 FileMaker ODBC client drivers 12 INT function 42
J
JAR archive files 13 Java Development Kit (JDK) 22 Java version 12 JDBC client driver, described 21 described 21 error messages 52 overview of using 7 JDBC client driver driver class and main entry point 22 installing 13 mapping data types 49 meta data functions 43 registering with the JDBC driver manager 22 repeating fields 27 specifying the JDBC URL 22 Unicode support 27 verifying access 25 JDBC SPI 22 JDBCTest 14 join 29
E
error message formats 51 escape character 20, 24 EXISTS operator 39 exponential notation in SQL expressions 38 expressions in SQL 37 extended privileges 16
F
field names in SQL expressions 37 fields mapping to JDBC 49 mapping to ODBC 47 FileMaker client drivers. See drivers FileMaker products 8 filename limitations (Mac OS) 19 files organizing on one computer 8 setting up access to 16 use in container fields 32 FOR UPDATE (SQL clause) 30 FROM (SQL clause) 29 functions in SQL expressions 41
K
keywords for DSNs (Mac OS) 20 reserved SQL 44
G
Get(LastError) function 51 Get(LastODBCError) function 51 GetAs function 32, 47 GROUP BY (SQL clause) 29
L
LEFT function 41 LEN function 42 LIKE operator 39 literals in SQL expressions 37 logical operators in SQL expressions 40 LOWER function 41 LTRIM function 41
H
HAVING (SQL clause) 30 holdable cursor 22 hosting a FileMaker data source 7
M I
image files in container fields 32 INNER JOIN 29 INSERT (SQL statement) 33 installation requirements 11 installing Mac OS creating a DSN 19 installing JDBC client driver 13 installing ODBC client driver 13 JDBC client driver requirements 12 ODBC Administrator 13, 19
|
ODBC client driver requirements 11 mapping data types JDBC client driver 49 ODBC client driver 47 MAX function 42 meta data functions for JDBC 43 Microsoft Access client application 8 Microsoft Query Wizard 8 MIN function 42 MOD function 42 MONTH function 42
Index
57
P
password with JDBC 24 with ODBC 19 port specifying for JDBC 24 specifying for ODBC (Mac OS) 20 specifying for ODBC (Windows) 18 portals 27 positioned updates and deletes 30 POW function 42 privileges, extended 16
N
network requirements 8 NOT NULL (SQL clause) 34 NOT operator 40 null value 33, 47 numeric operators in SQL expressions 38 NUMVAL function 42
Q
QuickTime files in container fields 32
R
Rapid Application Development (RAD) tools 21 REF data type 22 registering the JDBC client driver 22 relational operators in SQL expressions 39 remote access 8 repeating fields 27, 47 requirements for installation 11 reserved SQL keywords 44 RIGHT function 41 ROUND function 42 RTRIM function 41
O
ODBC described 15 error messages 51 overview of using 7 repeating fields 47 standards compliance 27 ODBC Administrator (Mac OS) 13, 19 ODBC client driver catalog functions 43 installing (Mac OS) 13 installing (Windows) 12 mapping data types 47 maximum number of FileMaker fields 47 repeating fields 27 Unicode support 27 verifying access (Windows) 18 ODBC Data Source Administrator (Windows) 17 operator precedence in SQL expressions 42 OR operator 40 ORDER BY (SQL clause) 30 OUTER JOIN 29 overview setting up privileges and sharing 16 using ODBC and JDBC with FileMaker 7
S
savepoint support 21 scientific notation in SQL expressions 38 Secure Socket Layer encryption 25 SELECT (SQL statement) 27 SequeLink Server Host 18 SequeLink Server Port 18 Server Data Source 18 sharing, setting up ODBC/JDBC 16 SPACE function 41 space in database name 20, 24 SQL aggregate functions 36 SQL expressions 37 character operators 38 constants 37 date operators 39 exponential or scientific notation 38 field names 37
58
functions 41 literals 37 logical operators 40 numeric operators 38 operator precedence 42 relational operators 39 SQL standards compliance 27 SQL statements ALTER TABLE 35 CREATE INDEX 35 CREATE TABLE 34 DELETE 33 DROP INDEX 36 INSERT 33 reserved keywords 44 SELECT 27 supported by client drivers 27 UPDATE 34 SQL_C_BINARY data type 27 SQL_C_WCHAR data type 27 SQL-92 27 SQLExceptions 52 standards compliance 27 string functions 41 STRVAL function 41 subqueries 33 SUBSTR function 41 syntax errors 44 system requirements 11
V
VAL function 42 VALUES (SQL clause) 33 verifying access JDBC client driver 25 ODBC client driver (Windows) 18
W
WHERE (SQL clause) 29 wildcards with SELECT statement 28, 31 Windows creating a DSN 17 installing JDBC client driver 13 installing ODBC client driver 12 JDBC client driver requirements 12 ODBC client driver requirements 11 verifying ODBC access 18
X
X function 42
Y
YEAR function 42
T
table aliases 28, 29 testing access JDBC client driver 25 ODBC client driver (Windows) 18 TIME function 41 TRIM function 41
U
Unicode support 27 UNION (SQL operator) 30 UPDATE (SQL statement) 34 UPPER function 41 URL (Uniform Resource Locator) for the JDBC client driver 22 USERNAME function 41