存在的錯誤,我想:SQL LIKE /地方使用INSERT語句
與上TBTRIGPMMCANC也TBPROPPAY所有id_payments的列表中創建一個臨時表。
從此列表中將它們從TBPROPPAY移動到TBPROPPAYH。
然後從TBPROPPAY中刪除它們。
這是我的sql我有一個插入語句問題。我想我需要像以前一樣的SQL將行移動到tbproppayh爲每個id_payment在臨時表中,但我不知道如何編寫它
錯誤是: E_US0AD8插入:目標列的數量必須等於目標 列出指定子查詢中的元素。 (星期四7月18日9時31分23秒2013)
----Clean up for IN:035466
----Description : Create a temporary table with with a list of all id_payments that are on TBTRIGPMMCANC and also TBPROPPAY.
----------------------------------------------------------------------------------------------------------------------------
DECLARE GLOBAL TEMPORARY TABLE session.set_values AS
SELECT a.id_payment FROM TBTRIGPMMCANC a, TBPROPPAY b
WHERE a.id_payment = b.id_payment
ON COMMIT PRESERVE ROWS WITH NORECOVERY;\p\t\g
--View temporary table
SELECT * FROM session.set_values;\p\t\g
--------------------------------------------------------------
-- Description: Move list from TBPROPPAY to TBPROPPAYH
-------------------------------------------------------------
SELECT id_payment FROM session.set_values
WHERE EXISTS id_payment;\p\t\g
-- Insert into tbproppayh
-------------------------------------------------------------
Insert into tbproppayh
Select id_payment FROM TBTRIGPMMCANC a, TBPROPPAY b
WHERE a.id_payment = b.id_payment;\p\t\g
-------------------------------------------------------------
-- Description: DELETE list FROM tbproppay
-------------------------------------------------------------
Delete FROM tbproppay b WHERE id_payment IN (Select a.id_payment FROM TBTRIGPMMCANC a, TBPROPPAY b
WHERE a.id_payment = b.id_payment);\p\t\g
-------------------------------------------------------------
--Select from tbproppay & TBTRIGPMMCANC
-------------------------------------------------------------
SELECT a.id_payment FROM TBTRIGPMMCANC a, TBPROPPAY b
WHERE a.id_payment = b.id_payment;\p\t\g
-------------------------------------------------------------
插入到tbproppayh(id_payment)選擇a.id_payment從TBTRIGPMMCANC a,TBPROPPAY b WHERE a.id_payment = b.id_payment。仍然無法正常工作在插入錯誤 – louise
上嘗試插入值時在目標表中的現有密鑰上添加條件:INSERT INTO ... SELECT .... AND NOT EXISTS(SELECT'X'FROM tbproppayh where condition關鍵) –