Ingres R3 Opensql Reference Guide
Total Page:16
File Type:pdf, Size:1020Kb
Ingres OpenSQL Reference Guide r3 P00283-1E This documentation and related computer software program (hereinafter referred to as the “Documentation”) is for the end user’s informational purposes only and is subject to change or withdrawal by Computer Associates International, Inc. (“CA”) at any time. This documentation may not be copied, transferred, reproduced, disclosed or duplicated, in whole or in part, without the prior written consent of CA. This documentation is proprietary information of CA and protected by the copyright laws of the United States and international treaties. Notwithstanding the foregoing, licensed users may print a reasonable number of copies of this documentation for their own internal use, provided that all CA copyright notices and legends are affixed to each reproduced copy. Only authorized employees, consultants, or agents of the user who are bound by the confidentiality provisions of the license for the software are permitted to have access to such copies. This right to print copies is limited to the period during which the license for the product remains in full force and effect. Should the license terminate for any reason, it shall be the user’s responsibility to return to CA the reproduced copies or to certify to CA that same have been destroyed. To the extent permitted by applicable law, CA provides this documentation “as is” without warranty of any kind, including without limitation, any implied warranties of merchantability, fitness for a particular purpose or noninfringement. In no event will CA be liable to the end user or any third party for any loss or damage, direct or indirect, from the use of this documentation, including without limitation, lost profits, business interruption, goodwill, or lost data, even if CA is expressly advised of such loss or damage. The use of any product referenced in this documentation and this documentation is governed by the end user’s applicable license agreement. The manufacturer of this documentation is Computer Associates International, Inc. Provided with “Restricted Rights” as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) or DFARS Section 252.227-7013(c)(1)(ii) or applicable successor provisions. 2004 Computer Associates International, Inc. All trademarks, trade names, service marks, and logos referenced herein belong to their respective companies. Contents Chapter 1: Introduction Audience .................................................................................... 1-1 Conventions.................................................................................. 1-1 Chapter 2: Overview of OpenSQL What Is OpenSQL?............................................................................ 2-1 Advantage Enterprise Access Products...................................................... 2-2 Ingres Distributed Option.................................................................. 2-2 Interactive OpenSQL ...................................................................... 2-2 Embedded OpenSQL ...................................................................... 2-2 Building Embedded OpenSQL Programs .................................................... 2-3 Retrieving Status Information .............................................................. 2-3 Specifying Parameters at Runtime .......................................................... 2-3 Differences between Embedded and Interactive OpenSQL .................................... 2-3 Features ..................................................................................... 2-4 Object Names............................................................................. 2-5 Regular and Delimited Identifiers .......................................................... 2-6 Restrictions on Identifiers .................................................................. 2-6 Comment Delimiters ...................................................................... 2-8 Statement Terminators .................................................................... 2-8 Correlation Names ........................................................................ 2-9 Chapter 3: OpenSQL Data Types Character Data Types ......................................................................... 3-2 Character ................................................................................ 3-2 Varchar .................................................................................. 3-3 Long Varchar ............................................................................. 3-3 Contents iii Unicode Data Types ........................................................................... 3-4 Nchar .................................................................................... 3-4 Nvarchar ................................................................................. 3-5 Long Nvarchar ............................................................................ 3-6 Numeric Data Types........................................................................... 3-7 Integer ................................................................................... 3-7 Decimal .................................................................................. 3-8 Floating-point ............................................................................. 3-8 Abstract Data Types ........................................................................... 3-9 Date...................................................................................... 3-9 Money................................................................................... 3-13 Binary Data Types............................................................................ 3-14 Long Byte................................................................................ 3-14 Storage Formats of Data Types ................................................................ 3-15 Literals ...................................................................................... 3-16 String ................................................................................... 3-16 Numeric ................................................................................. 3-16 Floating-point ............................................................................ 3-18 OpenSQL Constants .......................................................................... 3-18 Nulls........................................................................................ 3-19 Nulls and Comparisons ................................................................... 3-19 Nulls and Aggregate Functions ............................................................ 3-19 Chapter 4: Elements of OpenSQL Statements Operators .................................................................................... 4-1 Arithmetic ................................................................................ 4-1 Comparison............................................................................... 4-2 Logical ................................................................................... 4-2 Operations ................................................................................... 4-3 Assignment ............................................................................... 4-3 Arithmetic ................................................................................ 4-5 Functions..................................................................................... 4-8 Function Support for Advantage Enterprise Access Products .................................. 4-8 Scalar .................................................................................... 4-8 Aggregate ............................................................................... 4-27 Ifnull Function ........................................................................... 4-32 UUID ................................................................................... 4-34 Expressions .................................................................................. 4-37 Predicates ................................................................................... 4-37 Like ..................................................................................... 4-38 iv OpenSQL Reference Guide Between................................................................................. 4-39 In....................................................................................... 4-40 Any-or-All .............................................................................. 4-40 Exists ................................................................................... 4-42 Is Null .................................................................................. 4-42 Search Conditions ........................................................................... 4-42 Subqueries .................................................................................. 4-44 Chapter 5: Embedded OpenSQL Syntax of an Embedded OpenSQL Statement .................................................... 5-2 Structure of Embedded OpenSQL Programs..................................................... 5-3 Host Language Variables ...................................................................... 5-4 Declaring Variables ....................................................................... 5-5 The Include Statement ..................................................................... 5-6 Variable Usage...........................................................................