i need to output a message saying "matched" or "not an employee" in a column using xquery. I'm using 4444 as a placeholder for now, dont know how to iterate through within the query
SELECT
EXTRACTVALUE(B.JOBSHEET_DETAILS, '/jobSheet[@jobNo]/@jobNo') AS "JOB_DETAILS_ID",
XMLQUERY(' for $j in /jobSheet/employee[@empNo]/@empNo
let $msg := if ($j) then "Employee details match a current employee" else "Error in employee details (no match)"
where $j = 4444
return $msg
'
PASSING B.JOBSHEET_DETAILS
RETURNING CONTENT ).getstringval() AS "CHECK_EMP_DETAILS" ,
EXTRACTVALUE(B.JOBSHEET_DETAILS, '/jobSheet/employee[@empNo]/@empNo') AS "EMP_NO",
EXTRACTVALUE(B.JOBSHEET_DETAILS, '/jobSheet/employee/empName') AS "EMP_NAME",
EXTRACTVALUE(B.JOBSHEET_DETAILS, '/jobSheet/dateAttend/date') AS "DATE_ATTENDED"
FROM JOBSHEET_XML_TAB B
where XMLEXISTS('/jobSheet/employee[@empNo]/@empNo' passing B.JOBSHEET_DETAILS);
for one, the else inside xmlquery doesnt trigger. it outputs (null) when it should be an error.
I need to check all employees if the $j in this iterations is an existing employee or not. $j = 4444 is it possible to do another select count(*)from emp where no = $num.