declare
i number(4);
  v_sql varchar2(512);
begin
select count(*) into i from user_all_tables where table_name = 'Grid_Boundary_point';
  if i > 0 then
    execute immediate 'drop table Grid_Boundary_point';
    commit;
  end if; 
  v_sql := 'create table Grid_Boundary_point(a number)';
  execute immediate v_sql;
end;
这行  execute immediate v_sql; 报错name is already used by an existing object
这是怎么回事?怎么解决?

解决方案 »

  1.   

    当表对象存在时,对表进行删除操作时,语句改为如下:
    if i>0 then
     execute immediate 'drop table Grid_Boundary_point cascade constraints';
    end if;
      

  2.   

    if i > 0 then 改为if i >= 0 then
      

  3.   

    where table_name = 'Grid_Boundary_point';这后面的表名要大写才行,不然查不到数据。
      

  4.   

    select count(*) into i from user_all_tables where table_name = 'Grid_Boundary_point';楼上改 Grid_Boundary_point 全为大写应该就可以了如果还不行,将user_all_tables 改为all_tables一定就可以了