I have something very strange happening. There are two particular spatial tables in a PostGreSQL database that I cannot get to function 100% correctly in ArcGIS. Basically I can get them into ArcMap as query layers like all the others, but I can't open the attribute tables of these two in particular.
When I try to open the attribute table of one I get "The number of points is less than required for feature" and the other says "Linestring or poly boundary is self-intersecting". The table opens with the correct number of columns and rows, but it is completely blank. I know the data is in there because I can change symbology to be dependent on an attribute in the table, I just cannot get the table to open. If I export them and add them as shapefiles, they work fine. It's mind boggling that only two layers would behave this way.
Any ideas how I might fix them?
Does this table support mutliple topology classes (point and line and polygon)?
Query Layers use the first found topology class for rendering rules. Are all of your geometries clean with respect to that first found topology class? Bowtie and other degenerate features can be dumped into shapefiles and rendered, but FGDB, ArcSDE, and QueryLayers are held to a higher topology standard.
What does "SELECT ST_IsValid(geomcol) FROM tablename" return?
I repaired the geometries of the two tables in question, and re-uploaded them to our PostGreSQL server and the same two errors came up when I tried to open the attribute tables. When I run the script you posted, several of the features appear to have invalid geometries, but they display fine in ArcMap, I can even look at the properties of the columns in the attribute table and they are correct, it's just the attribute information disappears completely when I open the attribute table. It is only two of the features. There are several others that are very similar in the same schema that work 100% fine.
UPDATE: The two tables in question are behaving normally in ArcCatalog, I can preview the geometry and the attribute table without any problems. I think there is something going on specifically in ArcMap that is causing the problem.
Just because PostgreSQL doesn't think the geometry isn't invalid doesn't mean that the geometry constructors will agree. Tech Support can help you track down this issue.