Re: [SQL] using top-level aggregate values in subqueries

2001-04-23 Thread Tom Lane
"Thomas F. O'Connell" <[EMAIL PROTECTED]> writes: > select f.id > from foo f, ola o > where f.id = ( > select max( b.id ) > from bar b > where b.bling = "i kiss you!" > ) > and o.id != ( > select max( b.id ) > from bar b > where b.bling = "i kiss you!" > ) > is

[SQL] using top-level aggregate values in subqueries

2001-04-23 Thread Thomas F. O'Connell
from the docs, i know that if you have two tables, foo and bar, you can write a query such as select f.bling from foo f where f.id = ( select max( b.id ) from bar b where b.bling = "i kiss you!" ); what i'm wondering is if you need that subquery in two places in a query

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Josh Berkus
Tom, > But how would KPSQL know what value the function might have returned? > Something fishy here ... did you check the postmaster log to see > whether > an error is really being reported or not? Actually, I haven't been able to get the postgresql log to work since I compiled RC2. I keep mea

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Josh Berkus
Tom, > This would clearly be a bug, but I cannot replicate the problem: > > regression=# SELECT fn_save_order_details (7703, '{34,29,40}','{TRUE, > TRUE, FALSE}'); > ERROR: referential integrity violation - key referenced > from order_details not found in orders > regression=# Always good to

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Always good to have you folks test something. This does appear to be a > bug ... in KPSQL (the KDE GUI for PSQL), not in Postgres. When I run it > through command-line PSQL, an error is returned; for some reason, KPSQL > returns the return value for th

Re: [SQL] pg_dump bug? (7.1)

2001-04-23 Thread Tom Lane
Cedar Cox <[EMAIL PROTECTED]> writes: > When I try to run pg_dump I get a segmentation fault. This only seems to > happen if the PGDATABASE environment variable is set and I don't supply > the database name on the command line. Fixed. regards, tom lane -

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Josh Berkus
Joe, > I'm not sure if this is what you're looking for, but in 7.1 you can > do > something like: > > INSERT INTO bar(barpk,foopk) VALUES(barpkval,foopkval); > GET DIAGNOSTICS rows = ROW_COUNT; > -- do something based on rows -- There's several other ways I can check, as well. Howe

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Joe Conway
> However, not all types of errors are so trapped. The most problematic > un-trapped error is referential integrity: if an INSERT or UPDATE fails > because of a referential integrity violation, the PL/pgSQL function will > still see the statement as a success and not error out. Example: > I'm

[SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Josh Berkus
Folks, I've run up against a problematic limitation of PL/pgSQL's error-handling ability which could force me to re-write about 25 custom functions. I'm hoping that you folks can show me a way around the situation. THE PROBLEM: PL/pgSQL handles errors though "Implied Transactions", whe

[SQL] pg_dump bug? (7.1)

2001-04-23 Thread Cedar Cox
Well, I finally decided to play around with 7.1. Here's the problem: When I try to run pg_dump I get a segmentation fault. This only seems to happen if the PGDATABASE environment variable is set and I don't supply the database name on the command line. If I unset PGDATABASE, I get a normal e

Re: [SQL] Re: Cursors in plpgsql

2001-04-23 Thread Richard Huxton
From: "Hans-Jürgen Schönig" <[EMAIL PROTECTED]> > Currently no real cursors are supported - you can build a workaround using > a loop - this works in most cases. > I have found a doc (a very good one) that describes porting from Oracle to > Postgres - accidentally I have lost the link but I remeb