English Français Deutsch

Home Features Demos Download Installation User Manual Developer Manual Credits

Login

Query function

The Query function is depreciated. If you start with Sofawiki, use the Relation function.

The syntax of the query function looks like the SQL syntax, but it works on a more low level

  • All queries are linearized to check only one fields condition
  • The results of the queries are combined in a stack to create more complex queries
  • The expressions use a stack with Reversed Polish Notation
  • A line starting with # is a comment, and all text in this line is ignored

See also Sofawiki Database Primer and Differences between SQL and Sofawiki database

query = (selectstatement | importstatement | datastatement | wherestatement | groupstatement | orderstatement | limitstatement | UNION | exceptstatement | joinstatement | CROSS | COPY | POP | SWAP | projectstatement | ROTATE | renamestatement | formatstatement | numberformatstatement | calcstatement | templatestatement | outputstatement | stylestatement | # | FIELDS | VERBOSE)+

selectstatement = SELECT fieldlist (FROM (VIRTUAL)? name)? (wherestatement | IN valuelist)? (HINT string)?

fieldlist = field (, field)*

valuelist = string (:: string)*

optionlist = option (, value)*

option = parameter: value

name = string

wherestatement = WHERE field (operator string | dollaroperator expression)

operator = (!)? (numericoperator | stringoperator | relaxedstringoperator | otheroperator)

numericoperator = (= | < | > | <= | >=)

stringoperator = (== | =* | *= | *=* | << | >> | >=)

relaxedstringoperator = { ~~ | !~ | ~* | *~ | *~* )

otheroperator = (* | 0 | r= )

dollaroperator = $operator

expression = (field | $field | number | quotedstring | + | - | * | / | . | :: | ABS | SIGN | COPY | POP | SWAP | SUBSTR | REPLACE | TRIM | FUNCTION-function )*

quotedstring = "(.)+(""(.)*)*"

importstatement = IMPORT (TAB | FIELDS) name

datastatement = DATA wikifields

wikifields = ([[field::string]])*

groupstatement = GROUP (fieldaggregation) (, fieldaggregation)* BY fieldlist

fieldaggregation = field (COUNT | SUM | MIN | MAX | AVG | CONCAT)?

orderstatement = ORDER fieldorder (, fieldorder)*

fieldorder = field (NUMERIC)? (DESC)?

limistatement = LIMIT number number

orstatement = UNION

exceptstatement = EXCEPT field

joinstatement = (JOIN | LEFTJOIN | OUTERJOIN) field

projectstatement = PROJECT fieldlist

renamestatement = RENAME (field | * | # ) string (, field string)*

formatstatement = FORMAT field string

numberformatstatement = NUMERFORMAT field (number)? (, field (number)? )*

calcstatement = CALC field expression

templatestatement = TEMPLATE field templatename

outputstatement = OUTPUT (HTML | HTMLPAGED number | LIST | LISTPAGED number | FIXED (fieldlist)? | FIELDS | TAB | TABHEADER | TEXT | TEXTSPACE | ROWTEMPLATE string) | CHART (BAR|LINE|PIE) (optionlist)?

stylestatement = STYLE string

Note on quantificators on this formal definition:
* zero or more
? zero or one
+ one or more