Re: [SQL] rule causes nextval() to be invoked twice

2003-07-22 Thread Tom Lane
paul cannon <[EMAIL PROTECTED]> writes: > I'm having trouble understanding the behavior of rules with regards to > default values. > ... > If I remove the REFERENCES constraint, then I can see why. The insert > made into main behaves as expected; it gets nextval('main_id_seq'), > which comes out to

Re: [SQL] rule causes nextval() to be invoked twice

2003-07-22 Thread paul cannon
On Tue, Jul 22, 2003 at 07:47:00PM -0600, paul cannon wrote: > Until then, I'll have to make a function to do nextval('main_id_seq') > with every insert, and have the primary key be INTEGER. Nevermind- that doesn't work either! Here's the new sample code: -- Begin demo SQL CREATE SEQUENCE main_i

[SQL] rule causes nextval() to be invoked twice

2003-07-22 Thread paul cannon
'Sup list- I'm having trouble understanding the behavior of rules with regards to default values. Here's my situation: I have a table with a column referencing another. When inserts are made to the second, I would like a certain corresponding insert made to the first. Here's the simplest case I c

Re: [SQL] min() and NaN

2003-07-22 Thread Michael Tibbetts
Treating NaN's as larger(or smaller) than all ordinary values seems a fine way to go. It avoids the situation where you request MIN and get an ordinary value which is greater than the minimum ordinary value in the table. If MIN(or MAX given the ordering you're suggesting) returns NaN, the user

Re: [SQL] obtuse plpgsql function needs

2003-07-22 Thread Josh Berkus
Robert, > I'm starting to believe this is not possible, has anyone already done > it? :-) It sounds doable but you need more explicit examples; I can't quite tell what you're trying to do. -- Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)---

Re: [SQL] obtuse plpgsql function needs

2003-07-22 Thread elein
You'll need to pass the values down to your concat function (which I suggest you don't call concat) and have it return a text type. What exactly is your problem? I must be missing something. elein On Tue, Jul 22, 2003 at 06:31:52PM -0400, Robert Treat wrote: > given > > create table t1 (f,f1,

[SQL] obtuse plpgsql function needs

2003-07-22 Thread Robert Treat
given create table t1 (f,f1,f2,f3); create table t2 (f,f4,f5,f6); i'm trying to create a function concat() that does something like: select f,concat() as info from t1; which returns a result set equivalent to: select f,('f1:' || f1 || '- f2:' || f2 || '- f3:' || f3) as x from t1; or select f,

Re: [SQL] min() and NaN

2003-07-22 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Well, my 2 cents is that though we consider NULL when ordering via ORDER > > BY, we ignore it in MAX because it really isn't a value, and NaN seems > > to be similar to NULL. > > Good idea, but I don't think we can get away with it.

Re: [SQL] min() and NaN

2003-07-22 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Well, my 2 cents is that though we consider NULL when ordering via ORDER > BY, we ignore it in MAX because it really isn't a value, and NaN seems > to be similar to NULL. Good idea, but I don't think we can get away with it. The spec says that MAX/MIN h

Re: [SQL] min() and NaN

2003-07-22 Thread Bruce Momjian
Stephan Szabo wrote: > > On Tue, 22 Jul 2003, Bruce Momjian wrote: > > > Well, my 2 cents is that though we consider NULL when ordering via ORDER > > BY, we ignore it in MAX because it really isn't a value, and NaN seems > > to be similar to NULL. > > > > When doing ORDER BY, we have to put the N

Re: [SQL] min() and NaN

2003-07-22 Thread Jean-Luc Lachance
Hey! here is a (stupid maybe) idea. Why not disallow 'NaN' for a float? JLL Stephan Szabo wrote: > > On Tue, 22 Jul 2003, Bruce Momjian wrote: > > > Well, my 2 cents is that though we consider NULL when ordering via ORDER > > BY, we ignore it in MAX because it really isn't a value, and NaN

Re: [SQL] min() and NaN

2003-07-22 Thread Stephan Szabo
On Tue, 22 Jul 2003, Bruce Momjian wrote: > Well, my 2 cents is that though we consider NULL when ordering via ORDER > BY, we ignore it in MAX because it really isn't a value, and NaN seems > to be similar to NULL. > > When doing ORDER BY, we have to put the NULL value somewhere, so we put > it a

Re: [SQL] slow query

2003-07-22 Thread Markus Bertheau
I'm trying to explain the bigger function a bit although it's only called in 2% of the cases. В Втр, 22.07.2003, в 19:07, Markus Bertheau пишет: > CREATE FUNCTION iGetNumOfBookedRes(integer, timestamp, timestamp) RETURNS numeric AS > ' > SELECT > CASE WHEN (MAX(kumulierte) IS NULL) THEN 0 E

[SQL] slow query

2003-07-22 Thread Markus Bertheau
Hi, we have this large query about which we want to know if it can be made faster. The query is: select * from ( select ressourcen.*, gebaeude.bezeichnung as "gebaeude.bezeichnung", gebaeude.gebaeude_id as "gebaeude.gebaeude_id", gebaeude.kurzbezeichnung as "gebaeude.kurzbezeichnu

Re: [SQL] min() and NaN

2003-07-22 Thread Bruce Momjian
Well, my 2 cents is that though we consider NULL when ordering via ORDER BY, we ignore it in MAX because it really isn't a value, and NaN seems to be similar to NULL. When doing ORDER BY, we have to put the NULL value somewhere, so we put it at the end, but with aggregates, we aren't required to

Re: [SQL] How access to array component

2003-07-22 Thread Cristian Cappo A.
Thanks Joe.. -- On 21 Jul 2003 at 22:09, Joe Conway wrote: > Cristian Cappo A. wrote: > > Tried, but... > > >> select (foo(10::int2,20::int2))[1]; > > >> ERROR: parser: parse error at or near "[" at character 32 > > > > I'm using the version 7.3.3 > > Sorry, it works on 7.4devel, so I

Re: [SQL] time delay function

2003-07-22 Thread Peter Eisentraut
Girish Bajaj writes: > In pgplsql, Im looking for something like a function that I can use to > make the process to wait for 20 secs before continuing to execute the > next sql statment? There is no built-in support for that, but you could write your own function in C that accomplishes that, for

Re: [SQL] time delay function

2003-07-22 Thread Christoph Haller
> > Pseudo code: > > begin trans > select * from table1 > WAIT FOR 20 SECS > update table1 set blah = 'blah' > end transcation > > In pgplsql, Im looking for something like a function that I can use to make the process to wait for 20 secs before con tinuing to execute the next sql statment? > AFAIK

[SQL] time delay function

2003-07-22 Thread Girish Bajaj
Pseudo code: begin trans select * from table1 WAIT FOR 20 SECS update table1 set blah = 'blah' end transcation In pgplsql, Im looking for something like a function that I can use to make the process to wait for 20 secs before continuing to execute the next sql statment? Thanks, Girish -