-- A no-target aggregate is a successful empty-value result, not a no-row
-- execution failure. Keep the output alias from the verified logical metric.

DECLARE
  v_input CLOB;
  v_embedding VECTOR;
BEGIN
  SELECT TO_CLOB('Question: ') || question
      || TO_CLOB(CHR(10) || 'Answer SQL: SELECT CAST(NULL AS NUMBER) AS "USER_COUNT" FROM DUAL')
      || TO_CLOB(CHR(10) || 'Answer: This boundary applies only to a game-scoped user-master operation. '
          || 'When no game identifier is resolved, do not select a prefix-specific user-master object. '
          || 'Return USER_COUNT as NULL. This does not prohibit an approved common-object query.')
    INTO v_input
    FROM sg_qa_vector_example
   WHERE example_id = 5;
  v_embedding := DBMS_VECTOR.UTL_TO_EMBEDDING(
    v_input,
    JSON(sg_qa_vector_params('search_document'))
  );

  UPDATE sg_qa_vector_example
     SET answer_sql = 'SELECT CAST(NULL AS NUMBER) AS "USER_COUNT" FROM DUAL',
         answer_text = 'This boundary applies only to a game-scoped user-master operation. '
             || 'When no game identifier is resolved, do not select a prefix-specific user-master object. '
             || 'Return USER_COUNT as NULL. This does not prohibit an approved common-object query.',
         embedding_input = v_input,
         embedding = v_embedding,
         embedding_model = 'cohere.embed-v4.0',
         inspection_note = 'Canonical GAME_USER_MASTER boundary: no game target returns a NULL metric value, '
             || 'not an execution error and not a default game selection.',
         verified_at = SYSTIMESTAMP,
         verified_by = 'SGMP_POC_REVIEW'
   WHERE example_id = 5
     AND reference_status = 'APPROVED'
     AND reference_kind = 'NO_TARGET'
     AND object_role = 'GAME_USER_MASTER';
  COMMIT;
END;
/
