DECLARE
SSID2 NUMBER;
SSID NUMBER;
SID NUMBER;
SAMOUNT NUMBER;
BEGIN
delete from MISSIONARY_SUB;
delete from MISSIONARY_SUB2;
delete from MISSIONARY_YEAR;
/* Select Missionary */
insert into MISSIONARY_SUB
Select
MISSIONARY_ID,SUPPORTER_ID,AMOUNT,to_number(to_char(CONTRIBUTION_DATE,'MM'))
from CONTRIBUTION
where UPPER(:P9_MISSIONARY_ID) = MISSIONARY_ID
and :P9_YEAR = to_number(to_char(CONTRIBUTION_DATE,'YYYY'));
/* Sum Supporter's Contribution */
insert into MISSIONARY_SUB2
Select
SSID,SUM(SAMOUNT),SDATE
from MISSIONARY_SUB
Group by SSID,SDATE;
/* Monthly Supporter's Contribution Total */
/* Record Supporters List in Missionary_Year Table */
INSERT INTO MISSIONARY_YEAR (SID)
SELECT DISTINCT SSID FROM MISSIONARY_SUB;
/* Loop */
FOR x IN (Select * from MISSIONARY_YEAR) LOOP
UPDATE MISSIONARY_YEAR
SET JAN = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 1)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET FEB = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 2)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET MAR = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 3)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET APR = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 4)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET MAY = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 5)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET JUN = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 6)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET JUL = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 7)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET AUG = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 8)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET SEP = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 9)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET OCT = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 10)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET NOV = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 11)
WHERE SID = x.SID;
UPDATE MISSIONARY_YEAR
SET DEC = (SELECT SAMOUNT2 FROM MISSIONARY_SUB2 WHERE SSID2 = x.SID AND SDATE2 = 12)
WHERE SID = x.SID;
END LOOP;
COMMIT;
END;
No. | Subject |
---|---|
Notice | Certification Oracle SQL Developer |
154 | TECH on the Net |
153 | trim(to_char(:P113_REGULAR,'999G999G999G999G990D00')) |
152 | PIVOT |
151 | TEST 2 |
150 | CREATION DEDUCTION TYPE |
» | PL/SQL for creation Tables |
148 | TEST 1 |
147 | INNER JOIN & GROUP BY |
146 | DISPLAY ONLY FEW ROWS |
145 | GROUP BY (for CHART) |
144 | INNER JOIN |
143 | LOOP - 2 |
142 | DATE Compare & Convert |
141 | LOOP & ROWNUM |
140 | Oracle Number Format |
139 | Page Reload in APEX |
138 | SUM / GROUP BY |
137 | MEDWIGS DB |
136 | HOW TO CONVERT DD/MM/YYYY -> MM/DD/YYYY |
135 | Attributes - Link Icon |