pl/sql 脚本在运行简单过程时出现问题

发布于 2025-01-06 19:09:00 字数 1332 浏览 0 评论 0原文

我有一个名为 logger(message) 的存储过程,其中 message 的类型为 varchar2。

当我执行时,

 exec logger('hello'); 

它说匿名块已完成,而该过程所做的只是在另一个表中插入一条记录。

但是,当我将它用作脚本的一部分时,说:

  Begin

    select count(*) into countCol from USER_TAB_COLUMNS where TABLE_NAME = 'EVAPP_INTERFACE_APPENTITY' and COLUMN_NAME = 'ORIGPTI_NUM' and DATA_SCALE is null; 
  IF    (countCol <> 0) then   

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY add ORIGPTI_NUM_TMP NUMBER(14,2)' ; 

 execute immediate 'update EVAPP_INTERFACE_APPENTITY set ORIGPTI_NUM_TMP = ORIGPTI_NUM' ; 

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY drop column ORIGPTI_NUM' ; 

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY rename column ORIGPTI_NUM_TMP to ORIGPTI_NUM' ; 


 DBMS_OUTPUT.put_line('This column EVAPP_INTERFACE_APPENTITY.ORIGPTI_NUM has been modified to the required precision'); 
   END IF; 

  execute logger(' first insert');

我收到此错误说:

  Error report:
  ORA-06550: line 27, column 10:
  PLS-00103: Encountered the symbol "LOGGER" when expecting one of the following:

   := . ( @ % ; immediate
   The symbol ":=" was substituted for "LOGGER" to continue.

我尝试立即执行并仅插入 logger() ,但没有任何效果。

当我尝试在脚本中搜索执行存储过程时,我没有得到谷歌的太多帮助。我如何调用这个过程?

I have a stored procedure called logger(message), where message is of type varchar2.

When I execute just

 exec logger('hello'); 

it says anonymous block completed, and what this procedure does is just insert a record in another table.

However, when I use it as a part of script say:

  Begin

    select count(*) into countCol from USER_TAB_COLUMNS where TABLE_NAME = 'EVAPP_INTERFACE_APPENTITY' and COLUMN_NAME = 'ORIGPTI_NUM' and DATA_SCALE is null; 
  IF    (countCol <> 0) then   

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY add ORIGPTI_NUM_TMP NUMBER(14,2)' ; 

 execute immediate 'update EVAPP_INTERFACE_APPENTITY set ORIGPTI_NUM_TMP = ORIGPTI_NUM' ; 

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY drop column ORIGPTI_NUM' ; 

 execute immediate 'alter table EVAPP_INTERFACE_APPENTITY rename column ORIGPTI_NUM_TMP to ORIGPTI_NUM' ; 


 DBMS_OUTPUT.put_line('This column EVAPP_INTERFACE_APPENTITY.ORIGPTI_NUM has been modified to the required precision'); 
   END IF; 

  execute logger(' first insert');

I get this error saying :

  Error report:
  ORA-06550: line 27, column 10:
  PLS-00103: Encountered the symbol "LOGGER" when expecting one of the following:

   := . ( @ % ; immediate
   The symbol ":=" was substituted for "LOGGER" to continue.

I tried execute immediate and just inserting logger() , but nothing works.

And I haven't had much help with google when I tried searching for execute stored procedure in script. How do I call this procedure?

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

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

发布评论

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

评论(1

网白 2025-01-13 19:09:00

从该行中删除“执行”一词:

logger(' first insert');

Remove the word "execute" from that line:

logger(' first insert');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文