Informix SQL / insert result of stored procedure in table

試著忘記壹切 提交于 2019-12-02 16:08:06

问题


kassa_akt_revizii_parser('','','') returns field(per_monets_5,per_monets_10,per_monets_25,per_monets_50,per_rub_1,per_rub_5,per_rub_10,per_rub_25,per_rub_50,per_rub_100,per_rub_200,per_rub_500,per_val_376,per_val_428,per_val_498,per_val_643,per_val_840,per_val_978,per_val_980)

We need to do an insert into a table:

insert into kassa_akt_revizii_pereschet(
id_akt_revizii,per_monets_5,per_monets_10,per_monets_25,per_monets_50,
per_rub_1, per_rub_5, per_rub_10, per_rub_25, per_rub_50,
per_rub_100, per_rub_200, per_rub_500,per_val_376, 
per_val_428, per_val_498, per_val_643, per_val_840,
per_val_978, per_val_980)
values(50, kassa_akt_revizii_parser('','',''));

Number of columns in INSERT does not match number of VALUES


回答1:


Try this way:

INSERT INTO kassa_akt_revizii_pereschet(
    id_akt_revizii,
    per_monets_5,
    per_monets_10,
    per_monets_25,
    per_monets_50,
    per_rub_1, 
    per_rub_5, 
    per_rub_10, 
    per_rub_25, 
    per_rub_50,
    per_rub_100, 
    per_rub_200, 
    per_rub_500,
    per_val_376, 
    per_val_428, 
    per_val_498, 
    per_val_643, 
    per_val_840,
    per_val_978, 
    per_val_980
)
SELECT 50, *
FROM TABLE(kassa_akt_revizii_parser('','',''));

Example:

[infx1210@tardis ~]$ dbaccess -e db1 test.sql

Database selected.

CREATE TABLE tab1( col1 INT, COL2 INT, COL3 INT);
Table created.



CREATE FUNCTION sp1() RETURNING INT, INT
        RETURN 1, 2;
END FUNCTION;
Routine created.

;

INSERT INTO tab1 VALUES (0, sp1());
  236: Number of columns in INSERT does not match number of VALUES.
Error in line 7
Near character position 26


INSERT INTO tab1
SELECT 1, *
FROM TABLE(sp1());
1 row(s) inserted.



SELECT * FROM tab1;

       col1        col2        col3

          1           1           2

1 row(s) retrieved.



Database closed.

[infx1210@tardis ~]$



回答2:


Number of columns in INSERT does not match number of VALUES

Your error message simply denotes that while insert (columns) does not match number of (values) that you are inserting.

Check them again and insert again .

Insert query :

insert into tablename (column1,column2,...column50) values (value1,value2...value50)


来源:https://stackoverflow.com/questions/31828648/informix-sql-insert-result-of-stored-procedure-in-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!