Re: [SQL] Sequence behaviour.

2001-06-18 Thread Tom Lane
Grant <[EMAIL PROTECTED]> writes: > Why is the following like it is? I would think that nextval would return 2 > in both instances, am I missing something here? :) Thanks! > binary_data=# create sequence test; > CREATE > binary_data=# select nextval('test'); > NOTICE: test.nextval: sequence was

[SQL] Sequence behaviour.

2001-06-18 Thread Grant
Why is the following like it is? I would think that nextval would return 2 in both instances, am I missing something here? :) Thanks! binary_data=# create sequence test; CREATE binary_data=# select nextval('test'); NOTICE: test.nextval: sequence was re-created nextval - 1 (1 row)

Re: [SQL] Referential Integrity Question (Delete/Insert duringTransaction)

2001-06-18 Thread Stephan Szabo
On Mon, 18 Jun 2001, Stef Telford wrote: > > I seem to have hit what i -think- may be a bug (but i am not crying > wolf jst yet ;). > > I have three tables. action, client and order_details. action has a primary > key 'order', client references action (along with adding the cli

Re: [SQL] Problems ensuring uniqueness?

2001-06-18 Thread Christopher Smith
On 18 Jun 2001 18:04:14 -0400, Tom Lane wrote: > Christopher Smith <[EMAIL PROTECTED]> writes: > >> Um ... surely that should be "if count > 0" ? Or was that just a > >> transcription error? > >> > >> This approach certainly ought to work as desired given the exclusive > >> lock, so a silly typo

Re: [SQL] Problems ensuring uniqueness?

2001-06-18 Thread Christopher Smith
On 18 Jun 2001 17:42:15 -0400, Tom Lane wrote: > Christopher Smith <[EMAIL PROTECTED]> writes: > Um ... surely that should be "if count > 0" ? Or was that just a > transcription error? > > This approach certainly ought to work as desired given the exclusive > lock, so a silly typo seems like a p

Re: [SQL] Problems ensuring uniqueness?

2001-06-18 Thread Tom Lane
Christopher Smith <[EMAIL PROTECTED]> writes: >> Um ... surely that should be "if count > 0" ? Or was that just a >> transcription error? >> >> This approach certainly ought to work as desired given the exclusive >> lock, so a silly typo seems like a plausible explanation... > Sorry, it is inde

Re: [SQL] Problems ensuring uniqueness?

2001-06-18 Thread Tom Lane
Christopher Smith <[EMAIL PROTECTED]> writes: > begin > lock table foo in access exclusive mode > select count(*) from foo where key1 = bar, key2 = baz > if count > 1 > rollback > else > insert into foo (key1, key2, other) values (bar, baz, stuff) > commit > Now, table foo has a prim

[SQL] Problems ensuring uniqueness?

2001-06-18 Thread Christopher Smith
Hi there. I'm currently using Postgresql 7.0.3, accessing using the JDBC drivers. I'm enforcing the most severe transaction isolation available (serializable). I'm currently doing something like the following (this is pseudo code, with the if being performed in Java): begin lock table foo in acce

Re: [SQL] Subselects, the Oracle way

2001-06-18 Thread Tom Lane
"Svenne Krap" <[EMAIL PROTECTED]> writes: > Is there any way to mimic the oracle way of subselect, especially > constructs like > select * from (select col1 as x, col2, col6 from t1 union select col2 > as x, col6, col2 from t2) y order by y.x That should work fine in 7.1 ...

[SQL] Referential Integrity Question (Delete/Insert during Transaction)

2001-06-18 Thread Stef Telford
hello again everyone, I seem to have hit what i -think- may be a bug (but i am not crying wolf jst yet ;). I have three tables. action, client and order_details. action has a primary key 'order', client references action (along with adding the client_id as part of its pr

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread The Hermit Hacker
Perfect, thank you ... i knew I was overlooking something obvious ... the query just flies now ... On Mon, 18 Jun 2001, Tom Lane wrote: > The Hermit Hacker <[EMAIL PROTECTED]> writes: > >> Try adding ... AND n.nid = 15748 ... to the WHERE. > > > n.nid is the note id ... nl.id is the contact id

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread Tom Lane
The Hermit Hacker <[EMAIL PROTECTED]> writes: >> Try adding ... AND n.nid = 15748 ... to the WHERE. > n.nid is the note id ... nl.id is the contact id ... Ooops, I misread "n.nid = nl.nid" as "n.nid = nl.id". Sorry for the bogus advice. Try rephrasing as FROM (note_links nl JOIN notes n ON (

Re: [SQL] Better Archives?

2001-06-18 Thread The Hermit Hacker
On Mon, 18 Jun 2001, Josh Berkus wrote: > HH: > > > Will try and get some time this week to do a major overhaul of the > > mhonarc > > side of the lists, as it looks like hell right now :( > > > > Why not just link to Oleg's version? It seems to work pretty well. Oleg's version is searchable,

[SQL] Subselects, the Oracle way

2001-06-18 Thread Svenne Krap
Hi, Is there any way to mimic the oracle way of subselect, especially constructs like select * from (select col1 as x, col2, col6 from t1 union select col2 as x, col6, col2 from t2) y order by y.x I am aware of the fact, that it is possible to accomplish through the use of tempoary tables,

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread Stephan Szabo
I think that using INNER JOIN between nl and n (on n.nid=nl.nid) or joining those tables in a subquery might work. On Mon, 18 Jun 2001, The Hermit Hacker wrote: > Is there some way to write the above so that it evaluates: > > WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.ty

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread The Hermit Hacker
On Mon, 18 Jun 2001, Tom Lane wrote: > The Hermit Hacker <[EMAIL PROTECTED]> writes: > > FROM note_links nl, notes n LEFT JOIN calendar c ON (n.nid = c.nid) > > WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.type = 'C') > > AND (nl.id = 15748 AND contact_lvl = 'c

Re: [SQL] Better Archives?

2001-06-18 Thread The Hermit Hacker
Okay, I *really* have to dive into the mhonarc archives and clean it out, but I just went through and added a link to fts from the 'head' pages for each list, so that ppl know where to go to search ... Will try and get some time this week to do a major overhaul of the mhonarc side of the lists,

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread Tom Lane
The Hermit Hacker <[EMAIL PROTECTED]> writes: > FROM note_links nl, notes n LEFT JOIN calendar c ON (n.nid = c.nid) > WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.type = 'C') > AND (nl.id = 15748 AND contact_lvl = 'company') > AND n.nid = nl.nid >

[SQL] LEFT JOIN ...

2001-06-18 Thread The Hermit Hacker
Morning ... I'm trying to wrack my brain over something here, and no matter how I try and look at it, I'm drawing a blank ... I have two tables that are dependent on each other: notes (86736 tuples) and note_links (173473 tuples) The relationship is that one no

Re: [SQL] Better Archives?

2001-06-18 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > One thing I've noticed lately is that our archives are extremely hard to > search ... Which archives are you using? Oleg Bartunov &co provide a very nice search engine at http://fts.postgresql.org/db/mw/ I frequently also use Geocrawler's archive at h

Re: [SQL] sum of string columns, why ?

2001-06-18 Thread Ross J. Reedstrom
On Wed, Jun 06, 2001 at 06:13:18PM -0300, Marcos Vaz - ( NewAge Group ) wrote: > I have one table with thwo columns, user and text, why sum all the text > fields of the one user ? I assume you mean 'how' not 'why'? You don't give a lot of detail, like what you mean by 'sum all the text'. One int

Re: [SQL] Better Archives?

2001-06-18 Thread Roberto Mello
On Mon, Jun 18, 2001 at 08:55:34AM -0700, Josh Berkus wrote: > > I'd like to stop doing this, and I'm sure that some newbies, directed to > the archives, give up on Postgres entirely for something with a better > online knowledge base. I think so too. > Is there anything we can do abou

[SQL] How to build a TRIGGER in POSTGERSQL

2001-06-18 Thread Ilan Fait
Title: How to build a TRIGGER in POSTGERSQL    Hi ,   I need some help in  building  trigger and information about sysdate (System date), any help will be appreciate.    1) I need to build a trigger that every time I insert into the table  one of the columns will  get +1 numb

[SQL] Inheritance: Performance & Indexes

2001-06-18 Thread Itai Zukerman
Just curious: create table a (x int4 primary key); create table a1 () inherits (a); [...] delete from a where x = 1000; I take it that this is equivalent to: delete from only a where x = 1000; delete from only a1 where x = 1000; In particular, for performance reasons I should try

Re: [SQL] casts and conversions

2001-06-18 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > And, just to throw a banana peel onto the sidewalk of argument, there is > even a reason to keep things the way they are. [ ... ] > Thus there's a good reason for the database to be indecisive about > float/numeric decisions, and good reason for you to