customers:
+------------+--------------+
| cid | Name |
+------------+--------------+
| 1 | Bob |
| 2 | John |
| 3 | Jane |
+------------+--------------+
accounts:
+------------+--------------+
| aid | type |
+------------+--------------+
| 1 | Checking |
| 2 | Saving |
| 3 | Checking |
+------------+--------------+
transactions:
+------------+--------------+--------------+--------------+
| tid | cid | aid | type |
+------------+--------------+--------------+--------------+
| 1 | 1 | 1 | Open |
| 2 | 2 | 3 | Open |
| 3 | 1 | 2 | Open |
| 4 | 2 | 3 | Deposit |
+------------+--------------+--------------+--------------+
我試圖編寫一個觸發器,用於在新帳戶成功打開時寫入日誌表。當新帳戶打開時插入到表中的觸發器
現在我有這樣的:
CREATE OR REPLACE TRIGGER acc_opened
BEFORE INSERT ON transactions
FOR EACH ROW
DECLARE
c_name customers.name%TYPE;
BEGIN
IF :new.type = 'Open' THEN
SELECT name into c_name
FROM customers c
WHERE c.cid = :new.cid;
INSERT INTO logs (who, what) VALUES (c_name, 'An account has been opened');
END;
/
,我有不工作,不知道從哪裏何去何從的代碼。
觸發完成,但火災時,我收到此錯誤信息:
PLS-00103:出現符號「END」在需要下列之一時:(開始的情況下宣佈退出用於轉到如果環模空編譯提高收益選擇更新而與< <繼續關閉當前刪除獲取鎖芯打開回滾保存點設置SQL EXECUT提交FORALL合流管清洗
你能否澄清「不工作」的意思?你有錯誤嗎?如果是這樣,有什麼錯誤?這是編譯錯誤還是運行時錯誤? –
對不起,剛添加了錯誤。 – user1378863