text.sql
- SQL parsing and construction ¶This module provides a utility to parse and construct SQL statement.
It is currently under development, and we only have a tokenization routine. The plan is to define S-expression syntax of SQL and provides a routine to translate one form to the other.
Note: If you’re looking for a routine to escape strings to be
safe in SQL, see dbi-escape-sql
in DBI user API.
{text.sql
}
Tokenize a SQL statement sql-string. The return value is
a list of tokens, where each token is
represented by one of the following forms.
<symbol> Special delimiter. One of the followings: + - * / < = > <> <= >= || <character> Special delimiter. One of the followings: #\, #\. #\( #\) #\; <string> Regular identifier (delimited <string>) Delimited identifier (parameter <num>) Positional parameter (?) (parameter <string>) Named parameter (:foo) (string <string>) Character string literal (number <string>) Numeric literal (bitstring <string>) Binary string. <string> is like "01101" (hexstring <string>) Binary string. <string> is like "3AD20"
If it encounters an untokenizable string, it raises an
<sql-parse-error>
condition.