使用Alter命令的Oracle存储过程 [英] Oracle Stored Procedure with Alter command

查看:375
本文介绍了使用Alter命令的Oracle存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个Oracle存储过程,该存储过程将接受表名作为参数.然后,该过程将重建表上的所有索引.

I am trying to build an Oracle stored procedure which will accept a table name as a parameter. The procedure will then rebuild all indexes on the table.

我的问题是从存储过程中使用ALTER命令时出现错误,好像PLSQL不允许该命令一样.

My problem is I get an error while using the ALTER command from a stored procedure, as if PLSQL does not allow that command.

推荐答案

这里有两种可能.首先,您必须将SQL视为动态SQL.其次,Oracle DDL语句不能在事务中运行(或者,它们终止当前事务并且本身不能回滚).这可能会影响您是否可以在存储过程中使用它们,或在何处使用包含它们的存储过程.

Here are a couple of possibilities. First, you would have to treat the SQL as dynamic SQL. Second, Oracle DDL statements cannot be run in a transaction (or, they terminate the current transaction and cannot themselves be rolled back). This may affect whether you can use them in stored procedures, or where you can use stored procedures that contain them.

如果以上任何一项都不适用-可能容易误入歧途-我建议发布一些代码.

If none of the above apply at all - there could easily be something else astray - I suggest posting some code.

这篇关于使用Alter命令的Oracle存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆