0


I got the above error when running a Ruby script I had created. The script would read data from two Excel files (.CSV) and then it would connect to a PostgreSQL database and enter data based on some criteria that was parsed from the CSV files. This error displayed before the script has started working.

Entire Error:

[web@dev atp]$ ruby alldevices.rb       
/usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:115:in `query': ERROR C42601  MINSERT has more target columns than expressions    Fanalyze.c      L693    RtransformInsertRow (RuntimeError)
        from /usr/local/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:33:in `exec'
        from alldevices.rb:41
        from alldevices.rb:39:in `each'
        from alldevices.rb:39
        from alldevices.rb:38:in `each'
        from alldevices.rb:38

The above error must be getting returned by Postgres because the postgres-pr gem is complaining.

flag offensive community wiki
add comment
1 Answers:
0


The above error states that either you have specified more columns in the SQL syntax than you have provided data for or you have specified more data to go into columns than you have specified columns. Take the below for example.

SQL Example:

INSERT INTO devices (id,serial_number,active,mac_address,revision_id) VALUES(12,1234567,No,'00:00:00:00:00',14,7777777);

See how the VALUES specification has specified more data than the number of columns.

add comment
Your answer:
You are now not logged in but you can answer first and then login
toggle preview