prompt create function 'sp_knownode_detach_question...'
create or replace function sp_knownode_detach_question
(
  p_product_id        TypePkg.T_OperatorNo%type,
  p_operator_no        TypePkg.T_OperatorNo%type,
  p_password          TypePkg.T_String%type,
  p_action_in          TypePkg.T_Integer%type,
  p_knownode_id        TypePkg.T_Integer%type,
  p_question_id        TypePkg.T_Integer%type,
  p_mac_address        TypePkg.T_String%type,
  p_error_info    out    TypePkg.T_String%type
)
return number
as
  v_error_no      TypePkg.T_Integer%type;
  v_temp        TypepKg.T_Integer%type;
  v_null        TypePkg.T_String%type;
begin  
  
  -- 校验知识点是否存在
  select count(*) into v_temp
  from emis.knownode
  where know_id = p_knownode_id;
  if v_temp = 0 then
    rollback;
    v_error_no := 232201;
    p_error_info := '[232201]无效的知识点!knownode_id = ' || to_char(p_knownode_id);
      return(v_error_no);
  end if;
  
  -- 校验试题是否存在
  select count(*) into v_temp
  from emis.questionlib
  where question_id = p_question_id;
  if v_temp = 0 then
    rollback;
    v_error_no := 232202;
    p_error_info := '[232202]无效的试题!question_id = ' || to_char(p_question_id);
      return(v_error_no);
  end if;
  
  -- 校验两者是否已经关联
  select count(*) into v_temp
  from emis.knownode2question
  where knownode_id = p_knownode_id
    and question_id = p_question_id;
  if v_temp = 0 then
    return(0);
  else
    delete notenode2question
    where knownode_id = p_knownode_id
      and question_id = p_question_id;
    if SQL%rowcount != 1 then    
      rollback;
      v_error_no := 232203;
      p_error_info := '[232303]知识点关联试题失败!';
      return(v_error_no);
    end if;
  end if;return(0);
commit;
end sp_knownode_detach_question;
/运行结果Warning: Function created with compilation errors