1


This is another error received during the creation of a Ruby script that parses data from a couple Excel CSV files into arrays and then inserts certain data into PostgreSQL based on various criteria. The entire error is below.

Full Ruby 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 C22P02  Minvalid input syntax for integer: ""       Fnumutils.c     L54     Rpg_atoi (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

I am sure this has to do with the way the data is formatted inside the Postgres INSERT statement but I am not sire specifically what needs to change. Right now I have the number wrapped in double quotes via the Ruby script parsing the CSV file that is getting added to a PSQL field that has a type of integer.

Should I be using single quotes or no quotes at all?

flag offensive community wiki
add comment
1 Answers:
1


This error could describe a couple things but basically the issue is that PostgreSQL is telling you that the input for one of the integer columns is incorrect. This could be caused by double quotes or characters other than numbers being entered into the column.

I suggest manually running the command using the PSQL CLI to verify that your SQL syntax works without issue before coding it with Ruby.

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