EPOC   SDK Home Glossary Indexes Previous Next Up

SQL statements in EPOC Release 5


Contents


Overview

This is a summary reference of the subset of SQL which is understood by DBMS in EPOC Release 5. The syntax is, in general, standard and, where there are deviations, these are noted.

The grammar notation is similar to that used in the pre-ER5 documentation.


SQL statements

Section Contents


SQL query statements


Select statement


select-statement :
      SELECT select-list
            FROM table-name
            [ WHERE search-condition ]
            [ ORDER BY sort-specification-comma-list ]


SQL schema update statements (DDL)


Create table statement


create-table-statement :
      CREATE TABLE table-name (column-definition-comma-list)


Drop table statement


drop-table-statement :
      DROP TABLE table-name


Alter table statement


alter-table-statement :
      ALTER TABLE table-name
            {
            ADD add-column-set [ DROP drop-column-set ]
            | DROP drop-column-set
            }


Create index statement


create-index-statement :
      CREATE [ UNIQUE ] INDEX index-name ON table-name
      ( sort-specification-comma-list )


Drop index statement


drop-index-statement :
      DROP INDEX index-name FROM table-name


SQL data update statements (DML)


Insert statement


insert-statement :
      INSERT INTO table-name [ ( column-identifier-comma-list ) ]
      VALUES ( column-value-comma-list )


Delete statement


delete-statement :
      DELETE FROM table-name [ WHERE search-condition ]


Update statement


update-statement :
      UPDATE table-name SET update-column-comma-list
      [ WHERE search-condition ]


SQL elements


add-column-set


add-column-set :
      add-column-spec | ( add-column-spec-comma-list )


add-column-spec


add-column-spec :
      column-identifier data-type


boolean-factor


boolean-factor :
      [ NOT boolean-primary ]


boolean-primary


boolean-primary :
      predicate | ( search-condition )


boolean-term


boolean-term :
      boolean-factor [ AND boolean-term ]


column-definition


column-definition :
      column-identifier data-type [ NOT NULL ]


column-identifier


column-identifier :
      user-defined-name


column-value


column-value :
      literal | NULL


comparison-operator


comparison-operator :
      < | > | <= | >= | = | <>


comparison-predicate


comparison-predicate :
      column-identifier comparison-operator literal


data-type


data-type :
      BIT
      | [ UNSIGNED ] TINYINT
      | [ UNSIGNED ] SMALLINT
      | [ UNSIGNED ] INTEGER
      | COUNTER
      | BIGINT
      | REAL
      | FLOAT | DOUBLE [ PRECISION ]
      | DATE | TIME | TIMESTAMP
      | CHAR [ (n) ] | VARCHAR [ (n) ]
      | LONG VARCHAR
      | BINARY [ (n) ] | VARBINARY [ (n) ]
      | LONG VARBINARY


date-literal


date-literal :
      #{exact date expression}#

Notes

Valid date and time expressions are those which can be parsed by the Parse() member function of the TTime class.


digit


digit :
      0 | 1 | 2 | ... 8 | 9


drop-column-set


drop-column-set :
      column-identifier | ( column-identifier-comma-list )


index-name


index-name :
      user-defined-name


letter


letter :
      a | b ... y | z | A | B ... Y | Z


like-predicate


like-predicate :
      column-identifier [ NOT ] LIKE pattern-value


literal


literal :
      string-literal | numeric-literal | date-literal


null-predicate


null-predicate :
      column-identifier IS [ NOT ] NULL


numeric-literal


numeric-literal :
      {exact numeric types}

Notes

Valid numeric forms are those which can be parsed by the Val(TInt64&) and Val(TReal&) member functions of the TLex class.


pattern-value


pattern-value :
      string-literal

Notes

Non SQL-standard characters in the pattern value are used as wildcards:

Standard SQL uses the underscore (_) and percent (%) characters respectively.


predicate


predicate :
      comparison-predicate | like-predicate | null-predicate


search-condition


search-condition :
      boolean-term [ OR search-condition ]


select-list


select-list :
      * | column-identifier-comma-list


sort-specification


sort-specification :
      column-identifier [ ASC | DESC ]


string-literal


string-literal :
      '{character}'

Notes

Character strings can contain any text character. A single quote character (') can be embedded by using two single quote characters.


table-name


table-name :
      user-defined-name


update-column


update-column :
      column-identifier = column-value


user-defined-name


user-defined-name :
      letter [ letter | digit | _ ]...


Mapping SQL types to DBMS types

SQL type

DBMS type

BIT

EDbColBit

TINYINT

EDbColInt8

UNSIGNED TINYINT

EDbColUint8

SMALLINT

EDbColInt16

UNSIGNED SMALLINT

EDbColUint16

INTEGER

EDbColInt32

UNSIGNED INTEGER

EDbColUint32

COUNTER

EDbColUint32, with the TDbCol::EAutoIncrement attribute

BIGINT

EDbColInt64

REAL

EDbColReal32

FLOAT
DOUBLE
DOUBLE PRECISION

EDbColReal64

DATE
TIME
TIMESTAMP

EDbColDateTime

CHAR(n)
VARCHAR(n)

EDbColText, where n specifies a maximum column length

LONG VARCHAR

EDbColLongText

BINARY(n)
VARBINARY(n)

EDbColBinary, where n specifies a maximum column length

LONG VARBINARY

EDbColLongBinary

DECIMAL(p,s)
NUMERIC(p,s)

Not supported

EPOC       SDK Home Glossary Indexes Previous Next Up