All Manuals > LispWorks® User Guide and Reference Manual > 45 The SQL Package

*use-n-syntax-for-non-ascii-strings* Variable

Summary

Control whether the symbolic SQL syntax uses the N syntax for non-ASCII SQL string literals.

Package

sql

Initial Value

nil

Description

The variable *use-n-syntax-for-non-ascii-strings* controls whether SQL string literals containing non-ASCII characters are put into SQL expressions with the N syntax. When *use-n-syntax-for-non-ascii-strings* is nil (the default), all string literals are produced without the N syntax. When *use-n-syntax-for-non-ascii-strings* is non-nil, non-ASCII string literals are produced with the N syntax.

A non-ASCII string is any string that contains character codes out of the ASCII range 0 to 127.

For example:

(sql:sql-operation '= [name] "hhh<Greek>")
=>
#<SQL-RELATIONAL-EXP "(NAME = 'hhh<Greek>')">
 
(let ((sql:*use-n-syntax-for-non-ascii-strings* t)) 
   (sql:sql-operation '= [name] "hh<Greek>"))
=>
#<SQL-RELATIONAL-EXP "(NAME = N'hh<Greek>')">

For the symbolic SQL "[...]" syntax , the effect of *use-n-syntax-for-non-ascii-strings* occurs at macro expansion time. Therefore, if you use the symbolic SQL syntax and want to make of use *use-n-syntax-for-non-ascii-strings*, then you need to set it before compiling your code.

See 23.5.1.6 SQL string literals for details.

Notes

Microsoft SQL Server is currently the only SQL backend that requires the N syntax.

*use-n-syntax-for-non-ascii-strings* does not affect what sql-expression with :string does.


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:56