select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1  这条语句作为if条件语句如何拼写组合?if
  select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1  then 报错:Compilation errors for PROCEDURE X_ADS.PRO_REGISTUPError: PLS-00103: 出现符号 "SELECT"在需要下列之一时:
        ( - + case mod new not
          null <an identifier> <a double-quoted delimited-identifier>
          <a bind variable> continue avg count current exists max min
          prior sql stddev sum variance execute forall merge time
          timestamp interval date
          <a string literal with character set specification>
          <a number> <a single-quoted SQL string> pipe
          <一个带有字符集说明的可带引号的字符串文字>
          <一个可带引号的 SQL 字符串> purge
Line: 26
Text: select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1Error: PLS-00103: 出现符号 "="在需要下列之一时:
        . ( * % & - + ; / at for mod
          remainder rem <an exponent (**)> and or group having
          intersect minus order start union where connect || multiset
Line: 26
Text: select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1Compilation errors for PROCEDURE X_ADS.PRO_REGISTUPError: PLS-00103: 出现符号 "SELECT"在需要下列之一时:
        ( - + case mod new not
          null <an identifier> <a double-quoted delimited-identifier>
          <a bind variable> continue avg count current exists max min
          prior sql stddev sum variance execute forall merge time
          timestamp interval date
          <a string literal with character set specification>
          <a number> <a single-quoted SQL string> pipe
          <一个带有字符集说明的可带引号的字符串文字>
          <一个可带引号的 SQL 字符串> purge
Line: 26
Text: select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1Error: PLS-00103: 出现符号 "="在需要下列之一时:
        . ( * % & - + ; / at for mod
          remainder rem <an exponent (**)> and or group having
          intersect minus order start union where connect || multiset
Line: 26
Text: select count(username) from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1

解决方案 »

  1.   

    请问x_ads.f_getgameid()是函数吗?
    请提供函数代码呀?
      

  2.   

    这样可以不。
    select count(username) into l_count from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1;
    if l_count =1 then 
    else
    end if ;
      

  3.   

    对,定义变量,把count(*)的值 赋给变量,然后在进行if判断..
    declare
       para_cnt number ;
    begin
       select count(username) into para_cnt from x_ads.registuser where username=v_registuser and gameid=x_ads.f_getgameid(v_gamecode)=1 ;
    if(para_cnt>0) then 
      dbms_output.put_line('XXXXX');
    end;
    试试看能达到你要求不?