on 06-20-2015 12:46 AM
I've got a table that contains rows having the 'NUL' (x'00') in a varchar string. It's not just that character by itself, but mixed in with other printable ones and the occasional CR or LF. I'm looking for a way to replace these with blanks. I've tried what seems like it should work in SQLscript:
REPLACE(field, x'00', ' ')
...and this does not generate an error, but it doesn't do the replacement either. Checking further it seems that a hex or binary constant isn't being interpreted, so it's not just the sometimes-problematic NUL.
Currently at SPS06, going to SPS09; I can look up my HANA Studio version if that matters...
Thanks In Advance,
Donn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sudhir,
Thanks for the suggestion, but the CASE statement (or, it looks like, SQL-Script in general) still does not accept a binary (hex) string as a parameter. This is typing the SQL into HANA Studio, not using ABAP or any other application that has scripting.
However, I did find a solution:
Use BINTOHEX function to convert the original string (or part of it) to a hex-character string and then compare on that. For example:
where BINTOHEX(field) = '00' will match a NUL string (length 1) while
where field = x'00' does not!
This technique works in CASE and otherwise, so I'm getting the results I was hoping for. I'm going to mark this as 'solved' for now, but I'm open to other comments as to how to make binary(hex) constants work in SQL-script.
Donn
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.