Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Chuck D.
On October 25, 2007 09:22:10 pm you wrote: > Did the sed actually do anything? (Hint: the file size of > geonames_fixed.txt would be larger than geonames.txt if it did. > Or you could diff the two files to confirm that something sensible > happened.) > > I suspect that your shell may be fouling th

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Tom Lane
"Chuck D." <[EMAIL PROTECTED]> writes: > I tried this, which I found on the web from Tom Lane: > sed 's/^M/\\r/g' geonames.txt > geonames_fixed.txt > But still get the same error. I used ctrl-v ctrl-m to reproduce the > ^M. Not sure why it is kicking out those lines still. Did the sed actually

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Chuck D.
On October 25, 2007 03:16:59 pm Fernando Hevia wrote: > > As I understand it when a line starts with $ you would like to merge it > with the previous line. > No, it appears the data file I am attempting to COPY has some records with fields that contain a CR/LF in the data of that field. Postgres

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Fernando Hevia
> On October 25, 2007 10:57:49 am you wrote: > > > > If all you just want to do is strip out the ^M, you can run dos2unix on > > it, assuming that you are running a *nix distro. > > Well, I guess I could strip the ^M but I'm still left with a $ in the > middle > of a field which in the same as th

[SQL] hidden versioning system

2007-10-25 Thread Darnell Brawner
I am trying to make a sql based versioning system. I am working on a Ruby on Rails project and am using a plugin called hobo the plugin can do some nice things but over all its lame but thats what i got to work with. The problem is hobo does a lot of work for you but the database most be in

Re: [SQL] JOINing based on whether an IP address is contained within a CIDR range?

2007-10-25 Thread Tom Lane
"Jamie Tufnell" <[EMAIL PROTECTED]> writes: > Is it possible to somehow JOIN using the <<= and > = network operators? Sure, why not? You probably won't get a plan that's smarter than a nestloop, but I imagine you'll have few enough rows in network_names that it won't matter. One potential proble

Re: [SQL] JOINing based on whether an IP address is contained within a CIDR range?

2007-10-25 Thread Erik Jones
On Oct 25, 2007, at 1:22 PM, Jamie Tufnell wrote: Hi, I am storing a log of HTTP requests in a database table (including IP address): http_log: id(PK), path, time, ip I have another table that contains CIDR ranges and names for them: network_names: id(PK), cidr, name Some example data f

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Chuck D.
On October 25, 2007 10:57:49 am you wrote: > > If all you just want to do is strip out the ^M, you can run dos2unix on > it, assuming that you are running a *nix distro. Well, I guess I could strip the ^M but I'm still left with a $ in the middle of a field which in the same as the line terminato

[SQL] JOINing based on whether an IP address is contained within a CIDR range?

2007-10-25 Thread Jamie Tufnell
Hi, I am storing a log of HTTP requests in a database table (including IP address): http_log: id(PK), path, time, ip I have another table that contains CIDR ranges and names for them: network_names: id(PK), cidr, name Some example data for both tables: network_names: 1, 192.168.0.0/24, 'Engin

Re: [SQL] (repost) Help understanding expressions in order by clause

2007-10-25 Thread Tom Lane
Steve Midgley <[EMAIL PROTECTED]> writes: > select * from test_order > order by id <> 3, email > --sql end > Putting the expression "id <> 3" causes the id of 3 to sort to the TOP > of the list. This statement does the same thing: > select * from test_order > order by id = 3 DESC, email > I kno

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Bricklen Anderson
Chuck D. wrote: Pardon me on this, the cat -A report for the failed line (and subsequent lines) shows ^M$ within the field, not just $. I assume that is probably a \r\n and postgres wants \r for field data and \n to end a line. I've tried working this over with sed but can't get the syntax

[SQL] (repost) Help understanding expressions in order by clause

2007-10-25 Thread Steve Midgley
Hi, (I posted this to the list on 10/25 but it didn't seem to get distributed - apologies if it did and I'm actually double posting right now..) I've read on this list about some pretty powerful examples of using expressions in order by clauses to sort according to very complex rules. I kin

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Chuck D.
On October 25, 2007 09:35:23 am Chuck D. wrote: > On October 24, 2007 01:10:59 am Paul Lambert wrote: > > I get around this problem with my data loads by specifying some other > > arbitrary character that I know won't appear in the data as the quote > > character. > > > > Eg QUOTE E'\f' will specif

Re: [SQL] request for help with COPY syntax

2007-10-25 Thread Chuck D.
On October 24, 2007 01:10:59 am Paul Lambert wrote: > > I get around this problem with my data loads by specifying some other > arbitrary character that I know won't appear in the data as the quote > character. > > Eg QUOTE E'\f' will specify form feed as the quote character, ergo any > data with d

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

2007-10-25 Thread Erik Jones
On Oct 25, 2007, at 1:50 AM, Sébastien Meudec wrote: 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)

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

2007-10-25 Thread Filip Rembiałkowski
2007/10/25, Otniel Michael <[EMAIL PROTECTED]>: > OC. I will try to upgrade the postgres. What version that can fix this > problem? Postgres 8.2.5? Postgres 8.1? > > Now, i use postgres 8.0.3, what effect when i upgrade the postgres version? > I heared that i should check my sql? In postgres 8.0.3

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

2007-10-25 Thread Gregory Stark
"Tom Lane" <[EMAIL PROTECTED]> writes: > 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, possibl

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

2007-10-25 Thread Otniel Michael
Note: forwarded message attached. -- "He who is quick to become angry will commit folly, and a crafty man is hated" __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --- Begin Message --