Informix SQL / insert result of stored procedure in table

后端 未结 2 776
囚心锁ツ
囚心锁ツ 2021-01-27 10:52
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_ru         


        
相关标签:
2条回答
  • 2021-01-27 11:12

    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 ~]$
    
    0 讨论(0)
  • 2021-01-27 11:12

    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)
    
    0 讨论(0)
提交回复
热议问题