我目前正在上Oracle SQL类,并且在SAVEPOINT和ROLLBACK方面遇到问题。 据说SAVEPOINT和ROLLBACK语句在vs代码中靠近它们的语法无效,而APEX则表示SAVEPOINT语句是未知的。如果我删除代码周围的语句,似乎可以修复错误,但似乎我应该能够在一个文件中完成整个分配。至少那是他们想要的。我的教授似乎也很沮丧,因此我希望你们能为我提供帮助。仅供参考,我在编码和SQL方面还很陌生。这是我的代码:
/*These statements create indexes*/
CREATE INDEX CD_NUMBER_TRACK_LISTINGS_IDX
ON D_TRACK_LISTINGS(CD_NUMBER);
CREATE UNIQUE INDEX EMAIL_D_CLIENTS_IDX
ON D_CLIENTS(EMAIL);
CREATE INDEX TITLE_ARTIST_D_SONGS_IDX
ON D_SONGS(TITLE,ARTIST);
/* transaction statements*/
SAVEPOINT one;
DELETE TITLE
FROM D_SONGS
WHERE TITLE = "All These Years";
INSERT INTO D_SONGS(ID, TITLE, DURATION, ARTIST, TYPE_CODE)
VALUES(60, "Happy Birthday Sunshine", "4 min" , "The Sunsets", 88);
ROLLBACK TO SAVEPOINT one
COMMIT;
SAVEPOINT two;
INSERT INTO D_CDS
VALUES (100, "Best of Rock and Roll", "Old Town Records", "2004");
INSERT INTO D_CDS
VALUES (99, "Party Music", "Old Town Records", "2004");
INSERT INTO D_CDS
VALUES (98, "Holiday Tunes for All Ages", "Tunes are Us", "2004");
INSERT INTO D_CDS
VALUES (97, "Celebrate the Day", "R and B Inc.", "2003");
COMMIT;
SAVEPOINT three;
UPDATE D_EVENTS
SET NAME = "Employee Training";
ROLLBACK TO SAVEPOINT three;
/* explain statements*/
EXPLAIN PLAN
SET STATEMENT_ID = 'myPlan'
FOR
SELECT ID, TITLE, DURATION, ARTIST
FROM D_SONGS
WHERE EXISTS
(SELECT DESCRIPTION
FROM D_TYPES
WHERE DESCRIPTION = 'Jazz' OR DESCRIPTION = 'Pop');
答案 0 :(得分:3)
回滚语句存在问题。
它必须为rollback to <savepoint name>
。不需要SAVEPOINT
关键字。
您的情况应该是:
ROLLBACK TO three; -- or one or two
干杯!