title: Check what procedure modified data in IBM Netezza
body: <p>I found that Netezza stores history of data in HISDB schema. Is it possible to join them so I would get history of which table has been modified by what procedure?</p>
  
  <p>Reason for this is I have DataStage job that loads Netezza table and after SQL command triggers procedures that add another set of data to that same table. I am in need to have all events documented for data lineage purpose.</p>
  
  <p>Current query I made returns procedure's call time. Issue is with joining to <code>USER_HISTDB."$hist_table_access_3"</code>. The only field that matched is <code>NPSINSTANCEID</code>. <code>LOGENTRYID</code>, <code>OPID</code> and <code>SESSIONID</code> have different value.</p>
  
  <p>That stops me from making procedure to table link.</p>
  
  <pre><code>SELECT 
  b.SUBMITTIME,
  b.QUERYTEXT,
  b.USERNAME,
  b.DBNAME,
  b.SCHEMANAME,
  a.*
  FROM USER_HISTDB."$hist_log_entry_3" a
  JOIN USER_HISTDB."$hist_query_prolog_3" b
  ON a.LOGENTRYID = b.LOGENTRYID
  AND a.SESSIONID = b.SESSIONID 
  AND a.NPSID = b.NPSID
  AND a.NPSINSTANCEID = b.NPSINSTANCEID
  
  WHERE b.QUERYTEXT like '%PROCEDURE_NAME%'
  </code></pre>