Re: [SQL] trigger/for key help

2004-04-11 Thread Tom Lane
Bret Hughes <[EMAIL PROTECTED]> writes: > FWIW I tried to use alter table but could never get the parser to accept > $1 as a constraint name. I used single and double quotes as well as a > lame attempt \$1. Hm, "$1" works for me ... regression=# create table foo (f1 int primary key); NOTICE: CR

Re: [SQL] trigger/for key help

2004-04-11 Thread Bret Hughes
On Sun, 2004-04-11 at 17:00, Tom Lane wrote: > Bret Hughes <[EMAIL PROTECTED]> writes: > > elevating=# drop table test_types; > > ERROR: could not find tuple for constraint 2041971 > > > I can find no reference to these oids anywhere. > > You haven't looked very hard then ;-). I expect this is

Re: [SQL] trigger/for key help

2004-04-11 Thread Tom Lane
Bret Hughes <[EMAIL PROTECTED]> writes: > elevating=# drop table test_types; > ERROR: could not find tuple for constraint 2041971 > I can find no reference to these oids anywhere. You haven't looked very hard then ;-). I expect this is because pg_depend has links from the table to the constrain

Re: [SQL] cursors and for loops?

2004-04-11 Thread Dennis
Tom Lane writes: Something like LOOP FETCH ...; EXIT WHEN NOT found; ... END LOOP; Thank you! I tried finding documentation on "found" in this context and didn't come up with anything. Can you point me to where it is documented?

Re: [SQL] trigger/for key help

2004-04-11 Thread Bret Hughes
On Sun, 2004-04-11 at 10:17, Stephan Szabo wrote: > > On Sat, 11 Apr 2004, Bret Hughes wrote: > > > S*t s*t s*t. I have managed to screw up the system tables trying to > > delete a foreign key on a new table I was going to start using tomorrow. > > > > > > > elevating=# drop table diag_logs; >

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-11 Thread elein
No, it will not work twice in the same query as is. If you want to code two counter buckets and pass in some way to distinguish between the two yada yada yada it is possible. It is also possible to code this to do multi-level counting/breaks/calculations, etc. But the SD dictionary is by connect

Re: [SQL] cursors and for loops?

2004-04-11 Thread Tom Lane
"Dennis" <[EMAIL PROTECTED]> writes: > I am wondering if I can use a cursor in a for loop. Something like LOOP FETCH ...; EXIT WHEN NOT found; ... END LOOP; should do it. regards, tom lane -

Re: [SQL] trigger/for key help

2004-04-11 Thread Stephan Szabo
On Sat, 11 Apr 2004, Bret Hughes wrote: > S*t s*t s*t. I have managed to screw up the system tables trying to > delete a foreign key on a new table I was going to start using tomorrow. > > > elevating-# \d diag_logs > Table "diag_logs" > Column |

[SQL] cursors and for loops?

2004-04-11 Thread Dennis
Hello, I am wondering if I can use a cursor in a for loop. I haven't been able to get it to work. I am just beginning plpgsql and I am struggling here. I am trying to do this: create or replace function ttest(varchar) RETURNS varchar AS ' DECLARE parId ALIAS FOR $1; dennis varchar;