Jeroen wrote: >Merkel Marcel wrote: > >> I try to extract geometric data types from a postgre DB (7.4) with >> libpqxx. But I do not have much success. I'd like to get the four >> floating points which formed the box as integers. However I don't know >> how I can extract these four points from the result::field. It looks to >> me like it is a string. I could parse the string myself but I'm sure >> there is a better solution for that. > >I'm afraid there isn't! Arrays are not supported in libpqxx yet. >Floating-point values are, for what it's worth, but you'll have to extract >them from the array representation first. > > >> I solved a similar problem with the point data type by modifying the >> query : >> SELECT point[0], point[1] FROM .., gives me the two floats in seperate >> columns. But the same trick does not work for the box type. In that case >> I get two columns of type point. I tried SELECT box[0][0] FROM ... to >> get one value of the box as a single column but that doesn't work. > >That's a creative approach... Why doesn't it work? I haven't worked with >arrays in postgres yet, so I don't know much about them. > It simply gives me NULL as result don't know why. In the postgre manual I found that snippet (chapter 9.9) :
It is possible to access the two component numbers of a point as though it were an array with indices 0 and 1. For example, if t.p is a point column then SELECT p[0] FROM t retrieves the X coordinate and UPDATE t SET p[1] = ... changes the Y coordinate. In the same way, a value of type box or lseg may be treated as an array of two point values. I tried some combinations and the following works: SELECT (box[0])[0], (box[0])[1], (box[1])[0], (box[1])[1] FROM ... Thanks for your help. Marcel > >Jeroen _______________________________________________ Libpqxx-general mailing list [email protected] http://gborg.postgresql.org/mailman/listinfo/libpqxx-general
