oracle中存储过程中使用 if else 为什么会调用出错

create or replace procedure PCInsertOrUpdateMsg(

     companyId varchar2 :='1',
     personId varchar2 :='6',
     resume_name varchar2 :='简历1',
     msg varchar2 := ''

)
as

BEGIN
IF  not exists (select 1 from t_person_company where person_id = personId and resume_name = resume_name and company_id = companyId and company_to_person = '1' and  success = '1')  THEN
 insert into t_person_company values (company_id = companyId,person_id = personId,company_to_person = '1',success = '1' ,msg,sysdate,resume_name = resume_name,null);
ELSE
 update t_person_company set message = msg , company_to_person = '1' where person_id = personId and company_id = companyId and resume_name = resume_name and success = '1');
END IF;
    END;
    /

图片说明

请各位大神门帮忙看下,oracle中的 if else 到底怎么用。感激不尽!

3个回答

是不是else后面少半个括号

create or replace procedure PCInsertOrUpdateMsg(

                                                companyId   varchar2 := '1',
                                                personId    varchar2 := '6',
                                                resume_name varchar2 := '简历1',
                                                msg         varchar2 := '') as
  v_count integer;
BEGIN
  select count(1)
    into v_count
    from t_person_company
   where person_id = personId
     and resume_name = resume_name
     and company_id = companyId
     and company_to_person = '1'
     and success = '1';
  IF v_count > 0 THEN
    insert into t_person_company
    values
      (company_id = companyId,
       person_id = personId,
       company_to_person = '1',
       success = '1',
       msg,
       sysdate,
       resume_name = resume_name,
       null);
  ELSE
    update t_person_company
       set message = msg, company_to_person = '1'
     where person_id = personId
       and company_id = companyId
       and resume_name = resume_name
       and success = '1');
  END IF;
END;

注意sql语句中的空格

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问