Subject Re: A way to get a max of some calculated columns ?
Author csswa
--- In ib-support@y..., Amrita Chaudhury <achaudhu@s...> wrote:
> Hi All,
>
> Cashing in on the good spirits today, here's my plea for
> help :
>
> How can I generically get a max of 3 or four calculated
> values in a stored proc ?
>
> TIA,
> amrita .
>
>
> [Non-text portions of this message have been removed]

Here's a way to do it. May not be generic enough for you, but bend
it to your will.

CREATE PROCEDURE MAX_TEST
RETURNS (
RESULT DOUBLE PRECISION)
AS
DECLARE VARIABLE VAL1 DOUBLE PRECISION;
DECLARE VARIABLE VAL2 DOUBLE PRECISION;
DECLARE VARIABLE VAL3 DOUBLE PRECISION;
begin
SELECT MAX(T1.PCODE_PK),
MAX(T1.PCODE_POSTCODE),
MAX(T1.PCODE_REGION_FK)
FROM T_POSTCODE T1
INTO :VAL1, :VAL2, :VAL3;
RESULT = VAL1;
IF (VAL2 > RESULT) THEN RESULT = VAL2;
IF (VAL3 > RESULT) THEN RESULT = VAL3;
EXIT;
end

Regards,
Andrew Ferguson
-- Home of the pointy-headed dingus.