Hi community,
I tried to calculate via an AMDP a binary checksum of a document (see example below). For this I used the hash function hash_sha256(). Now I face the question that I do not want to name every single field of the affected tables, but take all the fields of a table into account. How to achieve this? In MSSQL there is a handy function BINARY_CHECKSUM that does exactly this, but I haven't found a similar function in HANA. Is there something similar planned or how can this be done otherwise?
The example given is already more complex as I do not calculate a single row only, but multiple rows from different sources. Probably also for this there is a better approach than the one I used here.
Thanks,
Renzo
Example:
METHOD mytest BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING ekko ekpo.
declare cursor c for select hash_sha256( to_binary(ebeln), to_binary(ebelp), to_binary(matnr) ) as hash FROM ekpo
WHERE mandt = session_context('CLIENT')
AND ebeln = p_purchaseorder
ORDER BY ebelp;
declare lt_hash table( hash varbinary(32) );
declare lv_hash varbinary(32);
lt_hash = SELECT hash_sha256( to_binary(ebeln), to_binary(bukrs), to_binary(bstyp), to_binary(bsart) ) as hash FROM ekko
WHERE mandt = session_context('CLIENT')
AND ebeln = p_purchaseorder;
FOR r as c DO
select hash into lv_hash from :lt_hash;
lt_hash = SELECT hash_sha256( lv_hash, r.hash ) as hash FROM dummy;
END for;
RETURN SELECT session_context('CLIENT') as Client, hash as HashValue FROM :lt_hash;
ENDMETHOD.