Re: [SQL] [HELP] Defining a function as a procedure

2006-01-26 Thread Tom Lane
"Daniel Caune" <[EMAIL PROTECTED]> writes: > Is there a way to define a function as a procedure, I mean a function > that returns nothing. In recent versions you can say RETURNS VOID, which is a bit of a hack but it gets the point across... regards, tom lane -

[SQL] [HELP] Defining a function as a procedure

2006-01-26 Thread Daniel Caune
Hi,   Is there a way to define a function as a procedure, I mean a function that returns nothing.   CREATE OR REPLACE FUNCTION foo() AS $$ BEGIN   END; $$ LANGUAGE 'plpgsql';   Actually, PostgreSQL complains as a “function result type must be specified”.  I can patch my function

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > How will the query planner do for a nesting query? Treat the > subqueries as multiple queries and then link them together? > where can I find the information (codes or documents)? Look at the execution plan using the EXPLAIN command. -- Peter Eisentraut http://developer.postgresq

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Andrew Sullivan
On Thu, Jan 26, 2006 at 01:51:27PM +0100, Markus Schaber wrote: > Hmm, are you shure that this is correct? The delete will always delete 0 > rows. Quite, and no it won't. The contrived example is actually a simplification of a case one of our developers implemented. The conflict is on the update

Re: [SQL] [PERFORM] Query optimization with X Y JOIN

2006-01-26 Thread Jaime Casanova
On 1/26/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > If I want my database to go faster, due to X then I would think that the > issue is about performance. I wasn't aware of a paticular constraint on X. > > I have more that a rudementary understanding of what's going on here, I was > just hop

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Stephan Szabo
On Thu, 26 Jan 2006, Markus Schaber wrote: > AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all, > the only way to introduce deadlocks is to issue LOCK commands to take > locks manually. And for this rare case, PostgreSQL contains a deadlock > detection routine that will abo

Re: [SQL] filtering after join

2006-01-26 Thread andrew
How will the query planner do for a nesting query? Treat the subqueries as multiple queries and then link them together? where can I find the information (codes or documents)? Thanks. On 1/26/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > But the function foo() would produce di

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Markus Schaber
Hi, Andrew, Andrew Sullivan wrote: >>AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all, >>the only way to introduce deadlocks is to issue LOCK commands to take >>locks manually. And for this rare case, PostgreSQL contains a deadlock >>detection routine that will abort one of

Re: [SQL] question with times and intervals

2006-01-26 Thread Andreas Kretschmer
Richard Huxton schrieb: > Now (upper_time - lower_time) is the interval you want and summing them > will give you your answer. > > Any help? Yes, thanks. But, i remember a little function that i wrote in the past: http://a-kretschmer.de/tools/time_intersect.sql And now i have a solution (i h

Re: [SQL] question with times and intervals

2006-01-26 Thread Richard Huxton
A. Kretschmer wrote: Hi, I have a table like this: test=# select * from status_log ; id | status |t_start | t_end +++ 1 | 1 | 2006-01-20 23:00:00+01 | 2006-01-21 06:00:00+01 1 | 1 | 2006-01-21 06:

[SQL] question with times and intervals

2006-01-26 Thread A. Kretschmer
Hi, I have a table like this: test=# select * from status_log ; id | status |t_start | t_end +++ 1 | 1 | 2006-01-20 23:00:00+01 | 2006-01-21 06:00:00+01 1 | 1 | 2006-01-21 06:00:00+01 | 2006-01-21 2

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Andrew Sullivan
On Thu, Jan 26, 2006 at 10:42:54AM +0100, Markus Schaber wrote: > AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all, > the only way to introduce deadlocks is to issue LOCK commands to take > locks manually. And for this rare case, PostgreSQL contains a deadlock > detection ro

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > But the function foo() would produce different values for the two > queries, so the result will be different. > A simple example is foo() computes the sum of all the integer fields > of the input record. OK, I see now where you're getting at. You want to combine the record type o

Re: [SQL] filtering after join

2006-01-26 Thread andrew
But the function foo() would produce different values for the two queries, so the result will be different. A simple example is foo() computes the sum of all the integer fields of the input record. On 1/26/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > Sorry for the confusion.

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > Sorry for the confusion. This is what i meant. Thanks, Michael. > > select * > from (select * from A, B where A.a = B.b) as s > where foo(s) < 2; > > On 1/25/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > > andrew wrote: > > > I want to use a UDF to filter tuples t that are gener

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Markus Schaber
Hi, Mario, My explanation is a little longer, as I think I must at least basically explain some of the fundamentals of database synchronization. Mario Splivalo wrote: >>>Is it possible to change the transaction level within the procedure? >>No, currently not, the PostgreSQL "stored procedures" r

Re: [SQL] Changing the transaction isolation level within the

2006-01-26 Thread Markus Schaber
Hi, Mario, Mario Splivalo wrote: >>you need to set the transaction level after the begin and before every >>other statement... after the begin you have a select that invoke your >>function so that set is not the first statement... > > But I can't do that inside of a function, right? Right, as y