Reputation: 133
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
Upvotes: 0
Views: 1887
Reputation: 1086
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 ~]$
Upvotes: 2
Reputation: 13971
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)
Upvotes: 2