-- STD-12 is a multi-target orchestration case, not a reusable SQL few-shot.
-- Preserve SG_AI_QA_QUESTION as the customer benchmark; remove only its
-- invalid vector-example row so it cannot be managed as a few-shot.

DECLARE
  v_count PLS_INTEGER;
BEGIN
  SELECT COUNT(*)
    INTO v_count
    FROM sg_qa_vector_example
   WHERE example_id = 51
     AND source_case_id = 'STD-12'
     AND source_type = 'CUSTOMER_QA_BENCHMARK';

  IF v_count <> 1 THEN
    RAISE_APPLICATION_ERROR(-20051, 'Expected exactly one invalid STD-12 few-shot row.');
  END IF;

  DELETE FROM sg_qa_vector_example
   WHERE example_id = 51
     AND source_case_id = 'STD-12'
     AND source_type = 'CUSTOMER_QA_BENCHMARK';

  IF SQL%ROWCOUNT <> 1 THEN
    RAISE_APPLICATION_ERROR(-20052, 'Invalid STD-12 few-shot row was not deleted.');
  END IF;

  COMMIT;
END;
/

SELECT COUNT(*) AS remaining_fewshot_rows
  FROM sg_qa_vector_example
 WHERE example_id = 51;

SELECT COUNT(*) AS preserved_question_rows
  FROM sg_ai_qa_question
 WHERE question_code = 'STD-12';
