Skip to Content
avatar image
Former Member

How to insert a bytestring into HANA table

Hi! I'm trying to insert a row into my table that is formatted like this:

CREATE TABLE test (COL1 VARBINARY, COL2 VARBINARY)

I tried two insert statements that look like this:

insert into TESTBYTE values(
"b'708ca7fbb701799bb387f2e50deaca402e8502abe229f705693d2d4f350e1ad6'", "b'G\xa2ac\xa0av\xf6'"
);
insert into TESTBYTE values( 
CAST('708ca7fbb701799bb387f2e50deaca402e8502abe229f705693d2d4f350e1ad6'ASVARBINARY), 
CAST('G\xa2ac\xa0av\xf6'ASVARBINARY)
);

The first one errors out as a syntax error and the second seems to be converting the given string into binary again. Is there any way to do this properly? Thank you!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 26, 2017 at 07:44 PM

    Hello Anton,

    as the documentation says binary strings have to be prefix with an X and the binary value has to be enclosed in single quotes (please check paragraph binary string contants in the documentation).

    In addition I think you will not be able to insert your binary value in the table with the current definition. That's because you have not defined a length for the VARBINARY type, so the default is 1 byte (which is to small for the content to be inserted).

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded