Hi I have created a procedure in db2:

There are 2 cursors, from first cursor i am getting the sum INV_AMT and from 2nd i m getting sum APPLD_AMT.now i want to open my 3 rd cursor that
gives me the value of 1 st cursor-2nd cursor means substracting c1 value from c2 value.

Kindly help if any body is aware of this.

Thanx in advance
regards
Anshul


CREATE PROCEDURE ANSHUL.ES_TOTAL ( )

DYNAMIC RESULT SETS 2
------------------------------------------------------------------------
-- SQL Stored Procedure
-- screen : Executive summary/total
------------------------------------------------------------------------
P1: BEGIN

DECLARE curFetchQtrAmts CURSOR WITH RETURN FOR
SELECT ED_CQTR_END_D,SUM(VCST1000.INV_Y) AS INV_AMT
FROM ANSHUL.VCST1000 VCST1000
WHERE
ED_CQTR_END_D IN ='2005-12-31' AND
VCST1000.INV_STAT_C<>'V'
GROUP BY ED_CQTR_END_D;

DECLARE curFthQtrApAmt CURSOR WITH RETURN FOR
SELECT
ED_CQTR_END_D,
COALESCE(sum(ORG_PYMT_APPL_A),0) AS APPLD_AMT
FROM
ANSHUL.VCST1000 AS VCST1000 LEFT OUTER JOIN
ANSHUL.VCST1300 AS VCST1300
ON (VCST1300.INV_I=VCST1000.INV_I AND
VCST1300.ED_END_M='9999-12-31-24.00.00.000000')
WHERE
VCST1000.ED_CQTR_END_D ='2005-12-31' AND
VCST1000.ED_END_M='9999-12-31-24.00.00.000000' AND
VCST1000.INV_STAT_C<>'V'
GROUP BY
ED_CQTR_END_D;

OPEN curFetchQtrAmts;
OPEN curFthQtrApAmt;

END P1