[SQL] Why are these queries so different in time?

2005-07-29 Thread Olivier Hubaut
Hi, I have a question about performance querying a 7.4 database. The orginal generated query was SELECT DISTINCT _compound0.object_id AS "ObjectId" FROM amaze._compound _compound0 LEFT JOIN amaze._product _product7 ON (_compound0.object_id = _product7.compound) LEFT JOIN amaze._

[SQL] calling EXECUTE on any exception

2005-07-29 Thread gherzig
Hi all: I want to call some FUNCTION , let say exception_hanler(Exception_code) for any exception in plsql functions. I give some pseudo code to explain myself better: CREATE FUNCION something(...) returns ... AS ' ... EXCEPTION WHEN OTHER THEN EXECUTE exception_handler(Exception_code) ...

Re: [SQL] calling EXECUTE on any exception

2005-07-29 Thread Michael Fuhr
On Fri, Jul 29, 2005 at 10:36:52AM -0300, [EMAIL PROTECTED] wrote: > EXCEPTION > WHEN OTHER THEN > EXECUTE exception_handler(Exception_code) > > how do i get that error_code (or code_name, whatever i can get) > generated in the something() function to be proccesed by the > exception_handler()

Re: [SQL] Why are these queries so different in time?

2005-07-29 Thread Richard Huxton
Olivier Hubaut wrote: Hi, I have a question about performance querying a 7.4 database. The orginal generated query was SELECT DISTINCT _compound0.object_id AS "ObjectId" FROM (4 LEFT JOINS then a couple of WHERE conditions on 2 tables) This on take a huge time to perform, which may come to

Re: [SQL] calling EXECUTE on any exception

2005-07-29 Thread gherzig
Oh...to bad...Thank you Michael! Did someone know if it can be acomplished in pypgsql? Thanks againg falks. Gerardo > On Fri, Jul 29, 2005 at 10:36:52AM -0300, [EMAIL PROTECTED] wrote: >> EXCEPTION >> WHEN OTHER THEN >> EXECUTE exception_handler(Exception_code) >> >> how do i get that error_

[SQL] CREATE TABLE AS SELECT

2005-07-29 Thread Jeff Boes
Offered up because I have no explanation, and curiosity overwhelms me: I was attempting to create a table from a SELECT statement against another table: create table foo as select a, f(b) from xxx; The function f() attempts to make a unique value based on its argument (it's actually a "usernam

Re: [SQL] CREATE TABLE AS SELECT

2005-07-29 Thread daq
JB> Offered up because I have no explanation, and curiosity overwhelms me: JB> I was attempting to create a table from a SELECT statement against JB> another table: JB> create table foo JB> as select JB> a, JB> f(b) JB> from xxx; In this command table foo populated after the select statement

[SQL] How to loop though an array plpgsql?

2005-07-29 Thread Matthew Schumacher
I need to loop though an input array, but can't figure out how to do it, the docs aren't really clear on this. Something like this: CREATE FUNCTION update (_id INTEGER[]) RETURNS VOID AS $$ BEGIN FOR i IN SELECT _id LOOP INSERT INTO table VALUES (_id[i]); END LOOP; END; $$ LANGUAGE plpg

[SQL] bug in information_schema?

2005-07-29 Thread Kyle Bateman
I noticed that it seemed a bit slow to query information_schema.view_column_usage. As I look at the code in information_schema.sql, I'm not sure why pg_user is referenced twice (once without an alias). It looks like we can take out the first pg_user and remove the DISTINCT keyword and this i