cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Converting VARBINARY(16) type value to string in MTA for READ operation

sagar17
Discoverer
0 Likes
2,062

Hi All,

I am new to cloud application programming and facing a strange issue.

I have table in Hana container which have field "Key" with type VARBINARY(16). Now I am trying to read the record from this table in my MTA application using normal read. I need to pass this Key to another select query.

When I am getting this record in console the Key field showing value like <Buffer 00 50 56 ac 42> and then I am trying to pass this value to another Select query I am getting error "Error: Cannot build SELECT.columns()".

As per me, I need to convert this key value in to normal string before passing to new Select query.

Is anyone faced such issue or How to convert the value to pass it to another Select query ?

Accepted Solutions (1)

Accepted Solutions (1)

sagar17
Discoverer
0 Likes

I got the solution, The entity is returning buffer object and as David mentioned NodeJs Buffer can be convert to String using toString(). I tried was trying it earlier but it was not giving me right conversion. But then I found different encodings which are :

'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'

Out of these correct encoding which helped me is 'hex'. So the final conversion which I used is as below :

data.toString('hex');

So that's the simple solution 🙂

Answers (0)