Re: [SQL] How to count from a second table in an aggregate query?

2009-04-17 Thread Steve Midgley
Date: Wed, 15 Apr 2009 21:23:04 -0700 From: Steve Midgley scie...@misuse.org To: Erik Jones ejo...@engineyard.com Subject: Re: How to count from a second table in an aggregate query? Message-ID: 49e6b2a8.5040...@misuse.org Erik Jones wrote: On Apr 15, 2009, at 1:15 PM, Steve Midgley wrote

[SQL] How to count from a second table in an aggregate query?

2009-04-15 Thread Steve Midgley
Hi, I'm trying to figure out how to do something which I'd guess is easy for a sql whiz but has me stumped. I would greatly appreciate any help on this - it's a form of SQL query that I've never figured out, but have wanted to use many times over the years.. I want to generate an analysis

Re: [SQL] How to count from a second table in an aggregate query?

2009-04-15 Thread Steve Midgley
Erik Jones wrote: On Apr 15, 2009, at 1:15 PM, Steve Midgley wrote: I want to generate an analysis report that counts the values in two separate tables. I've been able to accomplish what I want with two separate queries that I then merge together in Excel. Essentially what I need

Re: [SQL] changing multiple pk's in one update

2009-04-14 Thread Steve Midgley
Date: Mon, 13 Apr 2009 17:09:49 -0400 From: Glenn Maynard glennfmayn...@gmail.com To: pgsql-sql@postgresql.org Subject: Re: changing multiple pk's in one update Message-ID: d18085b50904131409g10d43d6cs35dd14ede13b...@mail.gmail.com (JMdict? I was playing with importing that into a DB a while

Re: [SQL] Nested selects

2009-04-09 Thread Steve Midgley
pgsql-sql-ow...@postgresql.org wrote: Date: Tue, 7 Apr 2009 22:34:38 -0400 From: Glenn Maynard glennfmayn...@gmail.com To: pgsql-sql@postgresql.org Subject: Nested selects Message-ID: d18085b50904071934g7ad206f1i14ac05f7bd29f...@mail.gmail.com I'm deriving high scores from two tables: one

Re: [SQL] Can we load all database objects in memory?

2009-03-26 Thread Steve Midgley
At 09:20 AM 3/26/2009, pgsql-sql-ow...@postgresql.org wrote: Message-Id: 587e5df3-5859-48de-93f9-f7b05c37e...@rvt.dds.nl From: ries van Twisk p...@rvt.dds.nl To: DM dm.a...@gmail.com In-Reply-To: eae6a62a0903251220p2edd379en50d17541edef0...@mail.gmail.com Subject: Re: Can we load all database

Re: [SQL] Alter Table/Indexing

2009-03-25 Thread Steve Midgley
At 02:20 AM 3/25/2009, pgsql-sql-ow...@postgresql.org wrote: To: Zdravko Balorda zdravko.balo...@siix.com cc: pgsql-sql@postgresql.org Subject: Re: Alter Table/Indexing In-reply-to: 49c89fea.8060...@siix.com References: 49c89fea.8060...@siix.com Comments: In-reply-to Zdravko Balorda

Re: [SQL] Exclude fields from SELECT command

2009-03-17 Thread Steve Midgley
At 05:20 PM 3/16/2009, pgsql-sql-ow...@postgresql.org wrote: In-Reply-To: 1992170861895942...@unknownmsgid References: 1992170861895942...@unknownmsgid Date: Mon, 16 Mar 2009 22:45:54 +0100 Message-ID: 162867790903161445i78127316s1c0deb3bec0e1...@mail.gmail.com Subject: Re: Exclude fields from

[SQL] Re: select count of all overlapping geometries and return 0 if none.

2009-03-13 Thread Steve Midgley
At 06:20 AM 3/13/2009, pgsql-sql-ow...@postgresql.org wrote: Message-ID: 457532.70947...@web45913.mail.sp1.yahoo.com Date: Thu, 12 Mar 2009 10:28:19 -0700 (PDT) From: Duffer Do dufferd...@yahoo.com Subject: select count of all overlapping geometries and return 0 if none. To:

Re: [SQL] Best practices for geo-spatial city name searches?

2009-02-25 Thread Steve Midgley
At 08:20 AM 2/25/2009, pgsql-sql-ow...@postgresql.org wrote: To: pgsql-sql@postgresql.org From: Mark Stosberg m...@summersault.com Subject: Best practices for geo-spatial city name searches? Date: Tue, 24 Feb 2009 11:19:56 -0500 Message-ID: 20090224111956.5b7a4...@summersault.com

Re: [SQL] problem using twice custom comparision operator

2009-01-25 Thread Steve Midgley
At 01:20 PM 1/24/2009, pgsql-sql-ow...@postgresql.org wrote: From: Marek Florianczyk fra...@adm.tp.pl Organization: TP SA To: pgsql-sql@postgresql.org Subject: problem using twice custom comparision operator Date: Fri, 23 Jan 2009 21:42:44 +0100 Message-Id: 200901232142.44102.fra...@adm.tp.pl

[SQL] Re: some howto/theory book/tutorial on practical problem solving in SQL

2009-01-14 Thread Steve Midgley
At 09:20 AM 1/14/2009, pgsql-sql-ow...@postgresql.org wrote: Date: Wed, 14 Jan 2009 12:05:29 +0100 From: Ivan Sergio Borgonovo m...@webthatworks.it To: pgsql-sql@postgresql.org Subject: Re: some howto/theory book/tutorial on practical problem solving in SQL Message-ID:

Re: [SQL] How to excute dynamically a generated SQL command?

2009-01-05 Thread Steve Midgley
At 10:20 AM 1/4/2009, pgsql-sql-ow...@postgresql.org wrote: Message-ID: 618950b80901031757l15109658kdae1cdb0814d3...@mail.gmail.com Date: Sat, 3 Jan 2009 17:57:32 -0800 From: John Zhang johnzhan...@gmail.com To: postgis-us...@postgis.refractions.net Subject: How to excute dynamically a

Re: [SQL] Question on Escape-string

2009-01-03 Thread Steve Midgley
At 05:20 AM 1/1/2009, pgsql-sql-ow...@postgresql.org wrote: To: pgsql-sql@postgresql.org Subject: Question on Escape-string X-Archive-Number: 200812/132 X-Sequence-Number: 32082 Dear all, I am using pl/pgsql to develop a function to implement some logic to load BLOB data, like .tif file, to

Re: [SQL] Best way to and from a one-to-many joined table?

2008-12-07 Thread Steve Midgley
At 11:20 AM 12/6/2008, [EMAIL PROTECTED] wrote: Message-ID: [EMAIL PROTECTED] From: Oliveiros Cristina [EMAIL PROTECTED] To: Bryce Nesbitt [EMAIL PROTECTED], sql pgsql pgsql-sql@postgresql.org References: [EMAIL PROTECTED] Subject: Re: Best way to and from a one-to-many joined table?

Re: [SQL] Sequence and nextval problem

2008-11-25 Thread Steve Midgley
At 11:20 PM 11/24/2008, [EMAIL PROTECTED] wrote: Message-Id: [EMAIL PROTECTED] From: ries van Twisk [EMAIL PROTECTED] To: Tk421 [EMAIL PROTECTED] In-Reply-To: [EMAIL PROTECTED] Subject: Re: Sequence and nextval problem Date: Mon, 24 Nov 2008 16:21:40 -0500 References: [EMAIL PROTECTED]

Re: [SQL] grouping/clustering query

2008-10-23 Thread Steve Midgley
At 10:20 PM 10/22/2008, you wrote: Message-ID: [EMAIL PROTECTED] Date: Wed, 22 Oct 2008 12:14:49 +0700 From: David Garamond [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: grouping/clustering query X-Archive-Number: 200810/89 X-Sequence-Number: 31731 Dear all, I have an invoices (inv)

Re: [SQL] many-to-many relationship

2008-10-09 Thread Steve Midgley
At 05:20 PM 10/8/2008, [EMAIL PROTECTED] wrote: Date: Wed, 8 Oct 2008 11:25:10 +0200 From: Louis-David Mitterrand [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Re: many-to-many relationship Message-ID: [EMAIL PROTECTED] Mail-Followup-To: pgsql-sql@postgresql.org References: [EMAIL

Re: [SQL] many-to-many relationship

2008-10-07 Thread Steve Midgley
At 06:20 AM 10/7/2008, [EMAIL PROTECTED] wrote: Date: Mon, 6 Oct 2008 15:08:02 +0200 From: Louis-David Mitterrand [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: many-to-many relationship Message-ID: [EMAIL PROTECTED] X-Archive-Number: 200810/13 X-Sequence-Number: 31655 Hi, Say you

Re: [SQL] Finding sequential records

2008-09-30 Thread Steve Midgley
At 09:50 PM 9/29/2008, Richard Broersma wrote: On Mon, Sep 29, 2008 at 7:48 PM, Steve Midgley [EMAIL PROTECTED] wrote: In my specific case it turns out I only had duplicates, but there could have been n-plicates, so your code is still correct for my use-case (though I didn't say

Re: [SQL] Finding sequential records

2008-09-29 Thread Steve Midgley
At 05:38 PM 9/26/2008, Oliveiros Cristina wrote: In-Reply-To: [EMAIL PROTECTED] References: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Howdy, Steve. SELECT id FROM dummy a NATURAL JOIN ( SELECT fkey_id,name FROM dummy GROUP BY fkey_id,name HAVING COUNT(*) 1 AND

[SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
Hi, I've been kicking this around today and I can't think of a way to solve my problem in pure SQL (i.e. I can only do it with a looping/cursor-type solution and some variables). Given a table with this DDL/data script: drop table if exists dummy; create table dummy ( id integer primary

Re: [SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
advice on either of these solutions. I'm going to learn a lot here if someone can pound it into my head. Thanks, Steve It seems to be returning any records that have sequential id's regardless At 11:02 AM 9/26/2008, Richard Broersma wrote: On Fri, Sep 26, 2008 at 10:39 AM, Steve Midgley [EMAIL

Re: [SQL] surrogate vs natural primary keys

2008-09-19 Thread Steve Midgley
At 08:20 AM 9/18/2008, [EMAIL PROTECTED] wrote: Message-ID: [EMAIL PROTECTED] Date: Wed, 17 Sep 2008 09:20:44 -0700 From: Richard Broersma [EMAIL PROTECTED] To: Scott Marlowe [EMAIL PROTECTED] Subject: Re: surrogate vs natural primary keys In-Reply-To: [EMAIL PROTECTED] References: [EMAIL

Re: [SQL] surrogate vs natural primary keys

2008-09-17 Thread Steve Midgley
To: pgsql-sql@postgresql.org From: Seb [EMAIL PROTECTED] Subject: Re: surrogate vs natural primary keys Date: Mon, 15 Sep 2008 17:56:31 -0500 Organization: Church of Emacs Lines: 20 Message-ID: [EMAIL PROTECTED] References: [EMAIL PROTECTED] [EMAIL PROTECTED] X-Archive-Number:

Re: [SQL] Join question

2008-08-15 Thread Steve Midgley
At 12:20 PM 8/15/2008, [EMAIL PROTECTED] wrote: Date: Fri, 15 Aug 2008 13:46:14 -0400 From: Edward W. Rouse [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Re: Join question Message-ID: [EMAIL PROTECTED] I did try that, but I can't get both the values from table a with no entries in

Re: [SQL] DELETE with JOIN

2008-08-07 Thread Steve Midgley
At 10:05 AM 8/7/2008, [EMAIL PROTECTED] wrote: Date: Thu, 7 Aug 2008 09:14:49 -0700 From: [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: DELETE with JOIN Message-ID: [EMAIL PROTECTED] I want to delete with a join condition. Google shows this is a common problem, but the only solutions

Re: [SQL] Problem with ORDER BY and DISTINCT ON

2008-07-31 Thread Steve Midgley
At 03:51 PM 7/31/2008, Tom Lane wrote: Steve Midgley [EMAIL PROTECTED] writes: At 07:29 AM 7/16/2008, Tom Lane wrote: I think what is happening is that ORDER BY knows that and gets rid of the duplicate entries while DISTINCT ON fails to do so. Of course removing the duplicate from both

Re: [SQL] index for group by

2008-07-22 Thread Steve Midgley
At 09:20 AM 7/22/2008, [EMAIL PROTECTED] wrote: Date: Tue, 22 Jul 2008 13:27:24 +0200 From: A. Kretschmer [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Re: index for group by Message-ID: [EMAIL PROTECTED] am Tue, dem 22.07.2008, um 13:18:30 +0200 mailte Patrick Scharrenberg

[SQL] Problem with ORDER BY and DISTINCT ON

2008-07-16 Thread Steve Midgley
Hi, I'm a little baffled. I'm trying to generate a SQL statement that issues a DISTINCT ON using the same values as my ORDER BY statement. I'm using a somewhat complex CASE statement in my ORDER BY clause. I'm on Pg 8.2. Here is some SQL to get you started at seeing my problem:

Re: [SQL] Copyright and Paper walls (was: Rollback in Postgres)

2008-07-12 Thread Steve Midgley
At 11:59 AM 7/12/2008, [EMAIL PROTECTED] wrote: Date: Sat, 12 Jul 2008 10:20:37 +0100 From: Simon Riggs [EMAIL PROTECTED] To: Dave Page [EMAIL PROTECTED] Cc: Lewis Cunningham [EMAIL PROTECTED], Scott Marlowe [EMAIL PROTECTED], samantha mahindrakar [EMAIL PROTECTED], pgsql-sql@postgresql.org

Re: [SQL] PERSISTANT PREPARE (another point of view)

2008-07-11 Thread Steve Midgley
At 04:31 PM 7/11/2008, [EMAIL PROTECTED] wrote: Date: Fri, 11 Jul 2008 23:31:03 + From: Milan Oparnica [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: PERSISTANT PREPARE (another point of view) Message-ID: [EMAIL PROTECTED] [snip] What could we gain by introducing a kind of global

Re: [SQL] ANSI Standard

2008-06-26 Thread Steve Midgley
At 02:20 AM 6/25/2008, [EMAIL PROTECTED] wrote: Date: Tue, 24 Jun 2008 17:33:11 +0300 From: Pascal Tufenkji [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: ANSI Standard Message-ID: [EMAIL PROTECTED] Hi, How do I know if a function (or a certain sql syntax) in Postgres is a SQL ANSI

Re: [SQL] Tsearch

2008-06-12 Thread Steve Midgley
At 12:20 PM 6/12/2008, [EMAIL PROTECTED] wrote: Date: Thu, 12 Jun 2008 08:47:44 -0400 From: PostgreSQL Admin [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Tsearch Message-ID: [EMAIL PROTECTED] this is a small sample of the data: short_desc |

Re: [SQL] Conceptual Design Question

2008-06-10 Thread Steve Midgley
At 10:52 AM 6/10/2008, [EMAIL PROTECTED] wrote: Date: Tue, 10 Jun 2008 05:05:24 -0700 From: Bryan Emrys [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Conceptual Design Question Message-ID: [EMAIL PROTECTED] Hello Everyone, In a text-heavy database, I'm trying to make an initial

Re: [SQL] design resource

2008-06-06 Thread Steve Midgley
At 11:20 PM 6/5/2008, [EMAIL PROTECTED] wrote: Date: Thu, 5 Jun 2008 10:14:04 -0400 From: Edward W. Rouse [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: design resource Message-ID: [EMAIL PROTECTED] I was wondering if there were any resources that have some table designs for common

Re: [SQL] Extremely Low performance with ODBC

2008-05-28 Thread Steve Midgley
At 09:20 PM 5/27/2008, [EMAIL PROTECTED] wrote: Date: Tue, 27 May 2008 09:29:56 -0700 From: Richard Broersma [EMAIL PROTECTED] To: Sebastian Rychter [EMAIL PROTECTED] Cc: pgsql-sql@postgresql.org Subject: Re: Extremely Low performance with ODBC Message-ID: [EMAIL PROTECTED] On Mon, May 26,

Re: [SQL] Extremely Low performance with ODBC

2008-05-28 Thread Steve Midgley
At 09:20 PM 5/27/2008, [EMAIL PROTECTED] wrote: Date: Tue, 27 May 2008 09:29:56 -0700 From: Richard Broersma [EMAIL PROTECTED] To: Sebastian Rychter [EMAIL PROTECTED] Cc: pgsql-sql@postgresql.org Subject: Re: Extremely Low performance with ODBC Message-ID: [EMAIL PROTECTED] On Mon, May 26,

Re: [SQL] export CSV file through Java JDBC

2008-04-15 Thread Steve Midgley
At 07:20 AM 4/15/2008, you wrote: Date: Mon, 14 Apr 2008 09:41:41 -0400 From: Emi Lu [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: export CSV file through Java JDBC Message-ID: [EMAIL PROTECTED] Good morning, Running the following command from command line is ok, but cannot export

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread Steve Midgley
At 06:47 AM 3/19/2008, D'Arcy J.M. Cain wrote: But your suggestion was to base this key on the serial primary key so where is your index collision protection? You are going to get collisions on both the serial key and, to a lesser extent, your generated one. Besides, has anyone ever

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Steve Midgley
At 11:58 AM 3/18/2008, [EMAIL PROTECTED] wrote: Date: Tue, 18 Mar 2008 13:40:42 -0500 From: Campbell, Lance [EMAIL PROTECTED] To: Vivek Khera [EMAIL PROTECTED], pgsql-sql@postgresql.org Subject: Re: Create on insert a unique random number Message-ID: [EMAIL PROTECTED] Thanks for all

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Steve Midgley
At 12:36 PM 3/18/2008, D'Arcy J.M. Cain wrote: On Tue, 18 Mar 2008 12:23:35 -0700 Steve Midgley [EMAIL PROTECTED] wrote: 1) Create a second field (as someone recommend on this list) that is an MD5 of your primary key. Use that as your accessor index from the web I strongly disagree

Re: [SQL] Insert problem

2008-03-10 Thread Steve Midgley
At 09:20 AM 3/10/2008, [EMAIL PROTECTED] wrote: Date: Mon, 10 Mar 2008 00:14:12 + From: Jamie Tufnell [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Re: Insert problem Message-ID: [EMAIL PROTECTED] [snip] table defination create sequence schItem_item_seq create table schItem

Re: [SQL] works but ...

2008-03-10 Thread Steve Midgley
At 02:49 PM 3/10/2008, A. R. Van Hook wrote: The following code seems to work but it leads to the following question(s): Is there a sequence for each scid,item or is there one sequence that must be reset when changing scid? $cmd = select setval('schItem_item_seq', (select max(item)+1 from

Re: [SQL] using copy from in function

2008-03-05 Thread Steve Midgley
At 03:20 AM 3/5/2008, [EMAIL PROTECTED] wrote: Date: Wed, 5 Mar 2008 01:51:19 +0300 From: Yura Gal [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: using copy from in function Message-ID: [EMAIL PROTECTED] I'm trying to automate import data using CORY FROM. For this purpose I wrote

Re: [SQL] Usage of UUID with 8.3 (Windows)

2008-02-12 Thread Steve Midgley
At 09:20 AM 2/12/2008, [EMAIL PROTECTED] wrote: Date: Mon, 11 Feb 2008 11:56:33 -0500 From: Tom Lane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: pgsql-sql@postgresql.org Subject: Re: Usage of UUID with 8.3 (Windows) Message-ID: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: Now, what do I have to

[SQL] Columns view? (Finding column names for a table)

2008-02-06 Thread Steve Midgley
Hi, I see this documentation item but can't figure out how to use it: http://www.postgresql.org/docs/8.2/interactive/infoschema-columns.html The view columns contains information about all table columns (or view columns) in the database. However, if I execute select columns; I get a not

Re: [SQL] accounting schema

2008-02-06 Thread Steve Midgley
At 05:09 PM 2/6/2008, [EMAIL PROTECTED] wrote: Date: Wed, 6 Feb 2008 17:08:54 -0800 From: Medi Montaseri [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: accounting schema Message-ID: [EMAIL PROTECTED] Hi, I am learning my way into Accounting and was wondering how Accounting

Re: [SQL] accounting schema

2008-02-06 Thread Steve Midgley
At 06:54 PM 2/6/2008, Medi Montaseri wrote: Thanks Steve... And finally you mentioned that bank accounts are tricky...can you expand on this please. After all I am under the impression that bank accounts are a corner stone of this whole book keeping...I mean...bank accounts have debits and

[SQL] Negative numbers for PK/ID's?

2008-02-05 Thread Steve Midgley
Hi, A while ago on a different SQL platform, I had the idea to use negative numbers as id's for certain system records that I didn't prefer to have interspersed with other records in a table. (For example, we had template records which we used to spawn new records, and rather than store them

[SQL] Re: Proposed archival read only trigger on rows - prevent history modification

2008-01-29 Thread Steve Midgley
At 07:50 PM 1/29/2008, [EMAIL PROTECTED] wrote: Date: Mon, 28 Jan 2008 20:16:35 -0800 From: Bryce Nesbitt [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Proposed archival read only trigger on rows - prevent history modification [snip] I'm considering building a protective mechanism,

Re: [SQL] improvements to query with hierarchical elements

2008-01-25 Thread Steve Midgley
At 07:24 PM 1/22/2008, you wrote: Hi all, I have created a little test database to help illustrate my situation. CREATE TABLE categories ( id integer NOT NULL, name character varying(255) NOT NULL, description character varying(255), vocabulary_id integer, derived boolean

Re: [SQL] improvements to query with hierarchical elements

2008-01-21 Thread Steve Midgley
Date: Sun, 20 Jan 2008 20:01:08 -0800 From: Ryan Wallace [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: improvements to query with hierarchical elements Message-ID: [EMAIL PROTECTED] Greetings, I have a complex query which I am trying to figure out the most efficient way of

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Steve Midgley
On Jan 13, 2008 8:51 PM, Steve Midgley mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: At 02:22 PM 1/13/2008, mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Date: Sat, 12 Jan 2008 14:21:00 -0800 From: Medi Montaseri mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] To: mailto:pgsql-sql

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Steve Midgley
; at character 59 Char 59 by the way is the first accurance of semi-colon as in #1; which is being caught by PG parser. Medi On Jan 14, 2008 12:18 PM, Steve Midgley mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: On Jan 13, 2008 8:51 PM, Steve Midgley mailto:[EMAIL PROTECTED][EMAIL PROTECTED

Re: [SQL] UTF8 encoding and non-text data types

2008-01-13 Thread Steve Midgley
At 02:22 PM 1/13/2008, [EMAIL PROTECTED] wrote: Date: Sat, 12 Jan 2008 14:21:00 -0800 From: Medi Montaseri [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: UTF8 encoding and non-text data types Message-ID: [EMAIL PROTECTED] I understand PG supports UTF-8 encoding and I have sucessfully

[SQL] Re: How to keep at-most N rows per group? periodic DELETEs or constraints or..?

2008-01-09 Thread Steve Midgley
At 07:20 AM 1/9/2008, [EMAIL PROTECTED] wrote: Date: Tue, 8 Jan 2008 17:41:18 + From: Jamie Tufnell [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: Re: How to keep at-most N rows per group? periodic DELETEs or constraints or..? Message-ID: [EMAIL PROTECTED] On 1/8/08, codeWarrior

[SQL] Re: How to keep at-most N rows per group? periodic DELETEs or constraints or..?

2008-01-08 Thread Steve Midgley
I think what you want is related to this post on how to create a FIFO queue in Postgres: http://people.planetpostgresql.org/greg/index.php?/archives/89-Implementing-a-queue-in-SQL-Postgres-version.html The major difference is that you want a FIFO queue per user_id, so the triggering code

[SQL] System catalog future changes

2007-12-18 Thread Steve Midgley
Hello again, Reading a previous recent post and answers called Describe Table got me thinking about a little piece of SQL I use in an application to get a list of all the tables for a specific namespace: select pg_class.relname as table_name from pg_class join pg_namespace on

Re: [SQL] System catalog future changes

2007-12-18 Thread Steve Midgley
Jones wrote: On Dec 18, 2007, at 10:53 AM, Steve Midgley wrote: Hello again, Reading a previous recent post and answers called Describe Table got me thinking about a little piece of SQL I use in an application to get a list of all the tables for a specific namespace: select pg_class.relname

Re: [SQL] Query design assistance - getting daily totals

2007-12-13 Thread Steve Midgley
Hi, Rodrigo is exactly right in my opinion. To provide a little more info on this calendar or day dimension idea.. You can create, for example, a time table dimension which stores every day of every year as a unique record (for as far into the future as you need). You can then associate

Re: [SQL] INSERT INTO relational tables

2007-12-08 Thread Steve Midgley
At 09:23 AM 12/7/2007, [EMAIL PROTECTED] wrote: Date: Fri, 07 Dec 2007 14:22:26 +0100 From: Stefan Scheidegger [EMAIL PROTECTED] To: pgsql-sql@postgresql.org Subject: INSERT INTO relational tables Message-ID: [EMAIL PROTECTED] Hi all I'm new to SQL and I'm facing a problem I can't find any

[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

[SQL] SQL performance help: self join or static var

2007-09-17 Thread Steve Midgley
Hi, Given a table (truncated some real fields for simplicity): CREATE TABLE city ( id serial NOT NULL, muni_city_id integer, post_code_city_id integer, alias_city_id integer, city_type character varying(15), post_code_type character varying(15), CONSTRAINT city_pkey PRIMARY KEY

Re: [SQL] raw data into table process

2007-08-22 Thread Steve Midgley
Hi, I'm not sure if you have access to a scripting language (like perl or ruby) but my experience is that if you transform the source text file into a secondary text file that postgres copy can read natively/directly into the data formats you want, the copy command will move everything into

Re: [SQL] Increment a sequence by more than one

2007-08-06 Thread Steve Midgley
Hi Peter, I struggled to implement Michael's suggestion to use CACHE in this regard when he made it but after your encouragement I've studied it more and you and he are both totally right - CACHE is designed to do exactly what I want. Here's the sample code so as to put this issue to bed and

[SQL] Increment a sequence by more than one

2007-08-03 Thread Steve Midgley
Hi, I'm writing an import app in a third party language. It's going to use copy to to move data from STDIN to a postgres (8.2) table. There are some complexities though: it's going to copy the records to a versioned table first, and then at a later time the records will be copied by a

Re: [SQL] Increment a sequence by more than one

2007-08-03 Thread Steve Midgley
that there's no way to solve this problem in an elegant manner even in a stored procedure? Your method seems to be as good as it's going to get? (Not that I'm complaining!) Thanks again - any thoughts are welcome, Steve At 08:01 PM 8/3/2007, Scott Marlowe wrote: On 8/3/07, Steve Midgley [EMAIL

[SQL] Race condition in resetting a sequence

2007-08-03 Thread Steve Midgley
at least understand that there's a potential bug here.. Thanks again, Steve At 08:42 PM 8/3/2007, Scott Marlowe wrote: On 8/3/07, Steve Midgley [EMAIL PROTECTED] wrote: Hi Scott, Thanks for this info (and Michael too!). Let me see if I understand your suggestion. I would run these three

[SQL] Selecting rows with static ordering

2007-04-26 Thread Steve Midgley
Hello, I have a strange problem (or one that I've never had before anyway). I am searching for a list of id's for a given table (these id values are generated at run-time and held statically in an application-local variable). From that application, I want to retrieve all those rows, and I

Re: [SQL] [pgsql-sql] Daily digest v1.2492 (19 messages)

2007-04-03 Thread Steve Midgley
Hi John, It sounds like a disk-bound operation, so cpu is not maxed out. I'm not clear on all the details of your operation but it sounds like you're using Java to do row-by-row based inserts, selects and updates within a transaction, from a file. This can be a very slow process if you have

Re: [SQL] Issue with copying data from a text file.

2007-03-21 Thread Steve Midgley
Hi, I think I had the exact same problem as you do a while back and I solved it by removing the header row and the CSV HEADER clause of the statement. For the large files I had, it was easier (for me) to remove the header row than it was to escape out all the quotes (or regen the file):

Re: [SQL] A form of inheritance with PostgreSQL

2007-03-09 Thread Steve Midgley
Hi Greg, While not in a C++ framework, you might find that it's not too hard to implement something similar in your system - It's called Single Table Inheritance. References to the Ruby on Rails implementation here: http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance It's based

Re: [SQL] GiST index question: performance

2007-03-06 Thread Steve Midgley
or insight here. Are C code patches or functions more of a risk to server stability/reliability than higher level code? Or am I speaking gibberish? Thanks, Steve At 01:01 AM 3/6/2007, Peter Eisentraut wrote: Steve Midgley wrote: my ISP that manages my Pg SQL server is (in my interests

[SQL] GiST index question: performance

2007-03-05 Thread Steve Midgley
Hi, First off, can I say how much I love GiST? It's already solved a few problems for me that seemed impossible to solve in real-time queries. Thanks to everyone who works on that project! I'm developing a geographic index based on a set of zip code boundaries. Points of interest (POI) will

Re: [SQL] GiST index question: performance

2007-03-05 Thread Steve Midgley
with whatever I uncover. I really do appreciate the help you've provided. Sincerely, Steve At 12:21 PM 3/5/2007, you wrote: On Mon, 5 Mar 2007, Steve Midgley wrote: Hi, First off, can I say how much I love GiST? It's already solved a few problems for me that seemed impossible to solve

Re: [SQL] COPY FROM query

2007-02-12 Thread Steve Midgley
Hi, For what it's worth, WindowsXP (at least) seems to currently support forward slashes at the OS level, so this Postgres behavior isn't as odd as it might seem. If you enclose your paths with double quote () marks, Windows will even accept Unix style paths for some instructions on the