|
请问在oracle9.2中可否在存储过程中增加表的字段,字段名由参数给定。
下面的命令可以执行,
- ALTER TABLE table_name ADD col_name col_type;
复制代码
但相应的存储过程(DEPT、VARCHAR2(200)分别是我的表名和新字段的类型)
- create or replace procedure ADD_COLUMN(COL_NAME IN VARCHAR2) is
- begin
- ALTER TABLE DEPT ADD COL_NAME VARCHAR2(100);
- end ADD_COLUMN;
复制代码
在创建时报错:
- Compilation errors for PROCEDURE DEV.ADD_COLUMN
- Error: PLS-00103: 出现符号 "ALTER"在需要下列之一时:
- begin case declare exit
- for goto if loop mod null pragma raise return select update
- while with <an identifier>
- <a double-quoted delimited-identifier> <a bind variable> <<
- close current delete fetch lock insert open rollback
- savepoint set sql execute commit forall merge
- <a single-quoted SQL string> pipe
- Line: 3
- Text: ALTER TABLE DEPT ADD COL_NAME VARCHAR2(100);
复制代码
希望大家指点。
谢谢! |
|