0

我想将数据库中的值传输到另一个数据库。但是在我的源数据库中,有一个包含 LONG 数据类型的列的表。所以我不能简单地对这些 LONG 类型的列使用插入命令。

所以我读了这个:http: //it.toolbox.com/blogs/siebel-answers/ora00997-illegal-use-of-long-datatype-when-performing-sql-insert-intoselect-from-27132

并构建此代码:

  DECLARE 
CURSOR b is 
select
Column_1,
Column_2
FROM DB1.TABLE1;
rb b%ROWTYPE; 
BEGIN 
OPEN b;
LOOP  
FETCH b INTO rb; 
EXIT WHEN b%NOTFOUND; 
INSERT INTO TABLE_1
(
 Column_1,
 Column_2
  )
  VALUES
  (
  rb.Column_1,
    rb.Column_2
  );
  END LOOP;
  COMMIT;
END;

它运作良好,但我在它之后添加了另一个块:

 DECLARE 
    CURSOR b is 
    select
    Column_1,
    Column_2
    FROM DB1.TABLE2;
    rb b%ROWTYPE; 
    BEGIN 
    OPEN b;
    LOOP  
    FETCH b INTO rb; 
    EXIT WHEN b%NOTFOUND; 
    INSERT INTO TABLE_2
    (
     Column_1,
     Column_2
      )
      VALUES
      (
      rb.Column_1,
      rb.Column_2
      );
      END LOOP;
      COMMIT;
    END;

 DECLARE 
    CURSOR b is 
    select
    Column_1,
    Column_2
    FROM DB1.TABLE1;
    rb b%ROWTYPE; 
    BEGIN 
    OPEN b;
    LOOP  
    FETCH b INTO rb; 
    EXIT WHEN b%NOTFOUND; 
    INSERT INTO TABLE_1
    (
     Column_1,
     Column_2
      )
      VALUES
      (
      rb.Column_1,
        rb.Column_2
      );
      END LOOP;
      COMMIT;
    END;

出现如下错误:

Error starting at line 1 in command:
DECLARE 
        CURSOR b is 
        select
        Column_1,
        Column_2
        FROM DB1.TABLE2;
        rb b%ROWTYPE; 
        BEGIN 
        OPEN b;
        LOOP  
        FETCH b INTO rb; 
        EXIT WHEN b%NOTFOUND; 
        INSERT INTO TABLE_2
        (
         Column_1,
         Column_2
          )
          VALUES
          (
          rb.Column_1,
          rb.Column_2
          );
          END LOOP;
          COMMIT;
        END;

     DECLARE 
        CURSOR b is 
        select
        Column_1,
        Column_2
        FROM DB1.TABLE1;
        rb b%ROWTYPE; 
        BEGIN 
        OPEN b;
        LOOP  
        FETCH b INTO rb; 
        EXIT WHEN b%NOTFOUND; 
        INSERT INTO TABLE_1
        (
         Column_1,
         Column_2
          )
          VALUES
          (
          rb.Column_1,
            rb.Column_2
          );
          END LOOP;
          COMMIT;
        END;
Error report:
ORA-06550: line 27, column 6:
PLS-00103: Encountered the symbol "DECLARE" 
ORA-06550: line 51, column 12:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   ( begin case declare end exception exit for goto if loop mod
   null pragma raise return select update while with
   <an identifier> <a double-quote
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

我怎样才能一个接一个地使用这个结构?

4

1 回答 1

1

只需/在每个块之后添加一个。吼叫END;

declare
var number;
begin
-do something
end;
/
于 2013-05-10T08:32:46.560 回答