[postgis-users] Problem with correlative ID after using INSERT INTO

Gery . gamejihou at hotmail.com
Fri Oct 7 04:39:30 PDT 2011



Thanks Puneet, it's enough what I have now in the table, the scheme you showed (a & b into table c) is actually what I did, but the order just in one table (4000 rows) changed I dont know why. The other table (50 rows) remained the same after being inserted in c. Both a and b had their correlative IDs. Anyway, in order to update my table I just order by id and know which one are the ones to be updated. Thanks.


----------------------------------------
> From: gamejihou at hotmail.com
> To: postgis-users at postgis.refractions.net
> Subject: FW: Problem with correlative ID after using INSERT INTO
> Date: Thu, 6 Oct 2011 20:07:56 +0000
>
>
>
> Thanks Sandro, what means "You want to order at query time."? I did a simple "select * from both_lines order by id;" and worked perfectly, I was thinking about creating a new table, based on the headers of the both_line table and copy all the ordered values into this new table, but after reading for a while I noticed that the geometrycolumn information will be lost and adding the same into it can cause some problems.
>
>
>
> ----------------------------------------
> > From: gamejihou at hotmail.com
> > To: postgis-users at postgis.refractions.net
> > Subject: FW: Problem with correlative ID after using INSERT INTO
> > Date: Thu, 6 Oct 2011 18:41:21 +0000
> >
> >
> >
> > Thanks Paul, I put ORDER BY ID before Select and after it but didn't work. Could you provide me please an example based on the code below?
> >
> > INSERT INTO both_lines (ID, SURVEY, PROFILE, TYPE, SOURCE, LENGTH_KM, LENGTH_NM, COMMENTS, GEOM)
> > SELECT ID, SURVEY, PROFILE, TYPE, SOURCE, LENGTH_KM, LENGTH_NM, COMMENTS, GEOM FROM line;
> >
> > Thanks,
> >
> >
> > ----------------------------------------
> > > From: gamejihou at hotmail.com
> > > To: postgis-users at postgis.refractions.net
> > > Subject: Problem with correlative ID after using INSERT INTO
> > > Date: Thu, 6 Oct 2011 12:17:54 +0000
> > >
> > >
> > >
> > > Hello,
> > >
> > > I'm trying to get a table, composed of other two tables, but the correlative ID of one of them changes, it "jumps", this is what happens:
> > >
> > > **************
> > > id | name
> > > ...
> > > 34 | 79-051
> > > 35 | 79-052
> > > 52 | 79-076
> > > 214 | 96-008A
> > > 215 | | 96-009
> > > 36 | 79-053
> > > 37 | 79-055
> > > ....
> > > ****************
> > >
> > > this shape was inserted as follows:
> > >
> > > shp2pgsql -s 4326 -W UTF-8 -g geom -I -D /home/postgres/shp/line/line.shp | psql -U postgres -d mydb
> > >
> > > after checking it in my db, it looks like:
> > >
> > > **********
> > > ...
> > > 34 | 79-051
> > > 35 | 79-052
> > > 36 | 79-053
> > > 37 | 79-055
> > > ...
> > > **********
> > >
> > > this is the part of the code I used to insert this table:
> > >
> > > INSERT INTO both_lines (ID, SURVEY, PROFILE, TYPE, SOURCE, LENGTH_KM, LENGTH_NM, COMMENTS, GEOM)
> > > SELECT ID, SURVEY, PROFILE, TYPE, SOURCE, LENGTH_KM, LENGTH_NM, COMMENTS, GEOM FROM line;
> > >
> > > I tried adding "ORDER BY ID" at the end of the second line (after "line") but didn't work.
> > >
> > > Any suggestions are very welcome, thanks in advance,
> > >
> > > Gery
> > >
> >
>
 		 	   		  


More information about the postgis-users mailing list