我想要 :
创建一个临时表,其中列出了 TBTRIGPMMCANC 和 TBPROPPAY 上的所有 id_payments。
从此列表中将它们从 TBPROPPAY 移至 TBPROPPAYH。
然后从 TBPROPPAY 中删除它们。
这是我的 sql 我在插入语句中有问题。我想我需要一个像以前一样的 SQL 来为临时表中的每个 id_payment 将行移动到 tbproppayh 但我不知道如何编写它
错误是:E_US0AD8 INSERT:目标列数必须等于指定子选择中的目标列表元素数。(2013 年 7 月 18 日星期四 09:31:23)
----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
-------------------------------------------------------------