Matisse SQL Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Matisse® SQL Programmer’s Guide January 2017 Matissse SQL Programmer’s Guide Copyright © 2017 Matisse Software Inc. All Rights Reserved. This manual and the software described in it are copyrighted. Under the copyright laws, this manual or the software may not be copied, in whole or in part, without prior written consent of Matisse Software Inc. This manual and the software described in it are provided under the terms of a license between Matisse Software Inc. and the recipient, and their use is subject to the terms of that license. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the government is subject to restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227- 7013 and FAR 52.227-19. The product described in this manual may be protected by one or more U.S. and international patents. TRADEMARKS: Matisse and the Matisse logo are registered trademarks of Matisse Software Inc. All other trademarks belong to their respective owners. PDF generated 7 January 2017 Tables Table 1.1 Command Line Options . 15 Table 2.1 Matisse SQL Reserved Words. 23 Table 3.1 Comparison of OID and REF(). 28 Table 3.2 AND Operator Truth Table . 39 Table 3.3 OR Operator Truth Table . 39 Table 3.4 Equivalent Logical Expressions . 40 Table 4.1 Comparison Operators. 62 Table 4.2 Bitwise Operators . 63 Table 4.3 Types Resulting from Arithmetic Operation . 64 Table 4.4 Type Resulting from the Negation Operation. 65 Table 5.1 IS [NOT] NULL. 68 Table 6.1 Text Comparison Operators. 69 Table 6.2 ASCII Characters and Their Numeric Values. 70 Table 6.3 Equivalent Expressions Using ANY and ALL . 74 Table 10.1 Supported casts between built-in data types . 108 Tables 3 Contents Introduction. 11 Conventions. 11 1 SQL Query Analyzer and mt_sql Utility . .12 1.1 SQL Query Analyzer . 12 1.2 Simple Example with mt_sql . 14 1.3 Basic Usage . 14 1.4 Command Line Options . 15 1.5 Online Help . 16 1.6 Discovering the Schema . 16 2 Constants and Identifiers . .18 2.1 What Is a Constant? . 18 Integer Constants . 18 Numeric Constants . 18 Real Constants . 19 Boolean Constants . 19 Character String Constants . 19 Date and Timestamp Constants . 20 Time Interval Constants. 21 Bytes Constants. 22 List Constants . 22 2.2 What Is an Identifier? . 22 2.3 Matisse SQL Reserved Words . 23 3 Selecting Data . .25 3.1 Using the SELECT Command . 25 Using the ONLY Keyword . 26 Specifying a SQL Projection . 26 List Types in SQL Projection . 27 Aliases in SQL Projection . 27 OID, and Relationship in SQL Projection. 27 REF() in SQL Projection . 28 SQL Methods in SQL Projection . 29 Get a Successor at a Position in a Relationship . 30 Pseudo Attributes . 30 Pseudo Relationships . 31 3.2 Join Operation . 33 Natural Join . 34 Conditional Join . 34 Sorting the Result . 35 3.3 Using SQL Selections . 35 4 Matissse SQL Programmer’s Guide Create an SQL Selection. 35 Select from SQL Selections . 35 Selection Class . 36 Delete a Selection . 37 3.4 Specifying a Search Criteria with WHERE . 37 3.5 Using Attributes in Expressions . 38 Specifying an Attribute in a WHERE Clause . 38 3.6 Combining Predicates with AND and OR . 38 Precedence of Evaluation of AND and OR . 39 3.7 Specifying a Negative Condition with NOT . 40 3.8 Specifying a Type Predicate with IS OF . 41 3.9 Specifying UNFILTERED . 42 3.10 Navigation Filtering with FILTERED . 42 Matching Predicates . 44 Matching Predicates with Composition . 44 Unmatching Predicates . 45 Filtering and Reordering Relationship with REF() . 45 Relationship COUNT. 46 3.11 Getting DISTINCT Values . 47 3.12 Specifying Sort Criteria with ORDER BY . 48 3.13 Filtering with HAVING . 49 Filtering List Type Values . 50 Aggregate Values from SQL Methods. 51 3.14 Grouping with GROUP BY . 53 Grouping by Class. 54 Grouping with Navigation . 54 Grouping by Composition . 55 3.15 Filtering with HAVING in GROUP BY . 56 GROUP BY / HAVING with Navigation . 56 3.16 LIMIT and OFFSET . 58 3.17 Subqueries . 59 Subquery for Comparison . 59 Subquery used with IN . 59 Subquery with EXISTS . 60 3.18 Specifying PARALLEL . 61 4 Using Numeric Values . 62 4.1 Introduction . 62 4.2 Comparison Operators . 62 4.3 Bitwise Operators . 63 4.4 Performing Arithmetic Operations . ..