Jump to main content
HCL Logo Product Documentation
  • Customer Support
HCL OneDB 2.0.1
  • What's new in HCL OneDB™ 2.0.1
  • Getting Started
  • Installing
  • Administering
  • Migrating and upgrading
  • Data warehousing
  • Security
  • Client APIs and tools
  • SQL programming
  • JSON compatibility
  • Extending HCL OneDB™
  • Designing databases
  • Embedding HCL OneDB™
  • Release information
  • Troubleshooting HCL OneDB™
  1. Home
  2. SQL programmingYou can use the HCL OneDB™ implementation of the SQL language to develop applications for HCL OneDB™ database servers.
  3. Guide to SQL: SyntaxThe HCL OneDB™ Guide to SQL: Syntax describes the syntax of the statements, data types, expressions, operators, and built-in functions of the HCL OneDB™ dialect of the SQL language.
  4. Data types and expressionsThese topics describe the data types and expressions that HCL OneDB™supports.
  5. Expression
  6. Function Expressions
  7. Substring functionsThe built-in SQL substring functions return substrings from character string arguments, or return positional information for operations on substrings.
  • SQL programmingYou can use the HCL OneDB™ implementation of the SQL language to develop applications for HCL OneDB™ database servers.
    • Guide to SQL: SyntaxThe HCL OneDB™ Guide to SQL: Syntax describes the syntax of the statements, data types, expressions, operators, and built-in functions of the HCL OneDB™ dialect of the SQL language.
      • Overview of SQL syntax These topics provide an overview about how to use the SQL statements, SPL statements, and syntax segments.
      • SQL statementsThis chapter describes the syntax and semantics of SQL statements that are recognized by HCL OneDB™.
      • SPL statementsThese topics describe Stored Procedure Language (SPL) statements, which you use to write SPL routines. You can store these routines in the database as user-defined routines (UDRs).
      • Data types and expressionsThese topics describe the data types and expressions that HCL OneDB™supports.
        • Scope of Segment Descriptions
        • Use of Segment Descriptions
        • Data type and expression segmentsData type and expression segments can appear in SQL statements.
        • Collection Subquery
        • Condition
        • Data TypeThe Data Type segment specifies the data type of a column, of a component of a collection, of a field within a ROW type, of a routine parameter, or of a value returned by an expression or by a cast function. Use this segment whenever you see a reference to a data type in a syntax diagram.
        • DATETIME Field QualifierUse a DATETIME Field Qualifier to specify the largest and smallest unit of time in a DATETIME column or value. Use this segment whenever you see a reference to a DATETIME Field Qualifier in a syntax diagram.
        • Expression
          • List of ExpressionsEach category of SQL expression includes many individual expressions.
          • Arithmetic Operators
          • Bitwise Logical Functions
          • Concatenation Operator
          • CAST ExpressionsUse the CAST (... AS ...) keywords or the double-colon ( :: ) cast operator to convert the data type of the value of an expression to some other target data type.
          • Column ExpressionsA column expression specifies a data value in a column in the database, or a substring of the value, or a field within a ROW-type column, or a field in a BSON column.
          • Conditional Expressions
          • Constant ExpressionsCertain expressions that return a fixed value are called constant expressions. These include variant function operators that read the system clock, but that are valid in contexts where literal constants are also valid.
          • Constructor Expressions
          • NULL Keyword
          • Function Expressions
            • Algebraic Functions
            • Bitshift Functions Bitshift functions perform a bit shift operation on an integer or bigint value and return the shift result.
            • CARDINALITY FunctionThe CARDINALITY function returns the number of elements in a collection column (SET, MULTISET, LIST).
            • SQLCODE Function (SPL)The SQLCODE function takes no arguments, but returns to its calling context the value of sqlca.sqlcode for the most recently executed SQL statement (whether static or dynamic) that the current SPL routine has executed. Only use SQLCODE in the context of a cursor.
            • DBINFO Function
            • Exponential and Logarithmic Functions Exponential and logarithmic functions take at least one argument and return a FLOAT data type.
            • NVL2 FunctionReturns the second argument when the first argument is not NULL. If the first argument is NULL, the third argument is returned.
            • HEX Function
            • Length functionsUse length functions to determine the length of a character column, string, or variable, or of the value returned by a character expression, or (for CHAR_LENGTH in multibyte locales) the number of logical characters.
            • Security Label Support Functions
            • SIGN functionThe SIGN function returns an indicator of the sign of the argument.
            • Smart-Large-Object FunctionsThe smart-large-object functions support objects of BLOB and CLOB data types:
            • Time FunctionsThe time functions of HCL OneDB™ accept DATE or DATETIME arguments, or character representation of a DATE or DATETIME value. They typically return DATE or DATETIME values, or convert information that they extract from DATE or DATETIME values into character strings or integers.
            • TO_NUMBER FunctionThe TO_NUMBER function can convert a number or a character expression representing a number value to a DECIMAL data type.
            • Trigonometric FunctionsThe built-in trigonometric functions calculate ratios of the lengths of the sides of right triangles. Two supporting functions, DEGREES and RADIANS, can respectively convert the units of angular values from radians to degrees, and from degrees to radians.
            • String-Manipulation FunctionsString-manipulation functions perform various operations on strings of characters.
            • Case-Conversion FunctionsThe case-conversion functions perform lettercase conversion on alphabetic characters. In the default locale, only the ASCII characters in the ranges A - Z and a - z can be modified by these functions, which enable you to perform case-insensitive searches in your queries and to specify the format of the output.
            • Substring functionsThe built-in SQL substring functions return substrings from character string arguments, or return positional information for operations on substrings.
              • CHARINDEX functionThe CHARINDEX function searches a character string for the first occurrence of a target substring, where the search begins at a specified or default character position within the source string.
              • INSTR functionThe INSTR function searches a character string for a specified substring, and returns the character position in that string where an occurrence of that a substring ends, based on a count of substring occurrences.
              • LEFT functionThe LEFT function returns a substring consisting of the leftmost N characters from a string argument.
              • RIGHT functionThe RIGHT function returns a substring consisting of the rightmost N characters from a string argument.
              • SUBSTR function
              • SUBSTRB functionReturns a substring of a string, beginning at a specified position in the string.
              • SUBSTRING function
              • SUBSTRING_INDEX functionThe SUBSTRING_INDEX function searches a character string for a specified delimiter character, and returns a substring of the leading or trailing characters, based on a count of a delimiter that you specify as an argument to the function.
            • FORMAT_UNITS FunctionThe FORMAT_UNITS function can interpret strings that specify a number and the abbreviated names of units of memory or of mass storage.
            • IFX_ALLOW_NEWLINE FunctionThe IFX_ALLOW_NEWLINE function sets a newline mode that allows newline characters in quoted strings or disallows newline characters in quoted strings within the current session.
            • User-Defined FunctionsA user-defined function (UDF) is a routine that you write in SPL or in a language external to the database, such as C or Java™, and that returns a value to its calling context.
          • Statement-Local Variable Expressions
          • Aggregate Expressions
        • OLAP window expressionsYou can include On-Line Analytical Processing (OLAP) expressions in a SELECT statement to operate on subsets of the rows in the result set of a query or subquery. You can use OLAP window expressions to examine subsets of the qualifying rows for patterns, trends, or exceptions in the data.
        • INTERVAL Field Qualifier
        • Literal Collection
        • Literal DATETIME The Literal DATETIME segment specifies a DATETIME value
        • Literal INTERVALThe Literal INTERVAL segment specifies a literal INTERVAL value. Use this whenever you see a reference to a literal INTERVAL in a syntax diagram.
        • Literal Number
        • Literal Row The Literal Row segment specifies the syntax for literal values of named and unnamed ROW data types.
        • Quoted String
        • Relational Operator
      • Other syntax segmentsThese topics describe syntax segments, which are language elements, such as database object names or optimizer directives, that appear as a subdiagram reference in the syntax diagrams of some SQL or SPL statements.
      • Built-in routinesUse build-in routines in SQL statements to perform specialized tasks.
      • Appendixes
    • Guide to SQL: ReferenceThe HCL OneDB™ Guide to SQL: Reference contains the reference information for the system catalog tables, data types, and environment variables of the HCL OneDB™ dialect of the SQL language, as implemented in HCL OneDB™. These topics also include information about the stores_demo, sales_demo, and superstore_demo databases that are included with HCL OneDB™.
    • Guide to SQL: TutorialThe HCL OneDB™ Guide to SQL: Tutorial shows how to use basic and advanced structured query language (SQL) to access and manipulate the data in your databases. It discusses the data manipulation language (DML) statements as well as triggers and stored procedure language (SPL) routines, which DML statements often use.

Substring functions

The built-in SQL substring functions return substrings from character string arguments, or return positional information for operations on substrings.

Substring Functions
(1)
Notes:
  • 1 HCL OneDB™ extension
  • 2 See CHARINDEX function
  • 3 See INSTR function
  • 4 See LEFT function
  • 5 See RIGHT function
  • 6 See SUBSTR function
  • 7 See SUBSTRB function
  • 8 See SUBSTRING function
  • 9 See SUBSTRING_INDEX function

Sections that follow describe the syntax and usage of these substring functions.

  • CHARINDEX function
    The CHARINDEX function searches a character string for the first occurrence of a target substring, where the search begins at a specified or default character position within the source string.
  • INSTR function
    The INSTR function searches a character string for a specified substring, and returns the character position in that string where an occurrence of that a substring ends, based on a count of substring occurrences.
  • LEFT function
    The LEFT function returns a substring consisting of the leftmost N characters from a string argument.
  • RIGHT function
    The RIGHT function returns a substring consisting of the rightmost N characters from a string argument.
  • SUBSTR function
  • SUBSTRB function
    Returns a substring of a string, beginning at a specified position in the string.
  • SUBSTRING function
  • SUBSTRING_INDEX function
    The SUBSTRING_INDEX function searches a character string for a specified delimiter character, and returns a substring of the leading or trailing characters, based on a count of a delimiter that you specify as an argument to the function.

Rate this topic


Comment on this topic.
  • Share: Email
  • Twitter
  • Disclaimer
  • Privacy
  • Terms of use
  • Cookie Preferences