Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I was attempting to import a polyline roads layer into postgis, using both SPIT in QGIS 1.7 and postGIS GUI for this purpose. I have received errors through both processes as described here:

  • SPIT

The database gave an error while executing this SQL: INSERT INTO "public"."highways"("STREET","FROMLEFT","TOLEFT","FROMRIGHT","TORIGHT","STREETCODE","OBJID","USERID","FJUNCTION","TJUNCTION","LENGTH","ROA... (rest of SQL trimmed) The error was: ERROR: value too long for type character varying(31)

  • postGIS GUI

Error msg. from postGIS

What can be the problem and how can I fix it?

Thanks for your response.

Dor

share|improve this question
    
Just to update that I have overcame this obstacle; unfortunatly by using ArcCatalog. With it I was able to drop the fields that I didn't want, and one of them caused the problem. –  dof1985 Jan 17 '13 at 9:19
1  
I'd put your last comment as your answer so this can be marked as answered. –  Zach May 24 '13 at 15:12

2 Answers 2

As the error message "The error was: ERROR: value too long for type character varying(31)" says, the problem is the character column with the max length of 31 characters. You can use text type instead of character to avoid this problem.

As an alternative, you can try QGIS DB Manager which now replaces SPIT.

share|improve this answer

As Zach suggested I put my own comment as an answer, eventhough I'm not fully satisfied with it.

"Just to update that I have overcame this obstacle; unfortunatly by using ArcCatalog. With it I was able to drop the fields that I didn't want, and one of them caused the problem."

Maybe it will be better to tell that the whole process of working with roads (polyline) vector data from the same source was much easier with Grass-GIS 7.0 svn. I think that is a better solution for anyone who is not found with postGIS

share|improve this answer
    
Reason was that you had there 31 char long column, easy fix, replace all char[lenght] columns with text type –  simplexio Dec 14 '13 at 11:30
    
@simplexio thanks for your answer. As i've written above, I have switched to grass-GIS to perform my analysis. However for other or future users of Post-gis, can you shortly descirbe how yo perform the replacment before improting the shp file? –  dof1985 Dec 15 '13 at 13:08
1  
i know shp2psql command. First you use it with option -p which only creates table code, edit it and run it to postgresql. Then use -a option to files to be imported. You can replace all variable length character columns with text type ( and there should be no performance hit) –  simplexio Dec 15 '13 at 18:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.