Mike Rylander <[EMAIL PROTECTED]> writes: > Here's mine: > CREATE FUNCTION max2 (INTEGER,INTEGER) RETURNS INTEGER > LANGUAGE SQL AS > 'SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END';
BTW, most of the standard datatypes have these already, because they are the transition functions for the MAX() and MIN() aggregates. The one above is int4larger(). regression=# \df *larger List of functions Result data type | Schema | Name | Argument data types -----------------------------+------------+--------------------+---------------------------------------------------------- money | pg_catalog | cashlarger | money, money date | pg_catalog | date_larger | date, date real | pg_catalog | float4larger | real, real double precision | pg_catalog | float8larger | double precision, double precision smallint | pg_catalog | int2larger | smallint, smallint integer | pg_catalog | int4larger | integer, integer bigint | pg_catalog | int8larger | bigint, bigint interval | pg_catalog | interval_larger | interval, interval numeric | pg_catalog | numeric_larger | numeric, numeric oid | pg_catalog | oidlarger | oid, oid text | pg_catalog | text_larger | text, text time without time zone | pg_catalog | time_larger | time without time zone, time without time zone timestamp without time zone | pg_catalog | timestamp_larger | timestamp without time zone, timestamp without time zone timestamp with time zone | pg_catalog | timestamptz_larger | timestamp with time zone, timestamp with time zone time with time zone | pg_catalog | timetz_larger | time with time zone, time with time zone (15 rows) All of these have matching xxxsmaller() as well. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])