[GENERAL] 'greatest' function?

2007-02-07 Thread jws
Is there any buil-in function to return the lesser of two numbers? i.e. lesser(100,125) would return 100. Do I need to roll my own? ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an inde

Re: [GENERAL] 'greatest' function?

2007-02-07 Thread jws
> Uh, what function in that table helps him --- I don't see it. I found GREATEST() and LEAST(), which in combination with COALESCE() returns exactly what I needed. I missed it because I was looking for numerical functions. Like so many other things in life, in retrospect, it's completely obvious.

[GENERAL] temp tables in functions?

2007-02-07 Thread jws
Having developed a complex query, I want to wrap it up as a function so that it can take a parameter and return a set of rows. This query is currently written as multiple sql statements that create a few interstitial temp tables that are then joined. If I put this into a function definition, do tho

[GENERAL] bytea characteristics

2007-02-09 Thread jws
Are there any known guidelines regarding storing images in a bytea column vs simply storing the meta-data? Do the images take up a certain percentage more space due to the on- disk format when stored this way? ---(end of broadcast)--- TIP 2: Don't

[GENERAL] Can psql show me where my script is broken?

2007-03-08 Thread jws
I have an enormous sql script with an incorrect insert line somewhere. I can echo the commands to stdout as they are executed, but apparently errors go to stderr. How can I determine where the problem is? ---(end of broadcast)--- TIP 2: Don't 'kill

[GENERAL] make cascade the default?

2007-03-08 Thread jws
Is there a way at to set the 'on delete' and 'on update' options at the database or table level, so that any new foreign keys default to, say 'CASCADE', rather than 'no action'? ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[GENERAL] Rounding datetimes

2007-05-22 Thread jws
Is there a way to round an interval to the nearest minute or do I need to create a function for this? ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings