title: SQL Update Statement based on Procedure in SAP HANA
body: <p>I'm creating an update statement that generate SHA256 for table columns based on table's name</p>
  
  <p>1st Step: I created a procedure that get the table columns, concatenate it all in one columns, then format to a desired format. </p>
  
  <pre><code>-- Procedure code : Extract table's columns list, conctenate it and format it
  
  Create procedure SHA_PREP (in inp1 nvarchar(20))
  as 
  begin
  
  SELECT concat(concat('hash_sha256(',STRING_AGG(A, ', ')),')')  AS Names
  FROM (
      SELECT  concat('to_varbinary(IFNULL("',concat(COLUMN_NAME,'",''0''))')) as A
      FROM    SYS.TABLE_COLUMNS
      WHERE SCHEMA_NAME = 'SCHEMA_NAME' AND TABLE_NAME = :inp1
      AND COLUMN_NAME not in ('SHA')
      ORDER BY POSITION 
      );
  end;
  
  /* Result of this procedures : 
  hash_sha256(
  to_varbinary("ID"),to_varbinary(IFNULL("COL1",'0')),to_varbinary(IFNULL("COL2",'0')) )
  */
  
  -- Update Statement needed 
  
  UPDATE "SCHEMA_NAME"."TABLE_NAME"
  SET "SHA" = CALL "SCHEMA_NAME"."SHA_PREP"('SCHEMA_NAME')
  WHERE "ID" = 99 -- a random filter
  </code></pre>