CREATE PROCEDURE kassa_ins()
RETURNING int,int,int;
return 1, 2, 3;
END PROCEDURE
CREATE TRIGGER "informix".on_ins_kassa INSERT ON "informix"
.kassa REFERENCING NEW AS n_val
FOR EACH ROW(
INSERT INTO "informix".kassa_log(col1,col2,col3)
VALUES(kassa_ins())
);
SQL错误(-236):INSERT中的列数与VALUES的数量不匹配。
如何将过程触发器中的结果插入到另一个表中? IBM Informix Dynamic Server版本11.70
答案 0 :(得分:1)
就像在另一个Answer中说的那样:
[infx1210@tardis ~]$ dbaccess -e dmitriy test.sql
Database selected.
CREATE TABLE "informix".kassa (
col1 INT,
col2 INT,
col3 INT
);
Table created.
CREATE TABLE "informix".kassa_log (
col1 INT,
col2 INT,
col3 INT
);
Table created.
CREATE FUNCTION "informix".kassa_ins()
RETURNING int,int,int;
RETURN 1, 2, 3;
END FUNCTION;
Routine created.
;
CREATE TRIGGER "informix".on_ins_kassa
INSERT ON "informix".kassa
REFERENCING NEW AS n_val
FOR EACH ROW(
INSERT INTO "informix".kassa_log(col1,col2,col3)
SELECT * FROM TABLE(kassa_ins())
);
Trigger created.
INSERT INTO "informix".kassa(col1,col2,col3)
SELECT * FROM TABLE(kassa_ins());
1 row(s) inserted.
SELECT * FROM "informix".kassa;
col1 col2 col3
1 2 3
1 row(s) retrieved.
SELECT * FROM "informix".kassa_log;
col1 col2 col3
1 2 3
1 row(s) retrieved.
Database closed.
[infx1210@tardis ~]$