PLS-00103 程序错误

发布于 2024-11-01 18:34:49 字数 1998 浏览 0 评论 0原文

我有 2 台服务器(一台用于测试,一台用于生产),两台服务器都有以下 Oracle 软件包(两台服务器的 SELECT * FROM V$VERSION; 的输出相同:

Oracle9i Enterprise Edition Release 9.2.0.3 .0 - 生产
PL/SQL 版本 9.2.0.3.0 - 生产
CORE 9.2.0.3.0 生产
适用于 Linux 的 TNS:版本 9.2.0.3.0 - 生产
NLSRTL 版本 9.2.0.3.0 - 生产

奇怪的是,它在一台服务器上运行良好,但在另一台服务器上却出现这些错误...我应该在哪里查看?看来是服务器配置问题。

我正在尝试编译此过程:

CREATE OR REPLACE PROCEDURE P_A1 AS  
  NUMAR INTEGER := 0;  
  CURSOR A1_C3 IS  
    SELECT   
(SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A  
      FROM APP_COMPANY_ALL CO, A1_A D  
     WHERE D.YR_R = y.APPL_admin.F$APPL_YEAR  
       AND D.MON_R = y.APPL_admin.F$APPL_MONTH  
       AND d.cif=SUBSTR(RTRIM(CO.c_fisc),3);  
  V_A1 A1_C3%ROWTYPE;  

 BEGIN  
  NULL;  
END;  

我在其中一台服务器上收到以下错误:
PROCEDURE P_A1 的编译错误

Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:

          ( - + case mod new not null others <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> 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
Text: (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A

Error: PLS-00103: Encountered the symbol ")" when expecting one of the following:

          . ( * @ % & - + ; / at for mod rem <an exponent (**)> and or
          group having intersect minus order start union where connect
          ||
Text: (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A

正如我所说,它可以在测试服务器上运行,但不能在生产服务器上运行。 Oracle 版本是相同的。我很确定这是导致此问题的配置选项。但我不知道去哪里寻找解决方案。

如果“Select ( Select ...”不是标量子查询,它就可以正常工作。当它位于游标内时,它会失败。为什么它在生产服务器上不起作用?

I have 2 servers (one for testing, one for production), both have the following Oracle packages (identical output on both of them for SELECT * FROM V$VERSION; :

Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
PL/SQL Release 9.2.0.3.0 - Production
CORE 9.2.0.3.0 Production
TNS for Linux: Version 9.2.0.3.0 - Production
NLSRTL Version 9.2.0.3.0 - Production

The strange thing is that it works just fine on one server and it gives these errors on the other one... Where should I look? It seems it's a server configuration problem.

I'm trying to compile this procedure:

CREATE OR REPLACE PROCEDURE P_A1 AS  
  NUMAR INTEGER := 0;  
  CURSOR A1_C3 IS  
    SELECT   
(SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A  
      FROM APP_COMPANY_ALL CO, A1_A D  
     WHERE D.YR_R = y.APPL_admin.F$APPL_YEAR  
       AND D.MON_R = y.APPL_admin.F$APPL_MONTH  
       AND d.cif=SUBSTR(RTRIM(CO.c_fisc),3);  
  V_A1 A1_C3%ROWTYPE;  

 BEGIN  
  NULL;  
END;  

I get the folowing errors on one of the servers:
Compilation errors for PROCEDURE P_A1

Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:

          ( - + case mod new not null others <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> 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
Text: (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A

Error: PLS-00103: Encountered the symbol ")" when expecting one of the following:

          . ( * @ % & - + ; / at for mod rem <an exponent (**)> and or
          group having intersect minus order start union where connect
          ||
Text: (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A

The thing is that, as I said, it works on the test server, but not on the production server. The Oracle versions are identical. I am pretty sure it's a configuration option that's causing this problem. But I don't know where to look for a solution.

The "Select ( Select ..." works just fine if it's not a scalar subquery. It fails when it's inside the cursor. Why doesn't it work on the production server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

临走之时 2024-11-08 18:34:49

这可能只是一个剪切粘贴问题,但在原始帖子中,光标以

SELECT (SELECT...

我认为不起作用的方式开始。我建议您尝试以下操作:

CREATE OR REPLACE PROCEDURE P_A1 AS
  NUMAR INTEGER := 0;
  CURSOR A1_C3 IS
    SELECT x_A.PAY_SUM
      FROM (SELECT SUM(D1.A_PAY) AS PAY_SUM
              FROM A1_A D1
              WHERE D1.YR_R = D.YR_R AND
                    D1.MON_R = D.MON_R) x_A
      INNER JOIN A1_A A D
        ON (D.YR_R = y.APPL_admin.F$APPL_YEAR AND
            D.MON_R = y.APPL_admin.F$APPL_MONTH)
      INNER JOIN APP_COMPANY_ALL CO
        ON (SUBSTR(RTRIM(CO.c_fisc),3) = D.CIF);
  V_A1 A1_C3%ROWTYPE;
BEGIN
  NULL;
END P_A1; 

分享并享受。

This may just have been a cut-n-paste issue, but in the original post the cursor starts with

SELECT (SELECT...

which I don't think will work. I suggest that you try the following:

CREATE OR REPLACE PROCEDURE P_A1 AS
  NUMAR INTEGER := 0;
  CURSOR A1_C3 IS
    SELECT x_A.PAY_SUM
      FROM (SELECT SUM(D1.A_PAY) AS PAY_SUM
              FROM A1_A D1
              WHERE D1.YR_R = D.YR_R AND
                    D1.MON_R = D.MON_R) x_A
      INNER JOIN A1_A A D
        ON (D.YR_R = y.APPL_admin.F$APPL_YEAR AND
            D.MON_R = y.APPL_admin.F$APPL_MONTH)
      INNER JOIN APP_COMPANY_ALL CO
        ON (SUBSTR(RTRIM(CO.c_fisc),3) = D.CIF);
  V_A1 A1_C3%ROWTYPE;
BEGIN
  NULL;
END P_A1; 

Share and enjoy.

复古式 2024-11-08 18:34:49

在比较两个服务器方面可能值得检查几个初始化参数:

plsql_optimize_level
兼容

这些差异可能会在服务器之间产生不同的行为。您可以通过将其更改为动态 SQL 来验证可能是解析器问题的建议:

open my_cursor for 
     'SELECT   
           (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A  
      FROM APP_COMPANY_ALL CO, A1_A D  
     WHERE D.YR_R = :1 
       AND D.MON_R = :2
       AND d.cif=SUBSTR(RTRIM(CO.c_fisc),3)'  using y.APPL_admin.F$APPL_YEAR , y.APPL_admin.F$APPL_MONTH  

Might be worth checking a couple initialization parameters in terms of comparing the two servers:

plsql_optimize_level
compatible

Differences in these could yield different behavior between servers. You can validate the suggestion that it might be the parser issue by changing it to dynamic SQL along the lines of:

open my_cursor for 
     'SELECT   
           (SELECT SUM(D1.A_PAY) FROM A1_A D1 WHERE D1.YR_R = D.YR_R AND D1.MON_R = D.MON_R) x_A  
      FROM APP_COMPANY_ALL CO, A1_A D  
     WHERE D.YR_R = :1 
       AND D.MON_R = :2
       AND d.cif=SUBSTR(RTRIM(CO.c_fisc),3)'  using y.APPL_admin.F$APPL_YEAR , y.APPL_admin.F$APPL_MONTH  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文