Oracle ORA-01451: 要修改为 NULL 的列无法修改为 NULL

2014-11-24 17:56:17 · 作者: · 浏览: 0

运行,又出现错误提示如下
---------------------------------------------------------------------------
ORA-06550: 第 8 行, 第 7 列:
PLS-00103: 出现符号 "ALTER"在需要下列之一时:
( begin case declare exit
for goto if loop mod null pragma raise return select update
while with
<<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
---------------------------------------------------------------------------------
仔细一看,原来alter不允许在PL/SQL下直接运行,只好更改如下

declare
visnull varchar2(4);
begin
select nullable into visnull from user_tab_columns
where table_name = upper('tblStockInspect')
and column_name = upper('FDepartID');
if visnull = 'N' then
execute immediate 'alter table tblStockInspect modify FDepartID int null‘;
end if;
end;
运行通过