There is audit trial requirement that need to be captured into log table these day. But we suffer from the limited function provided by Sybase ASE DB in order to achieve our goals. SybaseASE 12.5 does not support neither analytic function nor row number column, and therefore we have to implement cross comparison by ourselves via basic semantics.
12345678910111213
--create rownum columnselectrownum=identity(10),*from#temp_tablefromtablewhere1=2insertinto#temp_tableselect*fromtablewherepid=@pidinsertinto#temp_tableselect*fromtable_historywherepid=@pidorderbyaudit_update_datedesc--use self-join to match the cross rowsselecta.rownum,casewhena.col1=b.col1then'equal'else'inequal'endfrom#temp_tablealeftoutjoin#temp_tablebon(a.pid=b.pidand(a.rownum+1)=b.rownum)where...
In contrast, we also provide oracle version of implementation.