Subject Re: [firebird-support] Insert error: count of column and variable list do not match
Author Martijn Tonies (Upscene Productions)
Hi,
 
Remove the VALUES(( part
 
There’s no need for a VALUES keyword if you use a SELECT to insert rows.
 
With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Database Workbench - developer tool for Oracle, MS SQL Server, PostgreSQL,
SQL Anywhere, MySQL, InterBase, NexusDB and Firebird.
 
Sent: Friday, December 29, 2017 3:32 PM
Subject: [firebird-support] Insert error: count of column and variable list do not match
 


I'm trying to insert data from a query into a table however I receive the following error message:

 

SQL Message : -104

Invalid token

 

Engine Code    : 335544569

Engine Message :

Dynamic SQL Error

SQL error code = -104

Invalid command

count of column list and variable list do not match

 

The table is defined as:

 

CREATE GLOBAL TEMPORARY TABLE tmp_gdlmove

(

  verid BIGINT,

  level_num SMALLINT,

  parentid BIGINT,

  times_assigned SMALLINT,

  journey CHAR(1)

)

ON COMMIT DELETE ROWS;

 

and the query I'm trying is defined as:

 

INSERT INTO tmp_gdlmove (verid, level_num, parentid, times_assigned)

VALUES((SELECT verid,  level_num, parentid, count(*) as times_assigned

                   FROM (SELECT DIS           FROM ASSIGNMENT ass

                                    INNER JOIN orgchart och on och.childid=ass.orgid

                                    INNER JOIN organisation org on och.parentid=org.orgid

                                WHERE verid IN (3) AND level_num IN (1,2) and depth =1)

                   GROUP BY verid, level_num, parentid))

 

 

The select portion of the query returns the same number of columns as I have listed in the insert statement so I'm unsure why I receive this message.