<i id='YO3sp'><tr id='YO3sp'><dt id='YO3sp'><q id='YO3sp'><span id='YO3sp'><b id='YO3sp'><form id='YO3sp'><ins id='YO3sp'></ins><ul id='YO3sp'></ul><sub id='YO3sp'></sub></form><legend id='YO3sp'></legend><bdo id='YO3sp'><pre id='YO3sp'><center id='YO3sp'></center></pre></bdo></b><th id='YO3sp'></th></span></q></dt></tr></i><div id='YO3sp'><tfoot id='YO3sp'></tfoot><dl id='YO3sp'><fieldset id='YO3sp'></fieldset></dl></div>
  • <small id='YO3sp'></small><noframes id='YO3sp'>

    <tfoot id='YO3sp'></tfoot>
    <legend id='YO3sp'><style id='YO3sp'><dir id='YO3sp'><q id='YO3sp'></q></dir></style></legend>
      <bdo id='YO3sp'></bdo><ul id='YO3sp'></ul>

      1. IF EXISTS 条件不适用于 PLSQL

        IF EXISTS condition not working with PLSQL(IF EXISTS 条件不适用于 PLSQL)

        <i id='aoekR'><tr id='aoekR'><dt id='aoekR'><q id='aoekR'><span id='aoekR'><b id='aoekR'><form id='aoekR'><ins id='aoekR'></ins><ul id='aoekR'></ul><sub id='aoekR'></sub></form><legend id='aoekR'></legend><bdo id='aoekR'><pre id='aoekR'><center id='aoekR'></center></pre></bdo></b><th id='aoekR'></th></span></q></dt></tr></i><div id='aoekR'><tfoot id='aoekR'></tfoot><dl id='aoekR'><fieldset id='aoekR'></fieldset></dl></div>

            <small id='aoekR'></small><noframes id='aoekR'>

            <legend id='aoekR'><style id='aoekR'><dir id='aoekR'><q id='aoekR'></q></dir></style></legend>

              • <bdo id='aoekR'></bdo><ul id='aoekR'></ul>
                  <tbody id='aoekR'></tbody>
                  <tfoot id='aoekR'></tfoot>
                • 本文介绍了IF EXISTS 条件不适用于 PLSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图在条件为真时打印文本.选择代码完全正常.当我只运行选择代码时,它显示 403 值.但是当条件存在时我必须打印一些文本.以下代码有什么问题.

                  I am trying to print the TEXT when condition is TRUE. The select code is perfectly working fine. It's showing 403 value when i only run select code. But I have to print some text when condition exists. What's the problem with following code.

                  BEGIN
                  IF EXISTS(
                  SELECT CE.S_REGNO FROM
                  COURSEOFFERING CO
                  JOIN CO_ENROLMENT CE
                    ON CE.CO_ID = CO.CO_ID
                  WHERE CE.S_REGNO=403 AND CE.COE_COMPLETIONSTATUS = 'C' AND CO.C_ID = 803
                  )
                  THEN
                      DBMS_OUTPUT.put_line('YES YOU CAN');
                  END;
                  

                  错误报告如下:

                  Error report:
                  ORA-06550: line 5, column 1:
                  PLS-00103: Encountered the symbol "JOIN" when expecting one of the following:
                  
                     ) , with group having intersect minus start union where
                     connect
                  06550. 00000 -  "line %s, column %s:
                  %s"
                  *Cause:    Usually a PL/SQL compilation error.
                  *Action:
                  

                  推荐答案

                  IF EXISTS() 在语义上不正确.EXISTS 条件只能在 SQL 语句中使用.因此,您可以按如下方式重写 pl/sql 块:

                  IF EXISTS() is semantically incorrect. EXISTS condition can be used only inside a SQL statement. So you might rewrite your pl/sql block as follows:

                  declare
                    l_exst number(1);
                  begin
                    select case 
                             when exists(select ce.s_regno 
                                           from courseoffering co
                                           join co_enrolment ce
                                             on ce.co_id = co.co_id
                                          where ce.s_regno=403 
                                            and ce.coe_completionstatus = 'C' 
                                            and ce.c_id = 803
                                            and rownum = 1
                                          )
                             then 1
                             else 0
                           end  into l_exst
                    from dual;
                  
                    if l_exst = 1 
                    then
                      DBMS_OUTPUT.put_line('YES YOU CAN');
                    else
                      DBMS_OUTPUT.put_line('YOU CANNOT'); 
                    end if;
                  end;
                  

                  或者你可以简单地使用count函数来确定查询返回的行数,以及rownum=1谓词——你只需要知道一条记录是否存在:

                  Or you can simply use count function do determine the number of rows returned by the query, and rownum=1 predicate - you only need to know if a record exists:

                  declare
                    l_exst number;
                  begin
                     select count(*) 
                       into l_exst
                       from courseoffering co
                            join co_enrolment ce
                              on ce.co_id = co.co_id
                      where ce.s_regno=403 
                        and ce.coe_completionstatus = 'C' 
                        and ce.c_id = 803
                        and rownum = 1;
                  
                    if l_exst = 0
                    then
                      DBMS_OUTPUT.put_line('YOU CANNOT');
                    else
                      DBMS_OUTPUT.put_line('YES YOU CAN');
                    end if;
                  end;
                  

                  这篇关于IF EXISTS 条件不适用于 PLSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                • <legend id='tzCMC'><style id='tzCMC'><dir id='tzCMC'><q id='tzCMC'></q></dir></style></legend>

                    <i id='tzCMC'><tr id='tzCMC'><dt id='tzCMC'><q id='tzCMC'><span id='tzCMC'><b id='tzCMC'><form id='tzCMC'><ins id='tzCMC'></ins><ul id='tzCMC'></ul><sub id='tzCMC'></sub></form><legend id='tzCMC'></legend><bdo id='tzCMC'><pre id='tzCMC'><center id='tzCMC'></center></pre></bdo></b><th id='tzCMC'></th></span></q></dt></tr></i><div id='tzCMC'><tfoot id='tzCMC'></tfoot><dl id='tzCMC'><fieldset id='tzCMC'></fieldset></dl></div>
                    <tfoot id='tzCMC'></tfoot>
                    • <bdo id='tzCMC'></bdo><ul id='tzCMC'></ul>

                            <tbody id='tzCMC'></tbody>
                        • <small id='tzCMC'></small><noframes id='tzCMC'>