My question is maybe a little bit confusing. I have the problem that I'm calling an procedure with StoredProcedureCall
from Java e.g.:
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("test");
call.addNamedArgument("p_year");
call.addNamedArgument("p_rel");
call.useNamedCursorOutputAsResultSet("p_resset");
resset
is my result as a Cursor - as you can see - this works without any problems while the procedure looks like:
create or replace PROCEDURE TEST (p_year IN NUMBER,
p_rel IN VARCHAR2,
p_resset OUT SYS_REFCURSOR) AS
BEGIN
OPEN p_resset FOR
SELECT NVL (s.KA, 'Summe') ka,
COUNT (s.AZ) az
FROM table1 s,
table2 w
WHERE s.year= w.year
AND w.relevant = p_rel
AND s.year = p_year
END;
Now I've added a output parameter named "p_data"
with an own select call
create or replace PROCEDURE TEST (p_year IN NUMBER,
p_rel IN VARCHAR2,
p_data OUT VARCHAR2,
p_resset OUT SYS_REFCURSOR) AS
BEGIN
SELECT month
INTO p_data
FROM month_table b
WHERE month_nr = (SELECT MAX (month)
FROM instruction
WHERE year= b.year)
AND year= p_year;
OPEN p_resset FOR
SELECT NVL (s.KA, 'Summe') ka,
COUNT (s.AZ) az
FROM table1 s,
table2 w
WHERE s.year= w.year
AND w.relevant = p_rel
AND s.year = p_year
END;
And that's where I got stuck.
I don't know how to call the one single string which is the result of the new select statement (month) I tried to add
"call.addNamedOutputArgument("p_data");"
but that was totally wrong.
maybe also good to know is how I handle the result I get back from the first call:
DataReadQuery query = new DataReadQuery();
query.setCall(call);
query.addArgument("p_year");
query.addArgument("p_rel");
@SuppressWarnings("rawtypes")
List args = new ArrayList();
args.add(dbyear);
args.add(relevation);
@SuppressWarnings("rawtypes")
List result= (List) s.executeQuery(query, args);
for (int i = 0; i < ergebnis.size(); i++){
testDto record = new testDto();
ArrayRecord ar=(ArrayRecord) ergebnis.get(i);
record.setKa((ar.get("ka")).toString());
record.setAz((ar.get("az")).toString());
System.out.println("cursor : " + ergebnis.get(i));
result.add(ergebnis);
}
but as I said I'm not able to handle the single string to get it as a parameter to create a html/excel file after and that's the problem I have to handle.