Subject Making one row out of several
Author ainpoissee
Hi!

I do have SP which takes date as argument and return an integer. Now I
have to return an row per month with a column for each day... what is
the best way to do this? I'm looking for something like

CREATE PROCEDURE RepMonth(aAasta INTEGER, aKuu INTEGER)
RETURNS(Tooleping INTEGER,
P01 INTEGER, P02 INTEGER, P03 INTEGER, P04 INTEGER, P05
INTEGER, P06 INTEGER, P07 INTEGER,
P08 INTEGER, P09 INTEGER, P10 INTEGER, P11 INTEGER, P12
INTEGER, P13 INTEGER, P14 INTEGER,
P15 INTEGER, P16 INTEGER, P17 INTEGER, P18 INTEGER, P19
INTEGER, P20 INTEGER, P21 INTEGER,
P22 INTEGER, P23 INTEGER, P24 INTEGER, P25 INTEGER, P26
INTEGER, P27 INTEGER, P28 INTEGER,
P29 INTEGER, P30 INTEGER, P31 INTEGER)
AS
DECLARE VARIABLE Paev INTEGER;
DECLARE VARIABLE DCnt INTEGER;
DECLARE VARIABLE Kuupaev DATE;
DECLARE VARIABLE BOMDate DATE;
BEGIN
BOMDate = CAST(CAST(:aAasta AS CHAR(4))||'-'||CAST(:aKuu AS
CHAR(2))||'-01' AS DATE);
EXECUTE PROCEDURE DaysInMonth(:BOMDate)RETURNING_VALUES(:DCnt);
FOR SELECT ... INTO :Tooleping DO BEGIN
Paev = DCnt;
Kuupaev = BOMDate;
WHILE(Paev > 0)DO BEGIN
EXECUTE PROCEDURE CalcDateValue(:Tooleping, :Kuupaev)
RETURNING_VALUES(/* current PXX column */);
Kuupaev = Kuupaev + 1;
Paev = Paev - 1;
END
SUSPEND;
END
END


TIA
ain