查询以包括spring批处理作业参数值和作业执行数据

byqmnocz  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(305)

对于spring批处理作业,我有如下作业参数 requestName & responseId 哪个在 BATCH_JOB_EXECUTION_PARAMS table。

JOB_EXECUTION_ID | KEY_NAME | STRING_VAL 
2   |             responseId             | f5e1b3e9
2   |             requestName            | DUMMY

我正在通过以下查询检索有关作业执行的详细信息:

SELECT je.JOB_EXECUTION_ID, 
       je.START_TIME, 
       je.END_TIME, 
       je.STATUS, 
       je.EXIT_CODE, 
       je.EXIT_MESSAGE, 
       ji.JOB_INSTANCE_ID, 
       ji.JOB_NAME,
       --add requestName STRING_VAL
FROM BATCH_JOB_EXECUTION je
INNER JOIN BATCH_JOB_EXECUTION_PARAMS p ON je.JOB_EXECUTION_ID = p.JOB_EXECUTION_ID
INNER JOIN BATCH_JOB_INSTANCE ji ON je.JOB_INSTANCE_ID = ji.JOB_INSTANCE_ID
WHERE p.KEY_NAME = 'responseId' AND p.STRING_VAL = 'f5e1b3e9'

如何填充 requestName 在我的询问中?因此,对于jobExecutionID2,它将返回一个额外的列 REQUEST_NAME 有价值的 DUMMY

h79rfbju

h79rfbju1#

@mo6h只是加入另一个 BATCH_JOB_EXECUTION_PARAMS 这样地:

SELECT je.JOB_EXECUTION_ID, 
   je.START_TIME, 
   je.END_TIME, 
   je.STATUS, 
   je.EXIT_CODE, 
   je.EXIT_MESSAGE, 
   ji.JOB_INSTANCE_ID, 
   ji.JOB_NAME,
   p2.STRING_VAL AS `REQUEST_NAME` -- add requestName STRING_VAL
FROM BATCH_JOB_EXECUTION je
INNER JOIN BATCH_JOB_EXECUTION_PARAMS p ON je.JOB_EXECUTION_ID = p.JOB_EXECUTION_ID
INNER JOIN BATCH_JOB_INSTANCE ji ON je.JOB_INSTANCE_ID = ji.JOB_INSTANCE_ID
JOIN BATCH_JOB_EXECUTION_PARAMS AS p2 ON p2.JOB_EXECUTION_ID = p.JOB_EXECUTION_ID        
WHERE p.KEY_NAME = 'responseId' 
    AND p.STRING_VAL = 'f5e1b3e9'
    AND p2.KEY_NAME = 'requestName'

请让我知道如果这不做你想要的,我会努力帮助进一步。

相关问题