SQLTYPE VARBINARY is nothing else than a short BLOB (i.e. NO conversion).
Original Message:
Sent: Tue March 12, 2024 12:08 PM
From: Juan Garcia
Subject: Retrieve a blob field into a data structure
I'm going to try a SQLTYPE varbinary value
Dcl-s WWEXPSIG SQLTYPE(VARBINARY:32740);
the SQL precompiler transforms it into this
//* DCL-S WWEXPSIG SQLTYPE(VARBINARY:32740);
DCL-S WWEXPSIG VARCHAR(32740) CCSID(*HEX);
I'll post if it works or not
Doesn't work, error occurs with the code RNX1251 when displaying the screen
------------------------------
Juan Garcia
------------------------------
Original Message:
Sent: Tue March 12, 2024 10:13 AM
From: Birgitta Hauser
Subject: Retrieve a blob field into a data structure
It is a generated Binary value! What did you expect?
Another option would be to retrieve the HEX Value (using the HEX built-in-function) ... but I have no idea what it could help, because you cannot use it for everying, except converting it back into the original value.
------------------------------
Birgitta Hauser
Database and Software Engineer
Selfemployed - Modernization-Education-Consulting on IBM i
Kaufering
+49 170 5269964
Original Message:
Sent: Tue March 12, 2024 04:20 AM
From: Juan Garcia
Subject: Retrieve a blob field into a data structure
I have tried TRY_CAST in a debugging session in RDI and this is what it returns:
Eval WWEXPCHAR =
ííù_a7A ÿõü`_I ÷ç¨ Õ5Oµµf9ñ× ýï6×Ãü±b"Â[²» *qú»8}èö²û±îÊ» º2G}ß9hªí*j¹¥Ò j%`ÂñUÙæLÐãL ZG°ÊÅR ¶` ?ô¸q; %¤D·îÒ¨Ðiâ&Hsù \_Ѳ_0/G<LÉ= a:º/ñ̵ç×\àV B|7¦I©´Yï ;äÀ ÒËÏ:á ;äÀ ÒËÏ:á VOX¹Ë(¦¦ÆÃ This is the SQL statement
EXEC SQL
SELECT
Try_Cast(EXPORT_SIGNATURES as CHAR(32000))
INTO :WWEXPCHAR
FROM QSYS2.PROGRAM_INFO
WHERE PROGRAM_NAME = :WWPGMREF.WHFNAM
FETCH FIRST 1 ROWS ONLY;
and the definition of the variable that receives the data is:
Dcl-s WWEXPCHAR CHAR(32000);
------------------------------
Juan Garcia
Original Message:
Sent: Mon March 11, 2024 06:17 PM
From: Birgitta Hauser
Subject: Retrieve a blob field into a data structure
The EXPORT_SIGNATURES is a BINARY value (BLOB) you may try to convert/cast it into a Character_Value using TRY_CAST. Then you can fetch the value into a Character Field. If the binary value cannot be converted a NULL value will be returned
Try_Cast(Export_Signatures as CHAR(32000))
------------------------------
Birgitta Hauser
Database and Software Engineer
Selfemployed - Modernization-Education-Consulting on IBM i
Kaufering
+49 170 5269964
Original Message:
Sent: Mon March 11, 2024 01:24 PM
From: Juan Garcia
Subject: Retrieve a blob field into a data structure
Thanks for the reply
I want to recover the signatures of an SRVPGM, that's why I read the records from the QSYS2.PROGRAM_INFO table and the signatures are in the EXPORT_SIGNATURES field which is BLOB, I can't change the field type but I need to go from blob to characters
------------------------------
Juan Garcia
Original Message:
Sent: Sun March 10, 2024 05:14 AM
From: Birgitta Hauser
Subject: Retrieve a blob field into a data structure
BLOB means Binary Large Object. When using a BLOB the data is taken as it is, so you can save for example a picture or a PDF document or a music stream in a BLOB.
If you want to read, share or save character information, you either need a CLOB (Character Large Object) or a DBCLOB (Double Byte Character Large Objects).
------------------------------
Birgitta Hauser
Database and Software Engineer
Selfemployed - Modernization-Education-Consulting on IBM i
Kaufering
+49 170 5269964