
/* Parameters:  HOBJ ROW COL DTsource DataN TimeStart TimeEnd OffsetSec*/

set	wrap off
set linesize 100
set	feedback off
set	pagesize 0
set	verify off
set termout off

spool d2tmp.sql


prompt set wrap off
prompt set linesize 100
prompt set feedback off
prompt set pagesize 0
prompt set verify off

prompt prompt LOAD DATA
prompt prompt INFILE *
prompt prompt INTO TABLE &5
prompt prompt REPLACE
prompt prompt FIELDS TERMINATED BY '|'
prompt prompt ("ID","ROW","COL","CAS","VALUE","FLAGS","STATUS","ARCHIV_STATUS","LIMIT_STATUS")
prompt prompt BEGINDATA

prompt SELECT &1 || '|' || &2  || '|' ||  &3  || '| ' || (CAS-numtodsinterval(&8,'SECOND')) || '|' || VALUE  || '|' || FLAGS  || '|' || 
prompt BITAND(STATUS,4095)  || '|' ||  BITAND(STATUS,61440)/4096  || '|' ||  BITAND(DECODE(SIGN(STATUS),-1,4294967296+STATUS,STATUS), 4294901760)/65536 
prompt FROM &4 WHERE 
prompt CAS>= TO_DATE('&6','YYYY-MM-DD HH24:MI:SS') AND
prompt CAS<= TO_DATE('&7','YYYY-MM-DD HH24:MI:SS')
select DECODE(&2,0,'','AND "ROWX"=' || &2) || ' ' || DECODE(&3,0,'','AND COL=' || &3)  FROM DUAL;
prompt  /

spool off
set termout on
@d2tmp.sql
exit

