我想作以下工作:当主要钥匙配对时,如果与活跃的Y号字不成,则插入记录。 这是可能的吗?
我试图这样做:
-- Merge statement
MERGE INTO table1 AS DST
USING table2 AS SRC
ON (SRC.Code = DST.Code)
--Existing records updated if data changes
WHEN MATCHED
AND IF NOT EXISTS (WHERE active= Y FROM table1 )
THEN
INSERT INTO table1 (colum)
SELECT value
+-------+-------------+--------+
| Code | description | Active |
+-------+-------------+--------+
| AB | just | |
| | something | No |
+-------+-------------+--------+
只有当同一部法典没有积极记录时,我才希望插入一个记录。 新的记录希望能做到这一点。
+-------+-------------+--------+
| Code | description | Active |
+-------+-------------+--------+
| AB | something | |
| | else | YES |
+-------+-------------+--------+
我希望这能够更明确地表明这一点。
edit: Never mind its not possible, I just got this error message: An action of type INSERT is not allowed in the WHEN MATCHED clause of a MERGE statement.