0
我想將數據庫中的值傳送到另一個數據庫。但是在我的源數據庫中,有一些帶有LONG數據類型的列。所以我不能簡單地使用這些LONG類型的列插入命令。用於LONG數據類型的ORACLE DECLARE CURSOR列插入
,並建立驗證碼:
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;
它運作良好,但後來我再添blockafter它:
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:
我怎樣才能使用這structerone在另一個?
只需在每個塊之後加一個'/'。貝婁'END;' – 2013-05-10 08:23:18
哦,它的工作原理!感謝answar,對不必要的問題抱歉。 – 2013-05-10 08:28:13
也許沒有必要,也許有人會遇到同樣的問題。 – 2013-05-10 08:30:51