Generating Data for INSERT using a Stored Procedure, Function and Cursor

I've written a function that I finally got to compile, but was not successful in importing and inserting the data needed to populate a table with at least 1800 rows. Here's what I needed to do:
-- Generate a random test score ranging from 20 to 100 (already done)
-- Generate a random final grade for the course ranging from 4 to 0 (representing A to F) (already done, but question below.
-- Use conditional statements based on the counter to assign three courses (already done -- see SQL statements)
-- Process no more than 95% of the students (300) for test 1.
-- For test 2, process no more than 80% of the students who took test 1. Student cannot take test 2 unless the student takes test 1 (does this require a trigger? If so, how would I go about doing this?)
-- Use a function or another subprocedure to process the grade using IF-ELSIF statements
For example, I've tried the following statements:
For procedures
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 6;
AND for functions:
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
RETURN (6);
RETURN;
- or -
IF birth_date BETWEEN to_date('01-Jan-89','dd-Mon-yy') AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 9
RETURN school_grade;
-- Read the birth_date into the main procedure so that the value returned from the subprocedure or function can populate the birth_date column.
To give you an idea of what I've already done:
SQL>
SQL> CREATE OR REPLACE PROCEDURE add_tests (v_school_grade IN NUMBER) AS
2
3 v_counter NUMBER(3) := 0;
4 v_num_students CONSTANT NUMBER(3) := 300;
5 v_students_test1 NUMBER := 0;
6 v_students_test2 NUMBER := 0;
7 v_student_id VARCHAR2(5);
8 v_course1 VARCHAR2(2);
9 v_course2 VARCHAR2(2);
10 v_course3 VARCHAR2(2);
11 v_course4 VARCHAR2(2);
12 v_student_grade NUMBER(1) := 0;
13 v_test_score NUMBER(3) := 0;
14 v_course_final_grade NUMBER(1) := 0;
15 v_birth_date DATE;
16
17 FUNCTION pkg_get_grade RETURN NUMBER
18 IS
19
20 v_birth_date DATE;
21 v_school_grade NUMBER(1) :=0;
22
23 CURSOR grade_cur IS
24 SELECT birth_date FROM students;
25
26 BEGIN
27 OPEN grade_cur;
28 LOOP
29 FETCH grade_cur INTO v_birth_date;
30
31 EXIT WHEN grade_cur%NOTFOUND;
32
33 -- Assign student grade
34
35 -- 9th Grade
36
37 IF v_birth_date < TO_DATE('01-Jan-87','DD-Mon-YY') THEN
38 v_school_grade := 9;
39
40 -- 8th grade
41
42 ELSIF v_birth_date BETWEEN
43 TO_DATE('01-Jan-87','DD-Mon-YY') AND
44 TO_DATE('31-Dec-87','DD-Mon-YY') THEN
45
46 v_school_grade := 8;
47
48 -- 7th grade
49
50 ELSIF v_birth_date BETWEEN
51 TO_DATE('01-Jan-88','DD-Mon-YY') AND
52 TO_DATE('31-Dec-88','DD-Mon-YY') THEN
53
54 v_school_grade := 7;
55
56 -- 6th grade
57
58 ELSIF v_birth_date BETWEEN
59 TO_DATE('01-Jan-89','DD-Mon-YY') AND
60 TO_DATE('31-Dec-89','DD-Mon-YY') THEN
61
62 v_school_grade := 6;
63
64 -- 5th grade
65
66 ELSIF v_birth_date > TO_DATE('31-Dec-89','DD-Mon-YY') THEN
67
68 v_school_grade := 5;
69
70 END IF; -- end if loop for student's grade
71 END LOOP; -- end loop for grade_cur
72 CLOSE grade_cur; -- close cursor for assigning grade
73 RETURN v_school_grade;
74
75 END pkg_get_grade;
76
77 PROCEDURE delete_test_info AS
78
79 BEGIN
80
81 DELETE FROM student_facts;
82
83 END delete_test_info;
84
85 BEGIN
86
87 -- Process student for tests
88
89 WHILE (v_counter <= v_num_students) LOOP
90 v_counter := v_counter + 1; -- initialize counter
91
92 -- Set student id
93
94 v_student_id := 'S'&#0124; &#0124;v_counter;
95
96 -- portion of students taking beginning of year tests
97
98 v_students_test1 := v_num_students * .95;
99
100
101 -- Portion of students taking end of year tests
102
103 v_students_test2 := v_students_test1 * .80;
104
105
106 -- Est. test scores between 20 and 100
107
108 v_test_score := random.rand_max(80) + 20;
109
110
111 -- Est. final grade for course between 0 and 4
112
113 v_course_final_grade := random.rand_max(4);
114
115
116 -- Process tests for courses
117
118 IF v_counter < ROUND(v_num_students * .20) THEN
119 v_course1 := 'C1';
120 v_course2 := 'C2';
121 v_course3 := 'C3';
122
123 ELSIF v_counter BETWEEN ROUND(v_num_students * .20)
124 AND ROUND(v_num_students * .40) THEN
125
126 v_course1 := 'C2';
127 v_course2 := 'C1';
128 v_course3 := 'C3';
129
130 ELSE IF v_counter BETWEEN ROUND(v_num_students * .40)
131 AND ROUND(v_num_students * .60) THEN
132
133 v_course1 := 'C3';
134 v_course2 := 'C1';
135 v_course3 := 'C2';
136
137 ELSE IF v_counter BETWEEN (v_num_students * .60)
138 AND ROUND(v_num_students * .80) THEN
139
140 v_course1 := 'C3';
141 v_course2 := 'C1';
142 v_course3 := 'C2';
143
144 ELSE
145 v_course1 := 'C4';
146 v_course2 := 'C2';
147 v_course3 := 'C3';
148
149 END IF;
150 END IF;
151 END IF;
152
153 -- Input test information for students
154
155 -- Beginning of year test for Course 1
156
157 IF v_counter <= v_students_test1 THEN
158 INSERT INTO studentfacts
159 VALUES(v_student_id, v_course1, 'ACH1999',
160 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
161 v_student_grade, v_course_final_grade, v_test_score);
162 ELSE
163 INSERT INTO studentfacts
164 VALUES(v_student_id, v_course1, 'ACH1999',
165 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
166 v_student_grade, v_course_final_grade, NULL);
167 END IF;
168
169
170 -- End of year test for Course 1
171
172 IF v_counter <= v_students_test2 THEN
173 INSERT INTO studentfacts
174 VALUES(v_student_id, v_course1,'ACH2000',
175 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
176 v_student_grade, v_course_final_grade, v_test_score);
177 ELSE
178 INSERT INTO studentfacts
179 VALUES(v_student_id, v_course1, 'ACH2000',
180 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
181 v_student_grade, v_course_final_grade, NULL);
182 END IF;
183
184
185 -- Beginning of year test for Course 2
186
187 IF v_counter <= v_students_test1 THEN
188 INSERT INTO studentfacts
189 VALUES(v_student_id, v_course2, 'ACH1999',
190 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
191 v_student_grade, v_course_final_grade,
192 v_test_score);
193 ELSE
194 INSERT INTO studentfacts
195 VALUES(v_student_id, v_course2, 'ACH1999',
196 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
197 v_student_grade, v_course_final_grade, NULL);
198 END IF;
199
200
201 -- End of year test for Course 2
202
203 IF v_counter <= v_students_test2 THEN
204 INSERT INTO studentfacts
205 VALUES(v_student_id, v_course2,'ACH2000',
206 TO_DATE('01-JUN-2001''DD-MON-YYYY'),
207 v_student_grade, v_course_final_grade,
208 v_test_score);
209 ELSE
210 INSERT INTO studentfacts
211 VALUES(v_student_id, v_course2, 'ACH2000',
212 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
213 v_student_grade, v_course_final_grade, NULL);
214 END IF;
215
216
217 -- Beginning of year test for Course 3
218
219 IF v_counter <= v_students_test1 THEN
220 INSERT INTO studentfacts
221 VALUES(v_student_id, v_course3, 'ACH1999',
222 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
223 v_student_grade, v_course_final_grade,
224 v_test_score);
225 ELSE
226 INSERT INTO studentfacts
227 VALUES(v_student_id, v_course3, 'ACH1999',
228 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
229 v_student_grade, v_course_final_grade, NULL);
230 END IF;
231
232
233 -- End of year test for Course 3
234
235 IF v_counter <= v_students_test2 THEN
236 INSERT INTO studentfacts
237 VALUES(v_student_id, v_course3,'ACH2000',
238 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
239 v_student_grade, v_course_final_grade,
240 v_test_score);
241 ELSE
242 INSERT INTO studentfacts
243 VALUES(v_student_id, v_course3, 'ACH2000',
244 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
245 v_student_grade, v_course_final_grade, NULL);
246 END IF;
247
248
249 -- Beginning of year test for Course 4
250
251 IF v_counter <= v_students_test1 THEN
252 INSERT INTO studentfacts
253 VALUES(v_student_id, v_course4, 'ACH1999',
254 TO_DATE('01-SEP-1999','DD-MON-Y YYY'),
255 v_student_grade, v_course_final_grade,
256 v_test_score);
257 ELSE
258 INSERT INTO studentfacts
259 VALUES(v_student_id, v_course4, 'ACH1999',
260 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
261 v_student_grade, v_course_final_grade, NULL);
262 END IF;
263
264
265 -- End of year test for Course 4
266
267 IF v_counter <= v_students_test2 THEN
268 INSERT INTO studentfacts
269 VALUES(v_student_id, v_course4,'ACH2000',
270 TO_DATE('01-JUN-2001', 'DD-MON-YYYY'),
271 v_student_grade, v_course_final_grade, v_test_score);
272 ELSE
273 INSERT INTO studentfacts
274 VALUES(v_student_id, v_course4, 'ACH2000',
275 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
276 v_student_grade, v_course_final_grade, NULL);
277
278 END IF;
279 END LOOP;
280 END add_tests;
281 /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL> Input truncated to 9 characters
spool off
When I executed the main procedure, no data populated the student_table. I've tried several things, but I was not still able to populate the student_fact table (I've been at this for more than a week now, but haven't figured a way to populate the student_facts table with at least 1800 rows). Can you tell me what I need to change (if anything) whether if I need to structure things differently? I'm thinking that I missed something in calling the birth_date into the main procedure or returning the value from either a function or subprocedure. Related to the random final grade -- is there a way to sum the totals of the test scores (each student will have three), and generate a final grade from these values.
I also compiled successfully a package containing this same information, but don't know how to execute it to see whether this approach works.
Many thanks to anyone who can help.
null

ldsw,
I am not sure if I totally understand everything that you are trying to do, but I tried to clean up your code and what is listed below is what I came up with. Please see if you can make use of any of it.
SQL> EDIT ldsw
CREATE OR REPLACE PACKAGE ldsw
AS
CURSOR grade_cur
IS
SELECT birth_date
FROM students;
PROCEDURE delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (get_grade, WNDS, WNPS, RNDS, RNPS);
PROCEDURE add_tests;
END ldsw;
CREATE OR REPLACE PACKAGE BODY ldsw
AS
v_student_grade NUMBER (1) := 0;
PROCEDURE delete_test_info
IS
BEGIN
DELETE FROM studentfacts;
END delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER
IS
v_school_grade NUMBER (1) := 0;
BEGIN
IF v_birth_date < TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 9;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 8;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1988', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1988', 'DD-Mon-YYYY')
THEN
v_school_grade := 7;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1989', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 6;
ELSIF v_birth_date > TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 5;
END IF;
RETURN v_school_grade;
END get_grade;
PROCEDURE add_tests
IS
v_num_students CONSTANT NUMBER (3) := 300;
v_students_test1 NUMBER := 0;
v_students_test2 NUMBER := 0;
v_counter NUMBER (3) := 0;
v_student_id VARCHAR2 (5);
v_test_score NUMBER (3) := 0;
v_course_final_grade NUMBER (1) := 0;
v_course1 VARCHAR2 (2) := NULL;
v_course2 VARCHAR2 (2) := NULL;
v_course3 VARCHAR2 (2) := NULL;
v_course4 VARCHAR2 (2) := NULL;
BEGIN
ldsw.delete_test_info;
v_students_test1 := v_num_students * .95;
v_students_test2 := v_students_test1 * .80;
FOR rec IN grade_cur
LOOP
v_counter := v_counter + 1;
IF v_counter <= v_num_students
THEN
v_student_id := 'S' &#0124; &#0124; TO_CHAR (v_counter);
v_test_score := random.rand_max (80) + 20;
v_course_final_grade := random.rand_max (4);
IF v_counter < ROUND (v_num_students * .20)
THEN
v_course1 := 'C1';
v_course2 := 'C2';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .20) AND ROUND (v_num_students * .40)
THEN
v_course1 := 'C2';
v_course2 := 'C1';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .40) AND ROUND (v_num_students * .60)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSIF v_counter BETWEEN ROUND (v_num_students * .60) AND ROUND (v_num_students * .80)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSE
v_course1 := 'C4';
v_course2 := 'C2';
v_course3 := 'C3';
END IF;
SELECT ldsw.get_grade (rec.birth_date)
INTO v_student_grade
FROM DUAL;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
END IF;
END LOOP;
END add_tests;
END ldsw;
Save the file.
SQL> START ldsw
Package created.
Package body created.
SQL> EXECUTE ldsw.add_tests
PL/SQL procedure successfully completed.
SQL> SELECT * FROM student_facts;
null

Similar Messages

  • SSRS with Oracle Stored Procedures, Functions and Packages

    Hi,
    I am working on a BI project. Here we are using PowerPivot to access data from Oracle DB and generate reports. Currently Client generates Few reports using Oracle Stored Procedures, Functions and Packages. We need to move everything to PowerPivot, so
    that user can generate all reports using same platform. But PowerPivot doesn'e support Oracle Stored Procedures, Functions and Packages. So we have decided to try those reports using SSRS.
    I have no knowledge about using SSRS which will call Oracle function/stored procedures/packages for generating reports.
    Can anybody help me in getting exact steps?
    Please let me know if my question is not clear enough.
    Thanks and Regards,
    SS

    Hi Visakh,
    Thanks for the detailed steps. My next question is:
    Is there any other way to develop such reports without using any development tool like Visual Studio? Our aim is to provide a self-serviced reporting platform where user don't need any technical knowledge.
    I am sorry I have no knowledge about SSRS and Oracle DB.Can you please have a look at my Oracle function and let me know whether it's possible to execute this using SSRS? (I am pasting one by one as there is a character limit.
    CREATE OR REPLACE TYPE obj_special_pass_cases
    AS OBJECT
          CLAIM_ID    NUMBER(12),
          claim_ref_no  VARCHAR2(20),
          OFFICER_NAME   VARCHAR2(201),
          SUBMIT_DT   VARCHAR2(10),
          ACC_DT   VARCHAR2(10),
          SP_ISSUE_DT   VARCHAR2(10),
          STATUS    VARCHAR2(30),
          SUB_STATUS   VARCHAR2(30),
          STATUS_LAST_UPDATE_DATE VARCHAR2(10),
          SP_EXP_DT VARCHAR2(10),
          INDUSTRY_CODE VARCHAR2(8),
          EMP_SSIC VARCHAR2(8),
          rel VARCHAR2(4),
          WPNo VARCHAR2(20),
          FIN VARCHAR2(9),
          PASSPORT_NO VARCHAR2(16),
          SPNo VARCHAR2(20),
          VictimName VARCHAR2(100),
          SP_EXT_PURPOSE VARCHAR2(100),
          ISSUE_SYSTEM VARCHAR2(4), 
          REPATRIATION_DATE VARCHAR2(10),
          SP_STATUS    VARCHAR2(30),
          SP_ISSUE_PURPOSE VARCHAR2(500)
    CREATE OR REPLACE TYPE tbl_special_pass_cases
       AS TABLE OF obj_special_pass_cases
    CREATE OR REPLACE TYPE obj_special_pass_casesNew
    AS OBJECT
          CLAIM_ID    NUMBER(12),
          claim_ref_no  VARCHAR2(20),
          OFFICER_NAME   VARCHAR2(201),
          SUBMIT_DT   VARCHAR2(10), /*Case Registration Date*/
          ACC_DT   VARCHAR2(10),
          SP_ISSUE_DT   VARCHAR2(10),
          calc_sp_issue_dt VARCHAR2(10),
          calc_sp_issue_dt_month VARCHAR2(2),
          calc_sp_issue_dt_year VARCHAR2(4),
          calc_Duration_Of_Stay VARCHAR2(4),
          STATUS    VARCHAR2(30),
          SUB_STATUS   VARCHAR2(30),
          STATUS_LAST_UPDATE_DATE VARCHAR2(10),
          lastUpdateDtMonth varchar2(2),
          lastUpdateDtYear varchar2(4),
          DurationOfUpdateDt VARCHAR2(4),
          SP_EXP_DT VARCHAR2(10),
          INDUSTRY_CODE VARCHAR2(8),
          EMP_SSIC VARCHAR2(8),
          rel VARCHAR2(4),
          WPNo VARCHAR2(20), /* New columns from here - SR */
          FIN VARCHAR2(9),
          PASSPORT_NO VARCHAR2(16),
          SPNo VARCHAR2(20),
          VictimName VARCHAR2(100),
          workerNationality VARCHAR2(20),
          employName VARCHAR2(200),
          reportType VARCHAR2(10),
          SP_EXT_PURPOSE VARCHAR2(100),
          ISSUE_SYSTEM VARCHAR2(4), /*IWPS, EIDS*/
          REPATRIATION_DATE VARCHAR2(10),
          SP_STATUS    VARCHAR2(30),
          SP_ISSUE_PURPOSE VARCHAR2(500)
    CREATE OR REPLACE TYPE tbl_special_pass_casesNew
       AS TABLE OF obj_special_pass_casesNew
       FUNCTION getListOfSpecialPassCases(
                  vRepatriationDateFrom VARCHAR2,
                  vRepatriationDateTo VARCHAR2,
                  vIncludeRepatriationDate VARCHAR2)
        RETURN tbl_special_pass_cases
        IS
          TYPE cur_typ IS REF CURSOR;
          SPECIAL_PASS_CASES_CUR cur_typ;
          vSQL1 VARCHAR2(4000);
          --vSQL1 VARCHAR2(4000) := 'SELECT DISTINCT(A.CLAIM_ID), A.CLAIM_REF_NO, A.STATUS, A.SUB_STATUS, A.OFFICER_NAME,  A.SUBMIT_DT, A.ACC_DT, A.vLatestUpdatedDate, A.INDUSTRY_CODE, A.ID_NO, A.vWorkerName, B.vSPWPNO, B.vFIN, B.vSPPassportNo,
    B.vSPIssueDate, B.vSPExpiryDate, B.vSPNo, DECODE(B.vSPExtensionPurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''13'',''FMMD'',''14'',''TMB
    PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION (SB-F)'') vSPExtensionPurpose, B.vIssueSystem, B.vSPActualDepartDate, B.vSPStatus, DECODE(B.vSPIssuePurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
    RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''11'',''PENDING DOCUMENT VERIFICATION'',''12'',''LATE ERENEWAL'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION
    (SB-F)'') vSPIssuePurpose FROM (SELECT vSPWPNO, vFIN, vSPPassportNo, vSPIssueDate, vSPExpiryDate, vSPNo, vSPExtensionPurpose, vIssueSystem, vSPActualDepartDate, vSPStatus, vSPIssuePurpose FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSActiveSpecialPass) WHERE
    (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B JOIN (SELECT WC.CLAIM_ID CLAIM_ID, WC.CLAIM_REF_NO CLAIM_REF_NO, WC.STATUS STATUS,  WC.SUB_STATUS SUB_STATUS, TAS.LAST_NAME ||'' ''|| TAS.FIRST_NAME OFFICER_NAME,  to_char(trunc(IRN.SUBMIT_DT), ''dd/MM/yyyy'')
    SUBMIT_DT, TO_CHAR(trunc(decode(wc.assessmt_type,''OD-PI'',EV.OD_CONSULT_DT,''OD-TI'',ev.od_consult_dt,ECASE.acc_dt)), ''dd/MM/yyyy'') ACC_DT, (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), ''dd/MM/yyyy'') STATUS_LAST_UPDATE_DATE FROM WIC_CLAIM_STATUS WCS WHERE
    WCS.CLAIM_ID=WC.CLAIM_ID) vLatestUpdatedDate, EC.INDUSTRY_CODE INDUSTRY_CODE, EP.ID_NO ID_NO, EP.NAME vWorkerName FROM EVENT_PERSON EP, WIC_CLAIMS WC, TBL_AA_SUBJECT TAS, EVENT_COMPANY EC,EVENT_CASE ECASE,event_victim ev WHERE EP.ID_NO IS NOT NULL AND EP.DELETE_IND
    = ''F'' AND EP.INVOLVEMENT = ''VICTIM'' AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID AND ep.event_person_id = ev.event_person_id (+) AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID AND EC.EVENT_CASE_NO=WC.EVENT_CASE_NO AND
    EC.INVOLVEMENT in (''EMPLOYER'',''EMPLOYER_OCCUPIER'') AND ECASE.EVENT_CASE_NO=WC.EVENT_CASE_NO AND EC.DELETE_IND = ''F'') A ON (B.vFIN = A.ID_NO OR B.vSPPassportNo = A.ID_NO)';
          vSQL2 VARCHAR2(4000);
          --vSQL2 VARCHAR2(4000) := 'SELECT DISTINCT(A.CLAIM_ID),A.CLAIM_REF_NO,A.STATUS,A.SUB_STATUS,A.OFFICER_NAME,A.SUBMIT_DT,A.ACC_DT,A.vLatestUpdatedDate,A.INDUSTRY_CODE,A.ID_NO,A.vWorkerName,B.vSPWPNO,B.vFIN,B.vSPPassportNo,B.vSPIssueDate,B.vSPExpiryDate,B.vSPNo,DECODE(B.vSPExtensionPurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
    RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION (SB-F)'') vSPExtensionPurpose,B.vIssueSystem,B.vSPActualDepartDate,B.vSPStatus,DECODE(B.vSPIssuePurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
    RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''11'',''PENDING DOCUMENT VERIFICATION'',''12'',''LATE ERENEWAL'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION
    (SB-F)'') vSPIssuePurpose FROM (SELECT vSPWPNO,vFIN,vSPPassportNo,vSPIssueDate,vSPExpiryDate,vSPNo,vSPExtensionPurpose,vIssueSystem,vSPActualDepartDate,vSPStatus,vSPIssuePurpose FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSDepartedSpecialPass(''' || vRepatriationDateFrom
    || ''', ''' ||  vRepatriationDateTo || ''')) WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B JOIN (SELECT WC.CLAIM_ID CLAIM_ID, WC.CLAIM_REF_NO CLAIM_REF_NO, WC.STATUS STATUS,WC.SUB_STATUS SUB_STATUS, TAS.LAST_NAME ||'' ''|| TAS.FIRST_NAME OFFICER_NAME, 
    to_char(trunc(IRN.SUBMIT_DT), ''dd/MM/yyyy'') SUBMIT_DT,TO_CHAR(trunc(decode(wc.assessmt_type,''OD-PI'',EV.OD_CONSULT_DT,''OD-TI'',ev.od_consult_dt,ECASE.acc_dt)), ''dd/MM/yyyy'') ACC_DT, (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), ''dd/MM/yyyy'') STATUS_LAST_UPDATE_DATE
    FROM WIC_CLAIM_STATUS WCS WHERE WCS.CLAIM_ID=WC.CLAIM_ID) vLatestUpdatedDate, EC.INDUSTRY_CODE INDUSTRY_CODE, EP.ID_NO ID_NO, EP.NAME vWorkerName FROM EVENT_PERSON EP, WIC_CLAIMS WC, TBL_AA_SUBJECT TAS, EVENT_COMPANY EC,EVENT_CASE ECASE, IR_NOTIFICATION IRN,event_victim
    ev WHERE EP.ID_NO IS NOT NULL AND EP.DELETE_IND = ''F'' AND EP.INVOLVEMENT = ''VICTIM'' AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID and ep.event_person_id = ev.event_person_id (+) AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
    AND EC.EVENT_CASE_NO=WC.EVENT_CASE_NO AND EC.INVOLVEMENT in (''EMPLOYER'',''EMPLOYER_OCCUPIER'') AND ECASE.EVENT_CASE_NO=WC.EVENT_CASE_NO AND IRN.REF_NO(+) = ECASE.IR_REF_NO AND IRN.SUBMIT_TYPE IN (''SI'',''SE'') AND EC.DELETE_IND = ''F'') A ON (B.vFIN = A.ID_NO
    OR B.vSPPassportNo = A.ID_NO)';
          SPECIAL_PASS_CASES_TBL tbl_special_pass_cases := tbl_special_pass_cases();
       cursor sp_pass_settle_cur is
       SELECT DISTINCT (A.CLAIM_ID),
                    A.CLAIM_REF_NO,
                    A.STATUS,
                    A.SUB_STATUS,
                    A.OFFICER_NAME,
                    A.SUBMIT_DT,
                    A.ACC_DT,
                    A.vLatestUpdatedDate,
                    A.INDUSTRY_CODE,
                    A.ID_NO,
                    A.vWorkerName,
                    B.vSPWPNO,
                    B.vFIN,
                    B.vSPPassportNo,
                    B.vSPIssueDate,
                    B.vSPExpiryDate,
                    B.vSPNo,
                    DECODE(B.vSPExtensionPurpose,
                           '1',
                           'WICB',
                           '2',
                           'RE - APPLICATION',
                           '3',
                           'POLICE',
                           '4',
                           'REPATRIATION',
                           '5',
                           'LRD',
                           '6',
                           'LATE RENEWAL',
                           '9',
                           'OTHERS',
                           '10',
                           'LATE EISSUANCE',
                           '13',
                           'FMMD',
                           '14',
                           'TMB PENDING REPATRIATION',
                           '15',
                           'TMB REPATRIATION',
                           '16',
                           'PENDING REPATRIATION(SB - F)',
                           '17',
                           'REPATRIATION(SB - F)') vSPExtensionPurpose,
                    B.vIssueSystem,
                    B.vSPActualDepartDate,
                    B.vSPStatus,
                    DECODE(B.vSPIssuePurpose,
                           '1',
                           'WICB',
                           '2',
                           'RE - APPLICATION',
                           '3',
                           'POLICE',
                           '4',
                           'REPATRIATION',
                           '5',
                           'LRD',
                           '6',
                           'LATE RENEWAL',
                           '9',
                           'OTHERS',
                           '10',
                           'LATE EISSUANCE',
                           '11',
                           'PENDING DOCUMENT VERIFICATION',
                           '12',
                           'LATE ERENEWAL',
                           '13',
                           'FMMD',
                           '14',
                           'TMB PENDING REPATRIATION',
                           '15',
                           'TMB REPATRIATION',
                           '16',
                           'PENDING REPATRIATION(SB - F)',
                           '17',
                           'REPATRIATION(SB - F)') vSPIssuePurpose
      FROM (SELECT vSPWPNO,
                   vFIN,
                   vSPPassportNo,
                   vSPIssueDate,
                   vSPExpiryDate,
                   vSPNo,
                   vSPExtensionPurpose,
                   vIssueSystem,
                   vSPActualDepartDate,
                   vSPStatus,
                   vSPIssuePurpose
              FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSActiveSpecialPass)
             WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B
      JOIN (SELECT WC.CLAIM_ID CLAIM_ID,
                   WC.CLAIM_REF_NO CLAIM_REF_NO,
                   WC.STATUS STATUS,
                   WC.SUB_STATUS SUB_STATUS,
                   TAS.LAST_NAME ||''|| TAS.FIRST_NAME OFFICER_NAME,
                   '' SUBMIT_DT,
                   TO_CHAR(trunc(decode(wc.assessmt_type,
                                        'OD-PI',
                                        EV.OD_CONSULT_DT,
                                        'OD-TI',
                                        ev.od_consult_dt,
                                        ECASE.acc_dt)),
                           'dd/MM/yyyy') ACC_DT,
                   (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), 'dd/MM/yyyy') STATUS_LAST_UPDATE_DATE
                      FROM WIC_CLAIM_STATUS WCS
                     WHERE WCS.CLAIM_ID = WC.CLAIM_ID) vLatestUpdatedDate,
                   EC.INDUSTRY_CODE INDUSTRY_CODE,
                   EP.ID_NO ID_NO,
                   EP.NAME vWorkerName
              FROM EVENT_PERSON   EP,
                   WIC_CLAIMS     WC,
                   TBL_AA_SUBJECT TAS,
                   EVENT_COMPANY  EC,
                   EVENT_CASE     ECASE,
                   event_victim   ev
             WHERE EP.ID_NO IS NOT NULL
               AND EP.DELETE_IND = 'F'
               AND EP.INVOLVEMENT = 'VICTIM'
               AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO
               AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID
               AND ep.event_person_id = ev.event_person_id(+)
               AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
               AND EC.EVENT_CASE_NO = WC.EVENT_CASE_NO
               AND EC.INVOLVEMENT in ('EMPLOYER', 'EMPLOYER_OCCUPIER')
               AND ECASE.EVENT_CASE_NO = WC.EVENT_CASE_NO
               AND EC.DELETE_IND = 'F') A ON (B.vFIN = A.ID_NO OR  B.vSPPassportNo = A.ID_NO);
       sp_pass_settle_rec sp_pass_settle_cur%rowtype;
       cursor sp_details_with_dt_cur is
     SELECT DISTINCT (A.CLAIM_ID),
                    A.CLAIM_REF_NO,
                    A.STATUS,
                    A.SUB_STATUS,
                    A.OFFICER_NAME,
                    A.SUBMIT_DT,
                    A.ACC_DT,
                    A.vLatestUpdatedDate,
                    A.INDUSTRY_CODE,
                    A.ID_NO,
                    A.vWorkerName,
                    B.vSPWPNO,
                    B.vFIN,
                    B.vSPPassportNo,
                    B.vSPIssueDate,
                    B.vSPExpiryDate,
                    B.vSPNo,
                    DECODE(B.vSPExtensionPurpose,'1','WICB', '2','RE - APPLICATION','3','POLICE','4','REPATRIATION','5','LRD','6','LATE RENEWAL','9','OTHERS','10','LATE EISSUANCE',
                           '13','FMMD','14','TMB PENDING REPATRIATION','15','TMB REPATRIATION','16','PENDING REPATRIATION(SB - F)','17','REPATRIATION(SB
    - F)') vSPExtensionPurpose,
                    B.vIssueSystem,
                    B.vSPActualDepartDate,
                    B.vSPStatus,
                    DECODE(B.vSPIssuePurpose,
                           '1','WICB','2','RE - APPLICATION','3','POLICE','4','REPATRIATION','5','LRD','6','LATE RENEWAL','9','OTHERS', '10', 'LATE EISSUANCE','11','PENDING
    DOCUMENT VERIFICATION',
                           '12','LATE ERENEWAL','13','FMMD','14','TMB PENDING REPATRIATION','15','TMB REPATRIATION','16','PENDING REPATRIATION(SB - F)','17','REPATRIATION(SB
    - F)') vSPIssuePurpose
      FROM (SELECT vSPWPNO,
                   vFIN,
                   vSPPassportNo,
                   vSPIssueDate,
                   vSPExpiryDate,
                   vSPNo,
                   vSPExtensionPurpose,
                   vIssueSystem,
                   vSPActualDepartDate,
                   vSPStatus,
                   vSPIssuePurpose
              FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSDepartedSpecialPass(''|| vRepatriationDateFrom ||'', ''||  vRepatriationDateTo ||''))
             WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B
      JOIN (SELECT WC.CLAIM_ID CLAIM_ID,
                   WC.CLAIM_REF_NO CLAIM_REF_NO,
                   WC.STATUS STATUS,
                   WC.SUB_STATUS SUB_STATUS,
                   TAS.LAST_NAME ||''|| TAS.FIRST_NAME OFFICER_NAME,
                   to_char(trunc(IRN.SUBMIT_DT), 'dd/MM/yyyy') SUBMIT_DT,
                   TO_CHAR(trunc(decode(wc.assessmt_type,
                                        'OD - PI',
                                        EV.OD_CONSULT_DT,
                                        'OD - TI',
                                        ev.od_consult_dt,
                                        ECASE.acc_dt)),
                           'dd/MM/yyyy') ACC_DT,
                   (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), 'dd/MM/yyyy') STATUS_LAST_UPDATE_DATE
                      FROM WIC_CLAIM_STATUS WCS
                     WHERE WCS.CLAIM_ID = WC.CLAIM_ID) vLatestUpdatedDate,
                   EC.INDUSTRY_CODE INDUSTRY_CODE,
                   EP.ID_NO ID_NO,
                   EP.NAME vWorkerName
              FROM EVENT_PERSON    EP,
                   WIC_CLAIMS      WC,
                   TBL_AA_SUBJECT  TAS,
                   EVENT_COMPANY   EC,
                   EVENT_CASE      ECASE,
                   IR_NOTIFICATION IRN,
                   event_victim    ev
             WHERE EP.ID_NO IS NOT NULL
               AND EP.DELETE_IND = 'F'
               AND EP.INVOLVEMENT = 'VICTIM'
               AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO
               AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID
               and ep.event_person_id = ev.event_person_id(+)
               AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
               AND EC.EVENT_CASE_NO = WC.EVENT_CASE_NO
               AND EC.INVOLVEMENT in ('EMPLOYER', 'EMPLOYER_OCCUPIER')
               AND ECASE.EVENT_CASE_NO = WC.EVENT_CASE_NO
               AND IRN.REF_NO(+) = ECASE.IR_REF_NO
               AND IRN.SUBMIT_TYPE IN ('SI', 'SE')
               AND EC.DELETE_IND = 'F') A ON (B.vFIN = A.ID_NO OR  B.vSPPassportNo = A.ID_NO);
         sp_details_with_dt_rec sp_details_with_dt_cur%rowtype;
          /*vSQL VARCHAR2(4000);
          vFIN  VARCHAR2(9);
          vSPPassportNo  VARCHAR2(16);
          vSPWPNO VARCHAR2(20);
          vSPIssueDate VARCHAR2(10);
          vSPExpiryDate VARCHAR2(10);
          vSPNo VARCHAR2(20);
          vSPExtensionPurpose VARCHAR2(100);
          vIssueSystem VARCHAR2(4);
          vSPActualDepartDate VARCHAR2(10);
          vSPStatus VARCHAR2(30);
          vSPIssuePurpose VARCHAR2(500);
          CLAIM_ID NUMBER(12);
          CLAIM_REF_NO VARCHAR2(20);
          STATUS VARCHAR2(30);
          SUB_STATUS VARCHAR2(30);
          OFFICER_NAME VARCHAR2(201);
          SUBMIT_DT VARCHAR2(10);
          ACC_DT VARCHAR2(10);
          vLatestUpdatedDate VARCHAR2(10);
          INDUSTRY_CODE VARCHAR2(8);
          ID_NO VARCHAR2(50);
          vWorkerName VARCHAR2(100);*/
        BEGIN
      if vIncludeRepatriationDate = 'Y' then
       for sp_details_with_dt_rec in sp_details_with_dt_cur
       loop
       SPECIAL_PASS_CASES_TBL.EXTEND;
       SPECIAL_PASS_CASES_TBL(SPECIAL_PASS_CASES_TBL.LAST) := obj_special_pass_cases(sp_details_with_dt_rec.CLAIM_ID,sp_details_with_dt_rec.CLAIM_REF_NO,sp_details_with_dt_rec.OFFICER_NAME,sp_details_with_dt_rec.SUBMIT_DT,sp_details_with_dt_rec.ACC_DT,sp_details_with_dt_rec.vSPIssueDate,sp_details_with_dt_rec.STATUS,sp_details_with_dt_rec.SUB_STATUS,sp_details_with_dt_rec.vLatestUpdatedDate,sp_details_with_dt_rec.vSPExpiryDate,sp_details_with_dt_rec.INDUSTRY_CODE,sp_details_with_dt_rec.INDUSTRY_CODE,'a',sp_details_with_dt_rec.vSPWPNO,sp_details_with_dt_rec.vFIN,sp_details_with_dt_rec.vSPPassportNo,sp_details_with_dt_rec.vSPNo,sp_details_with_dt_rec.vWorkerName,sp_details_with_dt_rec.vSPExtensionPurpose,sp_details_with_dt_rec.vIssueSystem,sp_details_with_dt_rec.vSPActualDepartDate,sp_details_with_dt_rec.vSPStatus,sp_details_with_dt_rec.vSPIssuePurpose);
       end loop;
      else
       for sp_pass_settle_rec in sp_pass_settle_cur
       loop
       SPECIAL_PASS_CASES_TBL.EXTEND;
       SPECIAL_PASS_CASES_TBL(SPECIAL_PASS_CASES_TBL.LAST) := obj_special_pass_cases(sp_pass_settle_rec.CLAIM_ID,sp_pass_settle_rec.CLAIM_REF_NO,sp_pass_settle_rec.OFFICER_NAME,sp_pass_settle_rec.SUBMIT_DT,sp_pass_settle_rec.ACC_DT,sp_pass_settle_rec.vSPIssueDate,sp_pass_settle_rec.STATUS,sp_pass_settle_rec.SUB_STATUS,sp_pass_settle_rec.vLatestUpdatedDate,sp_pass_settle_rec.vSPExpiryDate,sp_pass_settle_rec.INDUSTRY_CODE,sp_pass_settle_rec.INDUSTRY_CODE,'a',sp_pass_settle_rec.vSPWPNO,sp_pass_settle_rec.vFIN,sp_pass_settle_rec.vSPPassportNo,sp_pass_settle_rec.vSPNo,sp_pass_settle_rec.vWorkerName,sp_pass_settle_rec.vSPExtensionPurpose,sp_pass_settle_rec.vIssueSystem,sp_pass_settle_rec.vSPActualDepartDate,sp_pass_settle_rec.vSPStatus,sp_pass_settle_rec.vSPIssuePurpose);
       end loop;
      end if ;
        RETURN SPECIAL_PASS_CASES_TBL;
      END getListOfSpecialPassCases;
    Thanks,
    SS

  • Is is possible to create Socket using Java Stored Procedures/Function(Ora)?

    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?
    OR
    How I can send a message from oracle to Java Desktop Application which is working like server program?
    Please Guide !!

    J3Ganesh wrote:
    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?No, Oracle was very careful to take that feature out of the JDK provided in Oracle 10/11, but you can buy that feature back for, if I remember correctly, about 5000 dollars. (I actually raised a service request on this and then told my rep what I thought about the answer I received--some thing along the line of money grubbing so and so....)
    How I can send a message from oracle to Java Desktop Application which is working like server program?You can make a table and poll it from time to time from the Java side and write and commit what ever you want to the table. I do not know any way to send a signal from Oracle DB an external Java application--Java or PL/SQL stored procedure.

  • How to query DDL locks on stored procedures/functions and packages?

    Hi!
    The subject says it all: How do I see existing DDL locks on stored procedures/functions and packages?
    While a procedure is executed it can't be deleted or replaced, so there has to be a DDL lock on it. The information does not seem to be in V$LOCK or V$LOCKED_OBJECTS.
    Thanks!
    Marcus
    Edited by: MMarcus on Nov 21, 2009 3:43 PM

    Hello,
    Here you can find an article about the view DBA_DDL_LOCKS:
    [http://www.praetoriate.com/int_40.htm]
    If you don't have this view on the Data Dictionary, you may have
    to execute the "OH/rdbms/admin/catblock.sql" script first.
    Hope it can help.
    Best regards,
    Jean-Valentin

  • Pivot table that uses a Stored Procedure parameter and filters the data based on it

    Hello, my 1st post.  I am lost.  Please help.
    I am trying to create an Excel Pivot Table that has data that comes from an ODC but needs to be filtered based on a parameter from a Stored Procedure.  This involves Project Server.  I need to filter the results based on the RBS value of the logged
    in user.  My Stored Procedure can return the RBS as long as the ResourceNTAccount value is given.  I cant figure out how to tie this all together.

    Hi,
    Based on your description,I think this issue should be  more related to Programming/coding, you can sumbit a new case to MSDN forum.
    As I'm not quite formular with Project Server, all I can tell you is that it is easy to running a Stored Procedure within Excel, however, if you have to pass dynamic parameters you’ll have to turn to VBA.For detailed information,please refer
    to:
    http://blogs.office.com/2010/06/07/running-a-sql-stored-procedure-from-excel-no-vba/
    Wind Zhang
    TechNet Community Support

  • SSRS 2008 Using Stored Procedure with SysRef Cursor Oracle

    Hi,
    I am new to SSRS.
    I have a ssrs procedure which runs to Return Result of Select Query. ( In form of SYS REF Cursor in Oracle ).
    When I am trying to see the Value in Test Window. It is showing Output. But when I m Running the Report in the environment it is giving me error.
    Please help me if there is a better way of handling it.
    As I read in some forum as SSRS has issue handling SYS Ref Cursor...
    Thanks
    Priyank
    Thanks Priyank Piyush

    Hi Priyank,
    According to your description, you are use a Stored Procedure from SysRef Cursor Oracle as the report dataset. The query works well in Dataset Query Designer, while an error occurs when you render the report.
    As per my understanding, the problem is that there are something wrong with the report design. Please double-check the design of the report. In order to trouble shoot the problem more efficiently, could you please post the detail error message? Then we can
    make further analysis.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to use a stored procedure as a datasource in Crystal Report for Eclipse

    Hi All,
    I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0".
    When I tried to add this stored procedure to the report using the connection explorer, I don't see any option to do this. But when I try to add any table, it shows options like "Add to the current report"....
    Can anybody assist me how to use a stored procedure as a data source in "Crystal Report For Eclipse"?
    Which driver should I use to connect to the oracle database? I tried using JDBC Driver for Oracle.
    Thanks in advance.

    Did you solve your problem? How did you do?

  • Looking for some help with using Oracle stored procedures in vb2010

    First off thank you to whoever lends me a hand with my problem. A little background first I am in a software development class and we are currently building our program using VB (I have no experience in this), and Oracle(currently in a Oracle class so I know how to use Oracle itself just not with VB).
    I am using vb2010 express edition if that helps. Currently I have a stored procedure that takes a 4char "ID" that returns a position (ie, salesperson,manager ect). I want to use the position returned to determine what vb form is displayed (this is acting as a login as you dont want a salesperson accessing the accountants page for payroll ect).
    Here is the code I have currently on the login page of my VB form
    Imports Oracle.DataAccess.Client
    Imports Oracle.DataAccess.Types
    Public Class Login
    Dim conn As New OracleConnection
    Private Sub empID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles empID.Click
    End Sub
    Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
    conn.ConnectionString = "User ID = Auto" & _
    ";Password = ********" & _
    ";Data Source = XE"
    conn.Open()
    Dim sq1 As String = "Return_Position" 'name of procedure
    Dim cmd As New OracleCommand(sq1, conn)
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.Add(New OracleParameter("I_EmpID", OracleDbType.Char, 4)).Value = Emp_ID.Text
    Dim dataReader As OracleDataReader = cmd.ExecuteReader
    dataReader.Read()
    Dim position As New ListBox
    position.Items.Add(dataReader.GetString(0)) 'were I am getting an error, I also tried using the dataReader.getstring(0) to store its value in a string but its a no go
    If position.FindStringExact("MANAGER") = "MANAGER" Then
    Me.Hide()
    Dim CallMenu As New Menu()
    CallMenu.ShowDialog()
    End If
    LoginBtn.Enabled = False
    End Sub
    I have read the oracle.net developer guide for using oracle in vb2010 and have successfully gotten through the document however they never use a stored procedure, since the teacher wants this program to user a layered architecture I cannot directly store sql queries like the document does, thus the reason I want to use stored procedures.
    This is getting frustrating getting stuck with this having no background in VB, I could easily do this in c++ using file i/o even through it would be a pain in the rear....

    Hello,
    I am calling Oracle 11g stored procedures from VB.Net 2010. Here is a code sample (based on your code) you should be able to successfully implement in your application.
    Please note that you may have to modify your stored procedure to include an OUT parameter (the employee position) if it doesn't have it yet.
    Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
    Dim sProcedureName As String = "Return_Position" 'name of stored procedure
    Dim ORConn as OracleConnection, sConn as String
    Dim sPosition as String, sDataSource as String, sSchema as String, sPWD as String
    Dim cmd As OracleCommand
    'please provide below sDataSource, sSchema and sPWD in order to connect to your Oracle DB
    sConn = "Data Source=" & sDataSource & ";User Id=" & sSchema & ";Password=" & sPWD & ";"
    ORConn = New OracleConnection(sConn)
    ORConn.Open()
    cmd = New OracleCommand(sProcedureName, ORConn)
    With cmd
    .CommandType = Data.CommandType.StoredProcedure
    'input parameter in your stored procedure is EmpId
    .Parameters.Add("EmpID", OracleDbType.Varchar2).Value = Emp_ID.Text
    .Parameters.Item("EmpID").Direction = ParameterDirection.Input
    'output parameter in your stored procedure is Emp_Position
    .Parameters.Add("Emp_Position", OracleDbType.Varchar2).Direction = ParameterDirection.Output
    .Parameters.Item("Emp_Position").Size = 50 'max number of characters for employee position
    Try
    .ExecuteNonQuery()
    Catch ex As Exception
    MsgBox(ex.Message)
    Exit sub
    End Try
    End With
    sPosition = cmd.Parameters.Item("Emp_Position").Value.ToString
    'close Oracle command
    If Not Cmd Is Nothing Then Cmd.Dispose()
    Cmd = Nothing
    'close Oracle connection
    If Not ORConn Is Nothing Then
    If not ORConn.State = 0 Then
    ORConn.Close()
    End If
    ORConn.Dispose()
    End If
    ORConn = Nothing
    If UCase(sPosition) = "MANAGER" Then
    Me.Hide()
    Dim CallMenu As New Menu()
    CallMenu.ShowDialog()
    End If
    LoginBtn.Enabled = False
    End Sub
    If you need further assistance with the code, please let me know.
    Regards,
    M. R.

  • Need to insert data in 2 tables thro stored procedure

    I need to create a stored procedure which will insert data in two tables. The procedure will get
    its inputs from an Oracle Developer Form which will be inserted into the tables.
    The 2 tables structure:
    1.FEES_MASTER
    Name Null? Type
    FEES_ID NOT NULL NUMBER(8) -- Primary Key
    CS_ID NOT NULL NUMBER(8) -- Class Student ID; An enrolled student
    REC_DATE NOT NULL DATE -- Fees receipt date
    REC_AMOUNT NOT NULL NUMBER(6) -- Fees receipt amount
    2.FEES_DETAIL
    Name Null? Type
    FEES_ID NOT NULL NUMBER(8) -- Foreign Key
    MONTH NOT NULL DATE -- First of each month to identify fee month
    Scenario:
    A student submits fees for 3 months through Master/Detail related blocks in a Developer Form as
    Under:
    Fees Master
    Fees ID : 11002
    Class Student ID : 356
    Receipt Date : 06-JAN-2001
    Receipt Amount : 1500
    Fees Detail
    Fees ID Fees Month
    11002 01-JAN-2001
    11002 01-FEB-2001
    11002 01-MAR-2001
    I need to check each fees detail record for fees month duplication as well before inserting new records.
    How can this be achieved?
    Thanks in advance.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Fan Liu ([email protected]):
    create primary key in the detail table. i think it's FEES_ID + MONTH. then mark the columns in Forms as primary key property true, then call check_record_uniqueness built-in in on-check-unique trigger.<HR></BLOCKQUOTE>
    Thanks very much. But what I need is to ensure transaction integrity thro stored procedure. The system allows a certain CS_ID (i.e. Class Student ID, which is assigned a new one to every student annually) to submit fees for 12 months only, because a student stays in a class for a year. The 2 columns in the FEES_DETAIL table are composite primary key which only ensures that a certain FEES_ID will not be repeated for the same month. But suppose:
    1)this data already exist in the tables:
    Fees Master
    Fees ID : 11002
    Class Student ID : 356
    Receipt Date : 06-JAN-2001
    Receipt Amount : 1500
    Fees Detail
    Fees ID Fees Month
    11002 01-JAN-2001
    11002 01-FEB-2001
    11002 01-MAR-2001
    2)And this data is currently being inserted:
    Fees Master
    Fees ID : 11300
    Class Student ID : 356
    Receipt Date : 04-FEB-2001
    Receipt Amount : 1500
    Fees Detail
    Fees ID Fees Month
    11300 01-JAN-2001
    11300 01-FEB-2001
    11300 01-MAR-2001
    The data in the 2nd condition is perfectly valid but the application can't allow a student to submit fees for a month which he has already submitted. Now only a stored procedure can make sure after checking that the same student doesn't pay fees for duplicate months. Another reason for my emphasis on stored procedure is that what if a user tries to insert data thro an SQL* Plus session instead of the Form.
    PROBLEM: Now the problem I am having is I don't know how the procedure will take input for multiple records from the FEES_DETAIL block in the Form.
    Please assist in this regard. Thanks.

  • Using a stored procedure for a  sender jdbc adapter

    Hi all,
    The requirement is to use a stored procedure, for extracting data from a oracle database.
    Is it possible to do this.
    If yes, what should be the source structure in this case.
    Please help with the exact soln.
    Thanks!!
    Younus

    Hi,
    Did you check the blog pointed by Aamir?
    /people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
    You will need to use Oracle Functions instead of Oracle Stored Procedures. Read thru the blog and the note pointed in the blog . Think it is quite a good example.
    Regards
    Bhavesh

  • Writing data to a foreign database-SQLServer using a stored procedure

    Does anyone know if I can Insert data into a SQLServer table which resides out on the WAN using a stored procedure which resides in my Oracle database?

    Is it possible? Sure. How easy it is really depends...
    Oracle has a feature called Heterogeneous Connectivity which allows you to create database links to non-Oracle databases. You can then treat the remote SQL Server objects just like you would use remote Oracle tables across a database link, i.e.
    INSERT INTO table_name@sql_server_dblink( <<list of columns>> )
      VALUES( <<list of values>> )Heterogeneous Connectivity requires some configuration on the Oracle database side. If you want to use Generic Connectivity, which is part of the base license, you'll need a SQL Server ODBC driver on the machine where Oracle is running. If you run Oracle on Windows, this is relatively easy. If you run Oracle on Unix, this gets a bit more challenging.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Need help with BC4J/Struts application using a Stored Procedure

    Hi,
    I am doing a proof of concept for a new project using JDeveloper, Struts and BC4J. We want to reuse our Business logic that is currently residing in Oracle Stored Procedures. I previously created a BC4J Entity Object based on a stored procedure Using Oracle Stored Procedures but this stored procedure is a bit different in that it returns a ref cursor as one of the paramters. http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html
    I tried the above method, but I am having some trouble with it. I keep getting the error ORA-01008: not all variables are bound when I test it using the AppModule tester.
    Here is the store procedure definition:
    CREATE OR REPLACE PACKAGE pprs_test_wrappers IS
    TYPE sn_srch_results IS REF CURSOR;
    PROCEDURE sn_srch_main_test
    (serial_num_in IN OUT VARCHAR2
    ,serial_coll_cd_in IN OUT NUMBER
    ,max_rows_allowed IN OUT NUMBER
    ,total_rows_selected IN OUT NUMBER
    ,message_cd_out IN OUT VARCHAR2
    ,query_results          OUT sn_srch_results
    END pprs_test_wrappers;
    And here is my code:
    package pprs;
    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.sql.Types;
    import oracle.jbo.JboException;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.DBTransaction;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.jbo.server.ViewRowImpl;
    import oracle.jbo.server.ViewRowSetImpl;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    // --- File generated by Oracle Business Components for Java.
    public class LienCheckImpl extends ViewObjectImpl
    * This is the PLSQL block that we will execute to retrieve the REF CURSOR
    private static final String SQL =
    "begin ? := pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
    public LienCheckImpl() {}
    * Overridden framework method.
    * Executed when the framework needs to issue the database query for
    * the query collection based on this view object. One view object
    * can produce many related result sets, each potentially the result
    * of different bind variable values. If the rowset in query is involved
    * in a framework-coordinated master/detail viewlink, then the params array
    * will contain one or more framework-supplied bind parameters. If there
    * are any user-supplied bind parameter values, they will PRECEED the
    * framework-supplied bind variable values in the params array, and the
    * number of user parameters will be indicated by the value of the
    * numUserParams argument.
    protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
    * If there are where-clause params (for example due to a view link)
    * they will be in the 'params' array.
    * We assume that if some parameter is present, that it is a Deptno
    * value to pass as an argument to the stored procedure.
    * NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
    * ---- but this parameter value should be oracle.jbo.domain.Number type.
    String serialNumIn = null;
    BigDecimal serialCollCdIn = null;
    BigDecimal maxRowsAllowed = null;
    BigDecimal totalRowsSelected = null;
    String messageCdOut = null;
    if (params != null) {
    serialNumIn = (String)params[0];
    serialCollCdIn = (BigDecimal)params[1];
    maxRowsAllowed = (BigDecimal)params[2];
    totalRowsSelected = (BigDecimal)params[3];
    messageCdOut = (String)params[4];
    storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
    serialCollCdIn,
    maxRowsAllowed,
    totalRowsSelected,
    messageCdOut));
    super.executeQueryForCollection(qc, params, numUserParams);
    * Overridden framework method.
    * Wipe out all traces of a built-in query for this VO
    protected void create() {
    getViewDef().setQuery(null);
    getViewDef().setSelectClause(null);
    setQuery(null);
    * Overridden framework method.
    * The role of this method is to "fetch", populate, and return a single row
    * from the datasource by calling createNewRowForCollection() and populating
    * its attributes using populateAttributeForRow().
    protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
    * We ignore the JDBC ResultSet passed by the framework (null anyway) and
    * use the resultset that we've stored in the query-collection-private
    * user data storage
    rs = getResultSet(qc);
    * Create a new row to populate
    ViewRowImpl r = createNewRowForCollection(qc);
    try {
    * Populate new row by attribute slot number for current row in Result Set
    populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
    populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
    populateAttributeForRow(r,2, rs.getString(3));
    populateAttributeForRow(r,3, rs.getString(4));
    populateAttributeForRow(r,4, rs.getString(5));
    catch (SQLException s) {
    throw new JboException(s);
    return r;
    * Overridden framework method.
    * Return true if the datasource has at least one more record to fetch.
    protected boolean hasNextForCollection(Object qc) {
    ResultSet rs = getResultSet(qc);
    boolean nextOne = false;
    try {
    nextOne = rs.next();
    * When were at the end of the result set, mark the query collection
    * as "FetchComplete".
    if (!nextOne) {
    setFetchCompleteForCollection(qc, true);
    * Close the result set, we're done with it
    rs.close();
    catch (SQLException s) {
    throw new JboException(s);
    return nextOne;
    * Overridden framework method.
    * The framework gives us a chance to clean up any resources related
    * to the datasource when a query collection is done being used.
    protected void releaseUserDataForCollection(Object qc, Object rs) {
    * Ignore the ResultSet passed in since we've created our own.
    * Fetch the ResultSet from the User-Data context instead
    ResultSet userDataRS = getResultSet(qc);
    if (userDataRS != null) {
    try {
    userDataRS.close();
    catch (SQLException s) {
    /* Ignore */
    super.releaseUserDataForCollection(qc, rs);
    * Return a JDBC ResultSet representing the REF CURSOR return
    * value from our stored package function.
    private ResultSet retrieveRefCursor(Object qc,
    String serialNum,
    BigDecimal serialColCd,
    BigDecimal maxRows,
    BigDecimal totalRows,
    String messageCd ) {
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
    * Register the first bind parameter as our return value of type CURSOR
    st.registerOutParameter(1,OracleTypes.CURSOR);
    * Set the value of the 2nd bind variable to pass id as argument
    if (serialNum == null) st.setNull(2,Types.CHAR);
    else st.setString(2,serialNum);
    if (serialColCd == null) st.setNull(3,Types.NUMERIC);
    else st.setBigDecimal(3,serialColCd);
    if (maxRows == null) st.setNull(4,Types.NUMERIC);
    else st.setBigDecimal(4,maxRows);
    if (totalRows == null) st.setNull(5,Types.NUMERIC);
    else st.setBigDecimal(5,totalRows);
    if (messageCd == null) st.setNull(6,Types.CHAR);
    else st.setString(6,messageCd);
    st.execute();
    ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
    * Make this result set use the fetch size from our View Object settings
    rs.setFetchSize(getFetchSize());
    return rs ;
    catch (SQLException s) {
    throw new JboException(s);
    finally {try {st.close();} catch (SQLException s) {}}
    * Store a new result set in the query-collection-private user-data context
    private void storeNewResultSet(Object qc, ResultSet rs) {
    ResultSet existingRs = getResultSet(qc);
    // If this query collection is getting reused, close out any previous rowset
    if (existingRs != null) {
    try {existingRs.close();} catch (SQLException s) {}
    setUserDataForCollection(qc,rs);
    hasNextForCollection(qc); // Prime the pump with the first row.
    * Retrieve the result set wrapper from the query-collection user-data
    private ResultSet getResultSet(Object qc) {
    return (ResultSet)getUserDataForCollection(qc);
    * Return either null or a new oracle.jbo.domain.Number
    private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
    try {
    return b != null ? new oracle.jbo.domain.Number(b) : null;
    catch (SQLException s) { }
    return null;
    I created the view object in expert mode so there is no entity object. Can someone help? I don't have much time left to finish this.
    Also, could I have done this from the Entity object instead of the view object by registering the ref cursor OUT parameter in handleStoredProcInsert()?
    Thanks
    Natalie

    I was able to get the input parameter by putting the following in my struts actions class
    vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
    The full code is:
    package mypackage2;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import oracle.jbo.html.BC4JContext;
    import oracle.jbo.ViewObject;
    import oracle.jbo.html.struts11.BC4JUtils;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class LienCheckView1QueryAction extends Action
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    BC4JContext context = BC4JContext.getContext(request);
    // Retrieve the view object instance to work with by name
    ViewObject vo = context.getApplicationModule().findViewObject("LienCheckView1");
    vo.setRangeSize(3);
    vo.setIterMode(ViewObject.ITER_MODE_LAST_PAGE_PARTIAL);
    // Do any additional VO setup here (e.g. setting bind parameter values)
    vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
    // default value for serialCollCd 1 is for Motor Vehicles
    vo.setWhereClauseParam(1,new oracle.jbo.domain.Number(1));
    // Default value for maxRows_allowed
    vo.setWhereClauseParam(2,new oracle.jbo.domain.Number(20));
    return BC4JUtils.getForwardFromContext(context, mapping);
    This doesn't always work properly though. The first time I press the query button, the SerialNum parameter is still null, however if I re-execute the query by pressing the query button again. It will work, and return the rows. I always have to query twice. Also the SerialNum attribute is set to a String in my view object, it is a varchar column in the database, but some serial number I enter give a "Error Message: oracle.jbo.domain.Number ". This happens even though the underlying BC4J is returning values for the query. I also get a "500 Internal Server Error java.lang.ClassCastException: java.lang.String on my View object's code at line 65 which is
    if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
    This is an input paramter to the oracle stored procedure that defaults to a Number value of 1.
    Any idea what the problem is? Here is the full code for my view object:
    package mypackage1;
    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.sql.Types;
    import oracle.jbo.JboException;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.DBTransaction;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.jbo.server.ViewRowImpl;
    import oracle.jbo.server.ViewRowSetImpl;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    // --- File generated by Oracle Business Components for Java.
    public class LienCheckViewImpl extends ViewObjectImpl
    * This is the PLSQL block that we will execute to retrieve the REF CURSOR
    private static final String SQL =
    "begin pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
    private BigDecimal totalRows = null;
    private String messageCd = null;
    private BigDecimal serialColCd = null;
    private BigDecimal maxRows = null;
    public LienCheckViewImpl() {}
    * Overridden framework method.
    * Executed when the framework needs to issue the database query for
    * the query collection based on this view object. One view object
    * can produce many related result sets, each potentially the result
    * of different bind variable values. If the rowset in query is involved
    * in a framework-coordinated master/detail viewlink, then the params array
    * will contain one or more framework-supplied bind parameters. If there
    * are any user-supplied bind parameter values, they will *PRECEED* the
    * framework-supplied bind variable values in the params array, and the
    * number of user parameters will be indicated by the value of the
    * numUserParams argument.
    protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
    * If there are where-clause params (for example due to a view link)
    * they will be in the 'params' array.
    * We assume that if some parameter is present, that it is a Deptno
    * value to pass as an argument to the stored procedure.
    * NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
    * ---- but this parameter value should be oracle.jbo.domain.Number type.
    String serialNumIn = null;
    BigDecimal serialCollCdIn = null;
    BigDecimal maxRowsAllowed = null;
    BigDecimal totalRowsSelected = null;
    String messageCdOut = null;
    if (params != null) {
    if (params.length>0) serialNumIn = (String)params[0];
    if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
    if (params.length>2) maxRowsAllowed = (BigDecimal)params[2];
    storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
    serialCollCdIn,
    maxRowsAllowed));
    super.executeQueryForCollection(qc, params, numUserParams);
    * Overridden framework method.
    * Wipe out all traces of a built-in query for this VO
    protected void create() {
    getViewDef().setQuery(null);
    getViewDef().setSelectClause(null);
    setQuery(null);
    * Overridden framework method.
    * The role of this method is to "fetch", populate, and return a single row
    * from the datasource by calling createNewRowForCollection() and populating
    * its attributes using populateAttributeForRow().
    protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
    * We ignore the JDBC ResultSet passed by the framework (null anyway) and
    * use the resultset that we've stored in the query-collection-private
    * user data storage
    rs = getResultSet(qc);
    * Create a new row to populate
    ViewRowImpl r = createNewRowForCollection(qc);
    try {
    * Populate new row by attribute slot number for current row in Result Set
    //AddedByRegisNum
    populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
    System.out.println("AddedByRegisNum :" + rs.getBigDecimal(1));
    // OrigRegisNum
    populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
    System.out.println("OrigRegisNum :" + rs.getBigDecimal(2));
    // SerialNum
    populateAttributeForRow(r,2, rs.getString(3));
    System.out.println("SerialNum :" + rs.getString(3));
    // SerialNumDesc
    populateAttributeForRow(r,3, rs.getString(4));
    System.out.println("SerialNumDesc :" + rs.getString(4));
    // FlagExactMatch
    populateAttributeForRow(r,4, rs.getString(5));
    System.out.println("FlagExactMatch :" + rs.getString(5));
    // MessageCd
    populateAttributeForRow(r,5, messageCd);
    // TotalRows
    populateAttributeForRow(r,6, totalRows);
    catch (SQLException s) {
    throw new JboException(s);
    return r;
    * Overridden framework method.
    * Return true if the datasource has at least one more record to fetch.
    protected boolean hasNextForCollection(Object qc) {
    ResultSet rs = getResultSet(qc);
    boolean nextOne = false;
    try {
    nextOne = rs.next();
    * When were at the end of the result set, mark the query collection
    * as "FetchComplete".
    if (!nextOne) {
    setFetchCompleteForCollection(qc, true);
    * Close the result set, we're done with it
    rs.close();
    catch (SQLException s) {
    throw new JboException(s);
    return nextOne;
    * Overridden framework method.
    * The framework gives us a chance to clean up any resources related
    * to the datasource when a query collection is done being used.
    protected void releaseUserDataForCollection(Object qc, Object rs) {
    * Ignore the ResultSet passed in since we've created our own.
    * Fetch the ResultSet from the User-Data context instead
    ResultSet userDataRS = getResultSet(qc);
    if (userDataRS != null) {
    try {
    userDataRS.close();
    catch (SQLException s) {
    /* Ignore */
    super.releaseUserDataForCollection(qc, rs);
    * Overridden framework method
    * Return the number of rows that would be returned by executing
    * the query implied by the datasource. This gives the developer a
    * chance to perform a fast count of the rows that would be retrieved
    * if all rows were fetched from the database. In the default implementation
    * the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
    * to let the database return the count. This count might only be an estimate
    * depending on how resource-intensive it would be to actually count the rows.
    public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
    Object[] params = viewRowSet.getParameters(true);
    String serialNumIn = (String)params[0];
    BigDecimal serialCollCdIn = (BigDecimal)params[1];
    BigDecimal maxRowsAllowed = (BigDecimal)params[2];
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
    * Register the fourth bind parameter as our return value of type NUMERIC
    st.registerOutParameter(4,Types.NUMERIC);
    * Set the value of the 3 bind variables to pass as arguments
    if (serialNumIn == null) st.setNull(1, Types.CHAR);
    else st.setString(1,serialNumIn);
    if (serialCollCdIn == null) st.setNull(2,Types.NUMERIC);
    else st.setBigDecimal(2,serialCollCdIn);
    if (maxRowsAllowed == null) st.setNull(3, Types.NUMERIC);
    else st.setBigDecimal(3, maxRowsAllowed);
    st.execute();
    System.out.println("returning value of :" + st.getLong(4));
    return st.getLong(4);
    catch (SQLException s) {
    throw new JboException(s);
    finally {try {st.close();} catch (SQLException s) {}}
    * Return a JDBC ResultSet representing the REF CURSOR return
    * value from our stored package function.
    private ResultSet retrieveRefCursor(Object qc,
    String serialNum,
    BigDecimal serialColCd,
    BigDecimal maxRows) {
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
    * Set the value of the bind variables
    System.out.println("SerialNumIn :" + serialNum);
    if (serialNum == null) st.setNull(1,Types.CHAR);
    else st.setString(1,serialNum);
    if (serialColCd == null) st.setNull(2,Types.NUMERIC);
    else st.setBigDecimal(2,serialColCd);
    if (maxRows == null) st.setNull(3,Types.NUMERIC);
    else st.setBigDecimal(3,maxRows);
    st.registerOutParameter(1, Types.CHAR); // serialNum
    st.registerOutParameter(2, Types.NUMERIC); // serialColCd
    st.registerOutParameter(3, Types.NUMERIC); // maxRows
    st.registerOutParameter(4, Types.NUMERIC); // totalRows
    st.registerOutParameter(5, Types.CHAR); // messageCd
    * Register the 6th bind parameter as our return value of type CURSOR
    st.registerOutParameter(6,OracleTypes.CURSOR);
    st.execute();
    ResultSet rs = ((OracleCallableStatement)st).getCursor(6);
    serialColCd = st.getBigDecimal(2);
    System.out.println("SerialColCd= " + serialColCd);
    maxRows = st.getBigDecimal(3);
    System.out.println("maxRows= " + maxRows);
    totalRows = st.getBigDecimal(4);
    System.out.println("totalRows= " + totalRows);
    messageCd = st.getString(5);
    System.out.println("messageCd= " + messageCd);
    * Make this result set use the fetch size from our View Object settings
    rs.setFetchSize(getFetchSize());
    return rs ;
    catch (SQLException s) {
    throw new JboException(s);
    finally {try {st.close();} catch (SQLException s) {}}
    * Store a new result set in the query-collection-private user-data context
    private void storeNewResultSet(Object qc, ResultSet rs) {
    ResultSet existingRs = getResultSet(qc);
    // If this query collection is getting reused, close out any previous rowset
    if (existingRs != null) {
    try {existingRs.close();} catch (SQLException s) {}
    setUserDataForCollection(qc,rs);
    hasNextForCollection(qc); // Prime the pump with the first row.
    * Retrieve the result set wrapper from the query-collection user-data
    private ResultSet getResultSet(Object qc) {
    return (ResultSet)getUserDataForCollection(qc);
    * Return either null or a new oracle.jbo.domain.Number
    private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
    try {
    return b != null ? new oracle.jbo.domain.Number(b) : null;
    catch (SQLException s) { }
    return null;
    Natalie

  • Problem creating dataset using db2 stored procedure in Eclipse BIRT

    Hi,
    I am using DB2 9.7 Express Edition in Eclipse BIRT(version 2.5.1) for generating reports. I have used Type4 driver for jdbc connection.
    For that, I have established jdbc connection using db2jcc.jar and db2jcc_license_cu.jar files.
    I have successfully created data source, say DB2BIRT having following requisites-
    Driver Class - com.ibm.db2.jcc.DB2Driver ( v3.50)
    Driver URL - jdbc:db2://localhost:50000/database_name
    User name - user_name
    Password - Password
    I have written some stored procedures and trying to use resultsets from those stored procedures into my report..
    The stored procedures having involvement of only single resultset are working absolutely fine for new dataset using above DB2BIRT.
    But, I am unable to create new dataset using stored procedures those having involvement of multiple resultsets.
    I am getting following error as -
    org.eclipse.birt.data.engine.odaconsumer.PreparedStatement$SequentialResultSetHandler getMoreResults
    SEVERE: Cannot get more result sets from the statement.
    Cannot get the result set.
    SQL error #1: [jcc][10120][10943][3.50.152] Invalid operation: statement is closed. ERRORCODE=-4470, SQLSTATE=null
    org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot get the result set.
    SQL error #1: [jcc][10120][10943][3.50.152] Invalid operation: statement is closed. ERRORCODE=-4470, SQLSTATE=null
    com.ibm.db2.jcc.b.SqlException: [jcc][10120][10943][3.50.152] Invalid operation: statement is closed. ERRORCODE=-4470, SQLSTATE=null
    at org.eclipse.birt.report.data.oda.jdbc.CallStatement.getMoreResults(CallStatement.java:1760)
    at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaAdvancedQuery.getMoreResults(OdaAdvancedQuery.java:214)
    at org.eclipse.birt.data.engine.odaconsumer.PreparedStatement$SequentialResultSetHandler.getMoreResults(PreparedStatement.java:5183)
    at org.eclipse.birt.data.engine.odaconsumer.PreparedStatement.getMoreResults(PreparedStatement.java:792)
    at org.eclipse.birt.data.engine.odaconsumer.PreparedStatement.flushResultSets(PreparedStatement.java:1009)
    at org.eclipse.birt.data.engine.odaconsumer.PreparedStatement.close(PreparedStatement.java:980)
    at org.eclipse.birt.data.engine.executor.DataSource$DataSourceReleaser.run(DataSource.java:374)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: com.ibm.db2.jcc.b.SqlException: [jcc][10120][10943][3.50.152] Invalid operation: statement is closed. ERRORCODE=-4470, SQLSTATE=null
    at com.ibm.db2.jcc.b.wc.a(wc.java:55)
    at com.ibm.db2.jcc.b.wc.a(wc.java:102)
    at com.ibm.db2.jcc.b.tk.db(tk.java:3118)
    at com.ibm.db2.jcc.b.tk.a(tk.java:1063)
    at com.ibm.db2.jcc.b.tk.getMoreResults(tk.java:908)
    at org.eclipse.birt.report.data.oda.jdbc.CallStatement.getMoreResults(CallStatement.java:1756)
    ... 7 more
    Moreover, I tried to resolve above issue by changing Driver Class from com.ibm.db2.jcc.DB2Driver ( v3.50) to com.ibm.db2.jcc.uw.DB2StoredProcDriver ( v3.50)
    So again while *"Test Connection"* for new Data source using this new driver class for stored procedure, there is an error reflection as -
    org.eclipse.birt.report.data.oda.jdbc.JDBCException: The selected driver cannot parse the given url.
    at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.testConnection(JDBCDriverManager.java:627)
    at org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader.testConnection(DriverLoader.java:120)
    at org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader.testConnection(DriverLoader.java:133)
    at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper.testConnection(JDBCSelectionPageHelper.java:653)
    at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper.access$7(JDBCSelectionPageHelper.java:627)
    at org.eclipse.birt.report.data.oda.jdbc.ui.profile.JDBCSelectionPageHelper$7.widgetSelected(JDBCSelectionPageHelper.java:549)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3493)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at org.eclipse.birt.report.designer.ui.dialogs.BaseDialog.open(BaseDialog.java:110)
    at org.eclipse.birt.report.designer.data.ui.actions.EditDataSourceAction.doAction(EditDataSourceAction.java:68)
    at org.eclipse.birt.report.designer.internal.ui.views.actions.AbstractElementAction.run(AbstractElementAction.java:70)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3493)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
    Can anybody address my this issue for successful implementation of stored procedure(with involvement of multiple resultsets) for creating Data set in Eclipse BIRT ?
    I will be really thankful.
    Thanks in advance,
    Manasi

    Well, in my stored procedure I have used 2 to3 cursors(as per my business logic) and all cursors except one are holding result sets. That exceptional cursor is intended for holding as well as returning result set after call to the procedure. And its perfectly running on db2 and returning the desired output. The problem is with Eclipse. The same procedure is not working in Eclipse BIRT.

  • Pass date range parameter  to SQL stored procedure.

    Hi,
    I'd like to pass a date range parameter from Crystal Reports to a sql stored procedure. Does anyone know if this is possible?
    I've had no problem passing standard datetime (single value) paramaters to and from but am struggling with getting a range value parameter to work.
    Environment: Crystal Reports 10/XI and SQL 2000 MSDE version or SQL 2005 Express Edition.
    Any help would be appreciated.

    C5112736 wrote:>
    > And then these 2 formulas 'Formula # 1' and 'Formula # 2' can be used to pass on to the stored procedure.
    Can someone please demonstrate exactly how to use formula results as date parameters to a SQL stored procedure?  Keep in mind, there are two parameters to the stored procedure.
    I have gleaned this much: Use Add Command and insert the procedure with
    EXEC ServerName.dbo.usp_sprocName;1 '{?StringParameter}'
    but if I try to do
    {CALL ServerName.dbo.usp_SprocName({@Formula1},{@Formula2})}
    then it gives the error "No value given for one or more required parameters". 
    Both of the parameters are VARCHAR(50).
    I have finally found this link: [http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx|http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx]
    This Microsoft site defines the format of the ODBC escape sequences, but I still do not know how to convince Crystal to insert it's parameter results or formula results.
    Pulling what's left of my hair out . . .
    ~ Shaun

  • Beans using plsql stored procedures

    Hi all
    My question is: has jdeveloper any graphic tool or asistant to make something like use stored procedures that return multiple rows ( ref cursor ).
    This is my problem, i'm student and have to build a web project that use beans, stored procedures and webservice.... i'm total noob in ejb, but i had worked with plsql some time.
    Can anyone tell me pls where to start, some article to read or something that may help me in this task
    Victor

    A Ref Cursor doesn't have any implicit structure, so it's not easy to automatically bind bean to it, however if you create database types like this, for example:
    drop type dept_t_list;
    drop type dept_t;
    drop type emp_t_list;
    drop type emp_t;
    create type emp_t as object(
      empno number(4),
      ename varchar2(10),
      job varchar2(9),
      mgr number(4),
      hiredate date,
      sal number(7,2),
      comm number(7,2),
      deptno number(2),
      terminated varchar(1)
    create type emp_t_list as table of emp_t;
    create type dept_t as object(
      deptno number(2),
      dname varchar2(14),
      loc varchar2(13),
      emps emp_t_list
    create type dept_t_list as table of dept_t;
    /Then you can create a pl/sql store procedure that works with this types and list types easily as beans and arrays of beans using the JPublisher tool.
    If you visit my Not Yet Documented Examples page and see example 36, it contains the SQL scripts that create example types and a stored package to work with them. It also contains the JPublisher-created Java classes for working with those types and package.
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    Inside JDeveloper, if you visit the connection navigator, expand your database connection and expand the "Packages" node, you can right-mouse and generate java (using JPublisher under the covers for you) on any package.

Maybe you are looking for

  • Port forwarding between two servers from Same subnet

     Hi, We have a Cisco ASA 5520 Version 8.4(3). There exists a site to site VPN tunnel between us and a client and the client sends us the data to our local host/server 10.x.x.20 on port 52944. So 10.x.x.20 gets data on port 52944. We want to forward t

  • Link to document not opening document in browser or client app

    hi All, i am using office 365 e1, i have aspx page on which we are fetching link of document and showing using CSOM. when user click on link instead of opening in client app or browser it is downloading.  if you have solution please help me

  • Restrict the users to use the field Unplanned delivery cost at MIRO

    Dear Friends, I want to restrict some users to use the unplanned delivery cost at MIRO. It should be displayed as visible to enter for some users and it should be displayed in grey mode not to enter anything for some users. I am asking this to restri

  • New Apple Keyboard KVM switch

    I shelled out the $50.00+ for the new aluminum keyboard. It does not work when connected with my Iogear KVM switch. Anyone know of a solution? I have been searching for hours, and cannot find anyone who has asked this question. I know there are new K

  • I have trial software which software to chose to buy? upgrade or box full version?

    HI I dowload the trial version and now it come to the time to purchase,  should I chose just upgrade ?? there is also a choice for Box?? please help sorry not too good with all these software