用ireport呼叫oracle儲存過程

2021-08-23 12:55:18 字數 4693 閱讀 5598

ireport不能直接呼叫oracle儲存過程的結果集,因為儲存過程不能返回標準的結果集。在oracle中作為解決方案,你可以使用儲存函式來得到儲存過程的結果集。

create global temporary table temp_data(

create_date date,

case_id varchar2(30),

division_a nvarchar2(50),

division_name nvarchar2(50),

case_type nvarchar2(255),

case_stage_2 varchar2(20),

case_stage_3 varchar2(20),

case_stage_4 varchar2(20),

transaction_remark nvarchar2(255)

) on commit preserve rows

create or replace procedure load_temp_data

astype cur is ref cursor;

mycursor cur;

create_date date;

case_id varchar2(30);

division_a nvarchar2(50);

division_name nvarchar2(50);

case_type nvarchar2(255);

case_stage varchar2(2);

case_assignee varchar2(255);

transaction_remark nvarchar2(255);

begin

execute immediate 'truncate table temp_data';

commit;

open mycursor for

select

table1.create_date, table1.case_id,

table2.division_name,

table1.division_name,

table3.description c_type,

table1.case_stage, table1.case_assignee,

table1.transaction_remark

from

(select

cm.create_date, cm.case_id, dt.division_name, dt.division_parent_id, cm.case_type,

ct.transaction_id, ct.case_stage, ct.case_action, ct.transaction_remark, ct.case_assignee

from

com.division_type dt, com.user_master um, com.case_master cm, com.case_transaction ct

where

dt.division_id= um.division_id and cm.create_by= um.user_id and ct.case_id= cm.case_id

and ct.case_action='a5'

order by

cm.case_id, ct.transaction_id

)table1

join

(select

dt.division_id, dt.division_name

from

com.division_type dt

where

dt.division_level = 'a'

)table2 on table1.division_parent_id=table2.division_id

join

(select

p.field_value fvalue,

p.field_description description

from

com.parameter p

where

p.field_name='case_type'

)table3 on table1.case_type = table3.fvalue;

loop

fetch mycursor into

create_date, case_id, division_a, division_name,

case_type, case_stage, case_assignee, transaction_remark;

exit when mycursor%notfound;

dbms_output.put_line(case_id);

if case_stage='s2' then

insert into temp_data values

(create_date, case_id, division_a, division_name,

case_type, case_assignee, '---', '---', transaction_remark

);elsif case_stage='s3' then

insert into temp_data values

(create_date, case_id, division_a, division_name,

case_type, '---', case_assignee, '---', transaction_remark

);elsif case_stage='s4' then

insert into temp_data values

(create_date, case_id, division_a, division_name,

case_type, '---', '---', case_assignee, transaction_remark

);else

insert into temp_data values

(create_date, case_id, division_a, division_name,

case_type, '---', '---', '---', transaction_remark

);end if;

commit;

end loop;

close mycursor;

end;

--call load_temp_data();

--select * from temp_data;

create or replace type data_type as object(

create_date date,

case_id varchar2(30),

division_a nvarchar2(50),

division_name nvarchar2(50),

case_type nvarchar2(255),

case_stage_2 varchar2(20),

case_stage_3 varchar2(20),

case_stage_4 varchar2(20),

transaction_remark nvarchar2(255)

)create or replace type data_type_table as table of data_type

create or replace function datas_function

return data_type_table pipelined

ispragma autonomous_transaction;

type cur1 is ref cursor;

mycursor cur1;

out_rec data_type := data_type(null, null, null, null, null, null, null, null, null);

begin

load_temp_data();

open mycursor for

select

create_date, case_id, division_a, division_name, case_type,

case_stage_2, case_stage_3, case_stage_4, transaction_remark

from temp_data;

loop

fetch mycursor into

out_rec.create_date, out_rec.case_id, out_rec.division_a,

out_rec.division_name, out_rec.case_type, out_rec.case_stage_2,

out_rec.case_stage_3, out_rec.case_stage_4, out_rec.transaction_remark;

exit when mycursor%notfound;

pipe row(out_rec);

end loop;

close mycursor;

return;

end;

select * from table(datas_function());

有關iReport呼叫印表機的問題

1 前提 工程 b s結構 部署在一台伺服器上 接著,在另外乙個pc機訪問伺服器 在pc機上安裝印表機,點選列印 2 問題 pc機上印表機未出現列印的字條,而在伺服器上出現列印的資訊 3 最終效果 如何在呼叫pc機上的印表機列印出字條?4 使用工具 ireport 3.6.0 5 使用技術 stru...

JDBC用管理員(DBA)許可權連線Oracle

具體實施如下 private static string driver oracle.jdbc.oracledriver private static string url jdbc oracle thin localhost 1521 orcl private static string user...

qt呼叫import sys庫 用qt呼叫第三方庫

宣告 事先我已經自己動手寫了乙個簡單的dll檔案 mydll.dll c版介面的。並且用我前兩篇有關dll文章裡面的方法,從dll中匯出了導入庫 lib 檔案,dll中有兩個函式,原型如下 void helloworld 函式內部呼叫win32 api,功能是彈出乙個helloworld提示框 in...