INSERT INTO hrm_training_courses (course_code, course_name, course_type, instructor, description, start_date, end_date, duration_hours, is_legal, max_attendees, status, created_by) VALUES (#{courseCode}, #{courseName}, #{courseType}, #{instructor}, #{description}, #{startDate}, #{endDate}, #{durationHours}, #{isLegal}, #{maxAttendees}, 'SCHEDULED', #{createdBy}) UPDATE hrm_training_courses SET course_name=#{courseName}, instructor=#{instructor}, start_date=#{startDate}, end_date=#{endDate}, duration_hours=#{durationHours}, max_attendees=#{maxAttendees}, updated_at=NOW() WHERE id=#{id} INSERT INTO hrm_training_enrollments (emp_id, course_id, status, enrolled_at, created_by) VALUES (#{empId}, #{courseId}, #{status}, NOW(), #{createdBy}) ON CONFLICT (emp_id, course_id) DO NOTHING UPDATE hrm_training_enrollments SET status=#{status}, completed_at=#{completedAt} WHERE id=#{id}