2 replies Latest Post - ‏2013-03-06T01:17:46Z by Saruton
111 Posts

Pinned topic Converted blob data to rstring and insert into solidDB, but...

‏2013-02-28T05:27:38Z |
Hi Experts,

I have to save blob data to solidDB, but it doesn't work as expected. As you know, solidDB cannot accept blob data, so I convert blob attribute into rstring by convertFromBlob() built-in function.

<Before the conversion : blob>

<After the Conversion : rstring>

After the conversion, I insert records into solidDB table by ODBCAppend operator (of course, the associated column type is rstring) . I checked the result and found as follows (the associated column name is GNHEADER):

[streamsadmin@myhost Test_Blob_Solid]$ solsql -e 
"select * from mytable" 
"my_solid_db" solid solid IBM solidDB SQL Editor (teletype) - Version: Build 2011-10-14 Copyright Oy International Business Machines Ab 1993, 2011. SOURCEDEVICEID     UDPFWMESSAGEID     GNHEADER --------------     --------------     -------- 1234               4d2.13d1ec66ba8 1234 4d2.13d1ec66f90 1234               4d2.13d1ec67377 3 rows fetched.

GNHEADER column seems empty...
To make sure, I retrieved those records by ODBCRun and converted GNHEADER from rstring to blob by convertToBlob() function and output tuples to a file.


As you can see, GNHEADER values have been missing.
What I mentioned above is incorrect as a way to handle blob attribute?

Could you please tell me the proper way to save blob data to solidDB by SPL application?

I appreciate your help in advance.

  • pcbye
    26 Posts

    Re: Converted blob data to rstring and insert into solidDB, but...

    ‏2013-03-04T19:31:57Z  in response to Saruton

    Just taking a look at the first section of output you have listed, the before/after convertFromBlob - the character field handling in the DB Toolkit operators expect standard null-terminated strings (i.e. they do not operate on bytes). So in your example, the "after the conversion" first byte is \0, which would signal the end of the "string". So my guess is that is why the column is empty when you look at it after ODBCAppend has run.

    I don't think there's a simple way to do what it is you're trying to do in this scenario. If the DB Toolkit handled BLOB column types, that would allow you to write a BLOB directly to the DB, but as you said solidDB does not support that anyway. The only way might be to write your own function to convert the blob to characters (so that "0" was actually a character "0" and not a null).
    • Saruton
      111 Posts

      Re: Converted blob data to rstring and insert into solidDB, but...

      ‏2013-03-06T01:17:46Z  in response to pcbye
      Thanks for your reply!
      I understood. I will convert blob attribute to some types accepted by DB toolkit.

      I have expected that DB toolkit could accepted rstring containing null characters because there were the following description in Information Center.

      Recall from topic Lexical syntax that SPL files are written in UTF-8, so letters such as ñ can also appear directly in a string literal, without the escape sequence. Both ustring and rstring may contain internal null characters, which, unlike in C, are not considered terminating. In other words, characters whose encoding is zero carry no special meaning, and the length of a string is independent from whether or not it contains such characters.

      But this understanding doesn't correspond to the case of DB toolkit, right?