Subject | Newlines etc. in string literals |
---|---|
Author | malte_starostik |
Post date | 2003-08-07T12:09:38Z |
Hi,
I've been trying in vain to find a way to insert a string containing
newlines into a varchar field with a plain SQL script (it's
generated, can't use parameters here).
Obviously I first tried things along the lines of 'some\r\ntext' but
that doesn't seem to work.
What does work is to really break the line in the script, but that
confuses the C preprocessor I use to do some macro expansions on the
script :-( Also, I'm looking for something more generic.
I have to admit that I've always disliked how SQL uses it's own
conventions instead of those well known from C, shell etc. when it
comes to special characters ('' instead of \', % instead of *, _
instead of ?), but oh well...
Back to the point. Is there any way to escape an arbitrary character
in a string literal, just like \r\n\e\xff\040 in C-like languages?
TIA,
-Malte
I've been trying in vain to find a way to insert a string containing
newlines into a varchar field with a plain SQL script (it's
generated, can't use parameters here).
Obviously I first tried things along the lines of 'some\r\ntext' but
that doesn't seem to work.
What does work is to really break the line in the script, but that
confuses the C preprocessor I use to do some macro expansions on the
script :-( Also, I'm looking for something more generic.
I have to admit that I've always disliked how SQL uses it's own
conventions instead of those well known from C, shell etc. when it
comes to special characters ('' instead of \', % instead of *, _
instead of ?), but oh well...
Back to the point. Is there any way to escape an arbitrary character
in a string literal, just like \r\n\e\xff\040 in C-like languages?
TIA,
-Malte