Reputation: 5401
I can hardly believe I need to ask this, but there really doesn't seem to be any documentation on it in the HSQLDB documentation.
What's the way to put a newline into a string literal for HSQLDB (it's part of a test data set I'm using). I have a statement like:
INSERT INTO "RANDOM_TABLE" ("TEXT_VALUE")
VALUES ('BRAF >> V600E (73%)\nPIK3CA >> E545G (31%)');
And I'd really like the \n
or equivalent to be a newline character. Except, of course \n
just passes through as is.
Upvotes: 3
Views: 942
Reputation: 10860
SQL Server has a CHAR function to let you insert a character by ASCII character number.
Character 13 is for Line Feed and 10 is Carriage Return. Sometimes you need one and sometimes you need both.
INSERT INTO "RANDOM_TABLE" ("TEXT_VALUE")
VALUES ('BRAF >> V600E (73%)' + CHAR(13) + CHAR(10) + 'PIK3CA >> E545G (31%)');
Upvotes: 2
Reputation: 3280
I admit this was surprisingly hard to google, but this worked for me:
CREATE TABLE baz (
col VARCHAR(255)
);
INSERT INTO baz
VALUES (U&'foo\000Abar');
Of course depending on your platform you may want to use \000A, \000D or \000D\000A (respectively: LF, CR or LF followed by CR).
By the way, credits to this post: Hsqldb single quote character
Upvotes: 4