Posts

Showing posts with the label db2

SQL merge minimum time difference

Image
Clash Royale CLAN TAG #URR8PPP SQL merge minimum time difference I'm having trouble with a SQL statement that is a bit over my skill level. Running this in a DB2 datawarehouse. I need to join two columns (CODE1 and CODE2) from TABLE2 into TABLE1 based on some IDs and the minimum time difference between a date in TABLE1 (STARTDATE) and a date in TABLE2 (TIME_SENT). The statement below shows what I'm trying to do, but having issues with ordering of group by and having clause. group by having SELECT * FROM TABLE1 LEFT JOIN (SELECT B.ID1, B.ID2, D.CODE1, D.CODE2 FROM TABLE1 B, TABLE2 D WHERE D.STATUS = '7' GROUP BY B.ID1, B.ID2 HAVING ABS(B.STARTDATE - D.TIME_SENT) = MIN(ABS(B.STARTDATE - D.TIME_SENT)) TABLE2 ON TABLE1.ID1 = TABLE2.ID1 AND TABLE1.ID2 = TABLE2.ID2; Appreciate any help with this. STRUCTURE TABLE1: --------------------------------------------------------- | ID1 (VARCHAR) | ID2 (VARCHAR) | STARTDATE (TIMESTAMP) | --...

Using QCMDEXC to call QEZSNDMG via DB2 stored procedure

Image
Clash Royale CLAN TAG #URR8PPP Using QCMDEXC to call QEZSNDMG via DB2 stored procedure Working on a side project where I use a set of views to identify contention of records within an iSeries set of physical files. What I would like to do once identified is pull the user profile locking the record, and then send a break message to their terminal as an informational break message. What I have found is the QEZSNDMG API. Simple enough to use interactively, but I'm trying to put together a command that would be used in conjunction with QCMDEXC API to issue the call to QEZSNDMG and alert the user that they are locking a record. Reviewing the IBM documentation of the QEZSNDMG API, I see that there are two sets of option parameters, but nothing as required (which seems odd to me, but another topic for another day). But I continue to receive the error "Parameters passed on CALL do not match those required." Here are some examples that I have tried from the command line so far: No...