How can I insert single quote character to Hsqldb table? Escape character doesn't work for the problem.
相关问题
- Syntax issue with HSQL sequence: `NEXTVAL` instead
- Inspect Hsqldb Schema
- Upserting a row into an hsqldb table using the MER
- Hibernate connection with HSQLDB
- Hibernate entity only one column, no name
相关文章
- “correct” way to select next sequence value in HSQ
- How to connect to HSQL which Spring creates when j
- net.ucanaccess.jdbc.UcanaccessSQLException: attemp
- HSQLDB cryptic exception message: “feature not sup
- Clojure jdbc create-table statement does not run u
- HsqlException: data exception
- org.hsqldb.HsqlException: user lacks privilege or
- Startup script to create a schema in HSQLDB
The question is old, but I found the answer by fredt but it led me astray because it doesn't actually do what the original poster requested which is insert a single quote. Instead it inserts escap'd which is not what I wanted to do.
This may have been the only way in the past (Fred would know better than me), but the easiest way in hsqldb to insert a single quote now is to just make a prepared statement in java (p_insert) and set the String:
p_insert.setString(1,"'"); p_insert.executeUpdate();
This will actually put a single quote in the database, at least in version 2.3.2. To retrieve it from the database, you will need to use double single quotes in your SELECT statement.
There are two ways.
Use two single quotes. For example
INSERT INTO T VALUES 'escap''d'
Use a Unicode string, which can contain a Unicode escape. For example
INSERT INTO T VALUES U&'escap\0027d'
Both examples insert the string
escap'd
into the table.