Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Chuck D.
On October 23, 2007 08:51:18 pm you wrote: > > I got it to work with your sample data by using the COPY command as > follows: COPY geo.orig_city_maxmind > FROM '/home/www/geo/DATA/MAXMIND.com/cities_no_header.txt' > CSV quote as ; I see what you are after and you solved the syntax

Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Chuck D.
On October 23, 2007 10:44:51 am you wrote: > Hi Chuck, > Do you need those characters in your table? If not I think you will be > better off preprocessing the data before running copy. > > Replacing those " for ' or directly removing them is quite simple if you > are working in Unix, actually it sh

Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Paul Lambert
Chuck D. wrote: Greetings everyone, I'm having some trouble with COPY syntax. I'm importing the cities data from MaxMind, but I run into errors when the data adds a double quote inside a field. The data is CSV, comma delimited, no quotes around fields, ISO-8859-1. I'm using COPY with the d

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Nis Jørgensen
D'Arcy J.M. Cain skrev: > On Wed, 24 Oct 2007 11:00:47 +0800 > Paul Lambert <[EMAIL PROTECTED]> wrote: >> It's marked not null as a result of being part of the primary key for >> that table which I can't really get around. >> >> I can get away with not having the foreign key though, so I'll have t

Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Chuck D." <[EMAIL PROTECTED]> writes: > On October 23, 2007 08:51:18 pm you wrote: >> >> I got it to work with your sample data by using the COPY command as >> follows: COPY geo.orig_city_maxmind >> FROM '/home/www/geo/DATA/MAXMIND.com/cities_no_header.txt' >> CSV

[SQL] get only rows for latest version of contents

2007-10-24 Thread Sébastien Meudec
Hi everybody. I have a table like that (i simplified it): CREATE TABLE business { idnode integer not null, version_no integer, c1 text, c2 text, c3 text } With a unique index in (idnode,version_no). This table records many version from contents identified by idnode where texts may be di

Re: [SQL] get only rows for latest version of contents

2007-10-24 Thread Christian Kindler
Hi! not quick mut works select * from business b1 where b1.version_no = (SELECT max(version_no) FROM business b2. where b2.idnode = b1.idnode ) If you want to make this quiry faster du a regular join select b1.* from business b1, (SELECT

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Paul Lambert
Paul Lambert wrote: It's marked not null as a result of being part of the primary key for that table which I can't really get around. I can get away with not having the foreign key though, so I'll have to go down that path. Cheers, P. Ignore this whole thread actually. I need to rethin

Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Fernando Hevia
> De: Chuck D. > > I'm not sure if they are needed because I've never seen a double quote in > a > place name before. I don't believe they are errors though because there > are > more records that contain them. As well, some records have single and > double > quotes allowed within a record and

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Robins Tharakan
Forgive my butting in, but frankly, most of the times, whenever I find myself in a very 'exceptional problem' such as this one, I always end up questioning the basic design due to which I am stuck in the first place. Paul, it seems that probably there is a basic design issue here. All the best :)

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread D'Arcy J.M. Cain
On Wed, 24 Oct 2007 09:43:10 +0200 Nis Jørgensen <[EMAIL PROTECTED]> wrote: > Well, I have a couple of times had the "need" to have a primary > key/uniqueness constraint with one column nullable (indicating "Not > Applicable"). The "problem" is that we have only one NULL, which for > comparison pur

[SQL] ERROR: failed to re-find parent key in "pk_ep07"

2007-10-24 Thread Otniel Michael
When i was vacuum the database, the vacuum if failed. And I get this error. Any ideas an to fix this? ERROR: failed to re-find parent key in "pk_ep07" Thanks before. Note : EP07 is name of tables. -- "He who is quick to become angry will commit folly, and a crafty man is hated"

Re: [SQL] ERROR: failed to re-find parent key in "pk_ep07"

2007-10-24 Thread Tom Lane
Otniel Michael <[EMAIL PROTECTED]> writes: > When i was vacuum the database, the vacuum if failed. And I get this error. > Any ideas an to fix this? >ERROR: failed to re-find parent key in "pk_ep07" Update to a newer PG version, possibly? This symptom has been seen before...

Re: [SQL] get only rows for latest version of contents

2007-10-24 Thread Sébastien Meudec
Thx a lot Chris. In fact the correct SQL was (rewritten with inner join because of it is required by my api): select b1.* from business b1 inner join (select idnode,max(version_no) as version_no from business group by idnode) as b2 on b1.idnode = b2.idnode and (b1.version_no = b2.