create or replace procedure forum_topics_update(
                 t_t_message varchar2,
                 t_t_subject varchar2,
                 t_cat_id number,
                 t_forum_id number,
                 t_t_mail number:=0,
                 t_topic_id number) is
begin
  if t_cat_id is null or t_forum_id is null then
  UPDATE FORUM_TOPICS SET T_MESSAGE = t_t_message, T_SUBJECT = t_t_subject,t_mail=t_t_mail WHERE TOPIC_ID = t_topic_id;
  else
  UPDATE FORUM_TOPICS SET T_MESSAGE = t_t_message, T_SUBJECT = t_t_subject, CAT_ID = t_cat_id, FORUM_ID = t_forum_id,t_mail=t_t_mail WHERE TOPIC_ID = t_topic_id;
  end if;
  commit; 
end forum_topics_update;我想当t_t_mail传进的值为空时,t_t_mail默认为0,可按照我上面哪样运行,t_t_mail总为空,请问是怎么回事,在线等!!!!!

解决方案 »

  1.   

    改为
                     t_t_mail number default 0,
                     t_topic_id number
      

  2.   

    先我改为DEFAULT 0但也没有,值为空时,它还是不等于0
      

  3.   

    default 0是指当你调用该procedure时,未指定t_t_mail的值时,t_t_mail=0,
    若你指定了值即使是NULL,其值也为NULL。建议使用t_t_mail时利用NVL函数,NVL(t_t_mail,0)
      

  4.   

    :=与default效果一样,没分别.传值时是否对好位置,或者可以采用命名符吧。forum_topics_update(t_t_message=>'1',
                     t_t_subject=>'1',
                     t_cat_id=>1,
                     t_forum_id=>1,
                     t_topic_id=>1)