For Development HEAD DRAFTSearch (procedure/syntax/module):

12.79 text.sql - SQL parsing and construction

Module: text.sql

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.

Function: sql-tokenize sql-string

{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.

Condition Type: <sql-parse-error>

{text.sql} A condition to indicate an SQL parse error. Inherits <error>.

Instance Variable of <sql-parse-error>: sql-string

Holds the source SQL string.



For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT