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] sequence number in a result

2008-10-09 Thread Relyea, Mike
> Is there a function or special system label I can use that would generate a sequence number in the returning result set? Would something like this work for you? CREATE TEMP SEQUENCE foo; SELECT a, b, c, nextval('foo') AS order FROM t1 ORDER BY a; Mike Relyea Product Development Engineer Xe

Re: [SQL] trigger parameters, what am I doing wrong ??

2008-10-09 Thread Tom Lane
"Marcin Krawczyk" <[EMAIL PROTECTED]> writes: > And here's what RAISE NOTICE looks like : NOTICE: TG_ARGV = , > TG_NARGS = 0, par = > What's wrong with it ?? I'm running 8.1.4 Works for me: regression=# insert into test_table values(1); INSERT 0 1 regression=# update test_table set f1 = 2; NOTI

Re: [SQL] sequence number in a result

2008-10-09 Thread Tom Lane
"Campbell, Lance" <[EMAIL PROTECTED]> writes: > Is there a function or special system label I can use that would > generate a sequence number in the returning result set? The usual hack is a temporary sequence: regression=# create temp sequence s1; CREATE SEQUENCE regression=# select nextval('s1'

Re: [SQL] sequence number in a result

2008-10-09 Thread Oliveiros Cristina
Sorry, Lance By mistake I posted my own things, which I was using to "adapt" to your situation. :-) Please kindly ignore everything below my signature :p Best, Oliveiros - Original Message - From: Oliveiros Cristina To: Campbell, Lance ; pgsql-sql@postgresql.org Sent: Thursday,

Re: [SQL] sequence number in a result

2008-10-09 Thread Oliveiros Cristina
Howdy, Lance. I had that problem about a year ago, and AFAIK there is no solution, at least not in SQL Standard. What I did was something like SELECT a,b,c,count(y.a) as order FROM t1 x , t1 y WHERE ((x.a > y.a) OR (x.a = y.a AND x.ID <= y.ID)) -- Use here whatever you have as primary key

[SQL] sequence number in a result

2008-10-09 Thread Campbell, Lance
Say I have the following SQL statement: SELECT a, b, c FROM t1 ORDER BY a; Is there a function or special system label I can use that would generate a sequence number in the returning result set? Example: SELECT a, b, c, SOMELABEL as order FROM t1 ORDER BY a; Result: ab c

Re: [SQL] 100% CPU at concurent access

2008-10-09 Thread Sabin Coanda
Hi Tom, Well, I thought the connection with the failed transaction checks in a loop until the succeeded transaction will finish, and then it will succeeded as well. However, would you suggest me a code for "TestProcOuter" that works and fulfils my desire, please ? :) Thanx, Sabin -- Sen

[SQL] trigger parameters, what am I doing wrong ??

2008-10-09 Thread Marcin Krawczyk
Hi guys. I'm trying to pass a parameter to trigger procedure but it's not working and I have no idea why since it looks pretty ok. Here's what I do : CREATE OR REPLACE FUNCTION test_proc() RETURNS "trigger" AS $BODY$ DECLARE chk boolean; parinteger := TG_ARGV[0]; BEGIN RAISE NOTICE 'TG_