其他分享
首页 > 其他分享> > ORA-14450: 试图访问已经在使用的事务处理临时表

ORA-14450: 试图访问已经在使用的事务处理临时表

作者:互联网

需要对临时表动态添加列,经常碰到表在事务中被使用的情况,如果可以的话,可以现在只用临时表的时候先truncate,这样可以终止事务对当前临时表的占用。

 

execute immediate('truncate table Temp_SD_SDInvReferItem ');
     if (Trim(p_OrderCond) is not null) then
      open cur for  SELECT FieldName FROM CustomFields WHERE ClassSetCode='SalesOrder' AND ActTable='SalesOrderItems' AND IsDeleted<='0';
       fetch cur into vCusFieldName;
       while cur%found loop
         vcnt :=vcnt+1;
         vcolName :='CusFieldName'||vcnt;
         declare vCount int := 0;
          begin
              select count(1) into vCount from user_col_comments where Upper(Table_Name) = Upper('Temp_SD_SDInvReferItem') and Upper(Column_Name) = Upper(vcolName);
              if vCount = 0 then
                begin
                        execute immediate('ALTER TABLE Temp_SD_SDInvReferItem add '||vcolName ||' varchar(1024) ');
                end;
              end if;
           end;
           vSOItemCustomFields:=vSOItemCustomFields ||  ', '|| vcolName;/*组织表头的列名*/
           vSOTableCustomFields := vSOTableCustomFields || ' , SalesOrders.' ||vCusFieldName;  /*组织select 的列名*/
           FETCH cur   INTO vCusFieldName;
           END loop;
      CLOSE cur;
    end if;
     if (Trim(p_BOLCond) is not null) then
      open cur for  SELECT FieldName FROM CustomFields WHERE ClassSetCode='BillsOfLading' AND ActTable='BOLItems' AND IsDeleted<='0';
       fetch cur into vCusFieldName;
       while cur%found loop
         vcnt :=vcnt+1;
         vcolName :='CusFieldName'||vcnt;
         declare vCount int := 0;
          begin
              select count(1) into vCount from user_col_comments where Upper(Table_Name) = Upper('Temp_SD_SDInvReferItem') and Upper(Column_Name) = Upper(vcolName);
              if vCount = 0 then
                begin
                        execute immediate('ALTER TABLE Temp_SD_SDInvReferItem add '||vcolName ||' varchar(1024) ');
                end;
              end if;
           end;
           vOtherItemCustomFields:=vOtherItemCustomFields ||  ', '|| vcolName;/*组织表头的列名*/
           vOtherTableCustomFields := vOtherTableCustomFields || ' , BOLItems.' ||vCusFieldName;  /*组织select 的列名*/
           FETCH cur   INTO vCusFieldName;
           END loop;
      CLOSE cur;
      end if;

标签:Upper,end,cur,vcolName,vCusFieldName,事务处理,vCount,14450,ORA
来源: https://www.cnblogs.com/myznt/p/3242933.html