Starcounter
HomeDownloadDocsCommunity
2.3.1
2.3.1
  • Starcounter Documentation
  • Getting Started
  • Starcounter
    • Collapsing the Stack
      • Complexity and Scalability Tradeoff
      • The Future of Micro-Services
      • 10 Benefits of Collapsing the Stack
    • Integrated Database and Web Server
  • Hello World - Tutorial
    • Create a Database Class
    • Create a Real Time UI
    • First Interactive UI
    • Computed Properties
    • Expense Tracker
    • Cancel and Delete
    • The Next Step
  • Guides
    • Database
      • Database Classes
      • Data manipulation
      • Object Identity and Object References
      • Querying with SQL
      • Data Types
      • Relations
      • Inheritance
      • Sharing data
      • Database Configuration
      • Comparing Database Objects
      • Referential Integrity and Constraints
    • SQL
      • Identifiers
      • Path Expressions
      • Data operators
      • Joins
      • Aggregates
      • Comparisons and Logical Operators
      • Sorting
      • Fetch
      • Offset Key
      • Indexes
      • Literals
      • Query Plan Hints
      • Reserved words
      • Query for Database Classes
      • SQL Isolation Between Applications
    • Transactions
      • Short-Running Transactions
      • Long running transactions
      • Using Transactions
      • Running Background Jobs
      • Commit Hooks
    • Typed JSON
      • JSON-by-example
      • Code-Behind
      • Data Bindings
      • Callback Methods
      • Responding with JSON
      • Accepting JSON in Requests
      • Primitive Arrays and Single Value Types
      • Typed JSON Internals
    • Blendable Web Apps
      • Starcounter MVVM
      • Palindrom
      • Client-Side Stack
      • Sessions
      • HTML Views
      • App Shell
      • Web Components
      • View Attaching
      • View Composing
      • HTML Compositions
      • HTML Views Blending Guidelines
      • Avoiding CSS conflicts
      • Debugging
    • Network
      • HTTP
      • Internal Self Calls
      • Middleware
      • Anonymous or Substitute Handlers
      • URL Aliases and Redirects
      • Network Gateway
      • Static File Server
      • External HTTP Calls
      • WebSocket
      • Avoiding URI conflicts
      • TCP Sockets
      • UDP Sockets
    • Publishing Apps
    • Working with Starcounter
      • Release Channels
      • Starting and Stopping Apps
      • Administrator Web UI
      • Star CLI
      • StarAdmin CLI
      • StarDump CLI
      • Working in Visual Studio
      • Error Log
      • Using HTTPS on NGINX
      • Using HTTPS on IIS
      • Run Starcounter in Production
      • Weaver
      • Investigating App Crashes
      • Configuration Structure
      • Database Refactoring
      • Using Unload/Reload to Modify Database Schema
      • Kernel Questions and Answers
      • Log Files
  • Cookbook
    • Attach an HTTP Request to an Existing Long-Running Transaction
    • Cookie-Based Authentication
    • Timestamp on Object Creation
    • Creating Strongly Typed JSON Collections
    • Migrating From 2.2 to 2.3+
    • Multiple Pages
    • Icons
    • Proposed Project Structure
    • Acceptance Testing with Selenium
    • Requesting a User to Authenticate
    • How to delete unused tables and columns
Powered by GitBook
On this page
  • Introduction
  • Boolean
  • Numeric
  • String
  • Date-time
  • Binary
  • Object
  1. Guides
  2. SQL

Literals

Introduction

Literals are used for queries in the Administrator, they can also be used instead of variables in programming code with Db.SlowSQL although, this comes with a heavy performance penalty.

Boolean

A boolean literal can have one of the two values true and false, which are represented by the two reserved words TRUE and FALSE. See example below.

SELECT e FROM Employee e WHERE e.Commission = TRUE

Numeric

There are three types of numerical literals Int64, Decimal and Double.

An Int64 literal is described by its integer value, as in example below.

SELECT e FROM Employee e WHERE e.Salary = 5000

A Decimal literal is described by its numerical value including a decimal point, as in example below.

SELECT e FROM Employee e WHERE e.Salary = 5000.00

A Double literal is described by two numerical values, the mantissa and the exponent, separated by the character E. The mantissa may include a decimal point, but the exponent may not. See example below.

SELECT e FROM Employee e WHERE e.Salary = 5.0E3

String

A string literal is a sequence of characters beginning and ending with single quote characters. To represent a single quote character within a String literal, you write two consecutive single quote characters, as in example below.

SELECT p FROM Photo p WHERE p.Description = 'Smith''s family'

Date-time

A date-time literal is either described by the reserved word DATE followed by a String literal of the form yyyy-mm-dd, the reserved word TIME followed by a String literal of the form hh:mm:ss[.nnn] (the specification of milliseconds is optional), or the reserved word TIMESTAMP followed by a String literal of the form yyyy-mm-dd hh:mm:ss[.nnn]. See examples below.

SELECT e FROM Employee e WHERE e.HireDate = DATE '2006-11-01'
SELECT e FROM Employee e WHERE e.HireDate = TIMESTAMP '2006-11-01 00:00:00'

Note that all date-time literals in fact are timestamps, which means that the date-time literal in the first query above does not represent the date '2006-11-01' but in fact the first millisecond of that date '2006-11-01 00:00:00.000'. Consequently, above examples are equivalent.

Binary

A binary literal is described by the reserved word BINARY and the binary value represented by a Hexadecimal string, as in example below.

SELECT d FROM Department d WHERE d.BinaryId = BINARY 'D91FA24E19FB065A'

Object

Since Starcounter SQL supports object references, you also need a way to represent an object reference to a specific object, i.e. an object literal. Every object in a Starcounter database can be identified by its unique object-id-number. You describe an object literal by the reserved word OBJECT followed by the object's object-id-number, as in example below.

SELECT e FROM Employee e WHERE e = OBJECT 123
PreviousIndexesNextQuery Plan Hints

Last updated 7 years ago