EXECUTE IMMEDIATE PL / SQL?

时间:2015-06-04 15:23:01

标签: sql oracle plsql oracle11g

CREATE OR REPLACE TRIGGER P88
AFTER INSERT ON reparation    
FOR EACH ROW   

DECLARE
vope number;    
BEGIN    
  SELECT observation_reparation into vope from repartion;    
  if(vope IS NULL)THEN

  EXECUTE IMMEDIATE 'ALTER TABLE ' || reparation.observations_Reparation || ' MODIFY libelle_piece NVARCHAR2(50)';    
END IF;
END;
/

我明白了:

  

错误:表或​​视图不存在。

1 个答案:

答案 0 :(得分:-1)

CREATE OR REPLACE TRIGGER P88
AFTER INSERT ON reparation
FOR EACH ROW
DECLARE
vope number;

BEGIN

  SELECT observation_reparation into vope from repartion;

  if(vope IS NULL)THEN

    EXECUTE IMMEDIATE 'ALTER TABLE reparation RENAME COLUMN observations_Reparation TO libelle_piece';

  END IF;
END;

如果您还需要更改列的声明,则需要另一个ALTER语句

alter table reparation modify (libelle_piece NVARCHAR2(50))