I am very new to writing Oracle Stored Procedures. I want to make sure my syntax is the problem or not the problem. I have visited another forum and got some insight as well as visited the ‘internet’ for some help. I eventually want this SP to run from a Crystal Report (XI). It seems that when I run this SP from Crystal the only time it executes correctly is when I initially run the SP and I’m prompted for database connection information or when I use the Crystal command – Verify Database which also prompts for database connection information. Any refresh attempt will not execute this SP. My only conclusion is that I am missing something in my SP to complete the transaction. Or my SP is correct and there is something beyond this forum I will need to research some more. Here is an example of my SP. I had to use Crystals OLE DB (ADO) connection because the application it will be used in requires it. On every refresh I get prompted for a date parameter like I should, but I don’t get the results I should.
ANY input/help is much appreciated. If this SP is written correctly, I will then explore other issues beyond this forum (unless someone has all the answers!!!)
I found some documentation that states I need a Package to use Oracle Stored Procedures in Crystal and I attempted to create one.
ANY input/help is much appreciated. If this SP is written correctly, I will then explore other issues beyond this forum (unless someone has all the answers!!!)
Code:
CREATE OR REPLACE PROCEDURE
sp_divcomm_act_report (v_enddate IN date) as
v_startmonth number;
v_startyear number;
v_endmonth number;
v_endyear number;
v_monthinx number;
v_yearinx number;
v_prof number := 1;
v_lictype number := 1000;
v_dgcitem number := 1005;
v_cgccitem number := 600;
v_firstdate date;
vv_new_apps number;
BEGIN
DELETE FROM divcomm_act_report;
select min(checklist_history.entry_date)
INTO v_firstdate
FROM checklist_history,
license
WHERE checklist_history.license_id = license.license_id and
license.profession_id = v_prof AND
license.license_type = v_lictype;
v_startmonth := EXtract(month from v_firstdate);
v_startyear := EXtract(year from v_firstdate);
v_endmonth := EXtract(month from v_enddate);
v_endyear := EXtract(year from v_enddate);
v_monthinx := v_startmonth;
v_yearinx := v_startyear;
while v_monthinx+(12*v_yearinx) <= v_endmonth+(12*v_endyear) LOOP
SELECT count(*)
into vv_new_apps
FROM checklist_history,
license
WHERE checklist_history.license_id = license.license_id and
license.profession_id = v_prof AND
license.license_type = v_lictype AND
extract(month from checklist_history.entry_date) = v_monthinx AND
extract(year from checklist_history.entry_date) = v_yearinx and
checklist_history.entry_date <= v_enddate;
SELECT vv_new_apps + count(*)
into vv_new_apps
FROM checklist,
license
WHERE checklist.license_id = license.license_id and
license.profession_id = v_prof AND
license.license_type = v_lictype AND
extract(month from checklist.entry_date) = v_monthinx AND
extract(year from checklist.entry_date) = v_yearinx and
checklist.entry_date <= v_enddate;
INSERT INTO divcomm_act_report
(rpt_month,rpt_year,new_apps)
VALUES (v_monthinx,v_yearinx,vv_new_apps);
IF v_monthinx < 12 THEN
v_monthinx := v_monthinx+1;
ELSE
v_monthinx := 1;
v_yearinx := v_yearinx + 1;
END IF;
END Loop;
END;
I found some documentation that states I need a Package to use Oracle Stored Procedures in Crystal and I attempted to create one.
Code:
CREATE OR REPLACE PACKAGE dca_report AS
PROCEDURE sp_divcomm_act_report(v_enddate IN date);
END dca_report;