Building report from PL/SQL cursor
Hello,
is there any way to build APEX report using just PL/SQL cursor?
I don't have grant to SELECT from views or tables, but I can use some functions returning row types and cursors. I know I can use them to build table from scratch with htp.p etc., but it’s not very nice. I want to do it using APEX reporting with filtering and pagination functionality.
Is it possible?
Regards,
Przemek
Apologies for the delay, I was out of the office.
Below is a package serving as the basis for creating a view based on a pipelined function. The package is just a skeleton and will not compile in its current form, you will need to go through it filling in the blanks as described by the comments.
If you want some control over what rows are returned by the view from a larger result set, use the set_parameters function in the WHERE clause, E.G.:
select * from really_big_complicated_slow_view where 1 = view_pkg.set_parameters(something_that_reduces_the_view_result_set_size);
Or, a more concrete example:
select result_text from view_to_convert_to_csv where 1 = view_pkg.set_parameters(pi_table => 'my_table', pi_where = 'whatever');
In the spirit of full disclosure, I got the idea for using the "set_parameters" function in the view WHERE clause from a post or blog somewhere a couple of years ago but have lost track of who actually deserves the credit for the good idea.
-Tom
create or replace package demo_vw as
-- Package to serve as the basis for a view based on a function
-- Customize this record so that it represents a row from this view...
type row_type is record (
-- record fields here
type table_type is table of row_type;
-- This function is used in the DDL to define the view, for example:
-- create or replace view my_view (col1, col2, ..., colN) as
-- select * from table(my_view_vw.get_view);
function get_view
return table_type
pipelined;
-- Customize this function header to accept the parameters for this view, if
-- any. If this view does not require any parameters, the set_parameters
-- function may be deleted.
-- This function should always return 1 and is called as follows
-- select <whatever>
-- from my_view
-- where 1 = my_view_vw.set_parameters(p1, p2, p3, ..., pN);
function set_parameters (pi_whatever1 in whatever,
pi_whateverN in whatever)
return number;
end demo_vw;
show error package demo_vw
create or replace package body demo_vw as
-- Customize this list of private global variables to match the parameters
-- required by the view. These variables are set, reset, and validated by
-- set_parameters, reset_parameters, and valid_parameters respectively...
g_var1 whatever;
g_varN whatever;
function set_parameters (pi_whatever1 in whatever,
pi_whateverN in whatever)
return number
is
-- Customize this function header to accept the parameters for this view, if
-- any. If this view does not require any parameters, the set_parameters
-- function may be deleted.
-- This function should always return 1 and is called as follows
-- select col1, col2, ..., colN
-- from my_view
-- where 1 = my_view_vw.set_parameters(p1, p2, p3, ..., pN);
begin
g_var1 := pi_whatever1;
g_varN := pi_whateverN;
return 1;
end set_parameters;
function valid_parameters
return boolean
is
-- Customize...
-- Assumes that set_parameters has been called to set the value of the view
-- parameters.
l_valid boolean := true;
begin
return l_valid;
end valid_parameters;
procedure reset_parameters
is
-- Customize...
-- This is called at the end of the get_view function to reset the view
-- parameters for the next caller.
begin
g_var1 := null;
g_varN := null;
end reset_parameters;
function get_view
return table_type
pipelined
is
-- build and return each row for the view...
l_row row_type;
begin
if valid_parameters then
-- do your process to populate the l_row variable here...
pipe row (l_row);
end if;
reset_parameters;
exception
when others then
reset_parameters;
raise;
end get_view;
end demo_vw;
show error package body demo_vw
create or replace view demo
as
select * from table(demo_vw.get_view);
Similar Messages
-
ERROR:SRW Packages to call report from PL/SQL.
Hi,
I am facing the following problem while calling a report from PL/SQL Block.
This is my code
SRW.Start_Debugging;
MYPLIST :=SRW_PARAMLIST(SRW_PARAMETER('',''));
SRW.ADD_PARAMETER(myPlist,'GATEWAY' ,'http:..............');
SRW.ADD_PARAMETER(myPlist,'USERID' ,'CGIA_AUTO/AUTO_DEV@ipaddress/ORCL');
SRW.ADD_PARAMETER(myPlist,'SERVER' ,'rep_cgian');
SRW.ADD_PARAMETER(myPlist,'REPORT' ,'PGIRCGIC047.rdf');
SRW.ADD_PARAMETER(myPlist,'DESTYPE' ,'file');
SRW.ADD_PARAMETER(myPlist,'DESFORMAT' ,'pdf');
SRW.ADD_PARAMETER(myPlist,'DESNAME' ,'\\ipaddress\CGIA_FormPrint\WatchFolder\OTHERS\'||Z.CS_REMARKS_BL||'_'||Z.CS_CHQ_NO||'_'||M_SEQ_NO||'-'||Z.CS_FLEX_07||'-'||Z.CS_FLEX_08||'.pdf');
SRW.ADD_PARAMETER(myPlist,'PARAMFORM' ,'NO');
SRW.ADD_PARAMETER(myPlist,'P_1' ,Z.CS_BANK_CODE);
SRW.ADD_PARAMETER(myPlist,'P_2' ,Z.CS_BAD_ACNT_NO);
SRW.ADD_PARAMETER(myPlist,'P_3' ,Z.CS_CHQ_BOOK_ID);
SRW.ADD_PARAMETER(myPlist,'P_4' ,Z.CS_CHQ_NO);
SRW.ADD_PARAMETER(myPlist,'P_5' ,Z.CS_CHQ_NO);
MYIDENT:=SRW.RUN_REPORT(MYPLIST);
MYSTATUS := SRW.REPORT_STATUS(MYIDENT);
SRW.STOP_DEBUGGING;
*** Length of Paramlist : 1
OK : Parameter added : GATEWAY=http://...
*** Length of Paramlist : 2
OK : Parameter added : USERID=CGIA_AUTO/AUTO_DEV@ipaddress/ORCL
*** Length of Paramlist : 3
OK : Parameter added : SERVER=rep_cgian
*** Length of Paramlist : 4
OK : Parameter added : REPORT=PGIRCGIC047.rdf
*** Length of Paramlist : 5
OK : Parameter added : DESTYPE=file
*** Length of Paramlist : 6
OK : Parameter added : DESFORMAT=pdf
*** Length of Paramlist : 7
OK : Parameter added :
DESNAME=\\ipaddress\CGIA_FormPrint\WatchFolder\OTHERS\CUST000115_102024_16--.pd
f
*** Length of Paramlist : 8
OK : Parameter added : PARAMFORM=NO
*** Length of Paramlist : 9
OK : Parameter added : P_1=SDNB
*** Length of Paramlist : 10
OK : Parameter added : P_2=7000674257
*** Length of Paramlist : 11
OK : Parameter added : P_3=7000
*** Length of Paramlist : 12
OK : Parameter added : P_4=102024
*** Length of Paramlist : 13
OK : Parameter added : P_5=102024
Starting run_report: building url
*** Building URL (RUN_REPORT)
OK : URL built :
http://ipaddress/reports/rwservlet?&USERID=CGIA_AUTO%2FAUTO_DEV%40ipaddress%2FORCL&SERVER=rep_cgian&REPORT=PGIRCGIC047.rdf&DESTYPE=file&DESFORMAT=
pdf&DESNAME=%5C%5Cipaddress%5CCGIA_FormPrint%5CWatchFolder%5COTHERS%5CCUST00
*** Submitting HTTP Request
*** using URL
:http://ipaddress/reports/rwservlet?&USERID=CGIA_AUTO%2FAUTO_DEV%ORCL&SERVER=rep_cgian&REPORT=PGIRCGIC047.rdf&DESTYPE=file&DESFORMAT
=pdf&DESNAME=%5C%5Cipaddress%5CCGIA_FormPrint%5CWatchFolder%5COTHERS%5CCUST0001
OK : Request submitted - Return stream : <?xml version = '1.0' encoding =
'ISO-8859-1' standalone = 'yes'?>
<serverQueues>
<error code="503"
component="REP" message="You did not specify the name of a
report."/>
</serverQueues>
Here in this case even though i specify the report id in the parameter,debugger message says that 'You did not specify the name'.
The same code is working in some other server and giving the pdf output.
Thanks in advance for any clarification.Hello Chirag,
If you want to invoke and run a report from your PL/SQL code in the database, you can do so by installing and using the SRW package supplied with Reports. This package allows you to run parametrized report jobs on a specified Reports Server from your PL/SQL program and track the job status. Please take a look at the documentation for this package in the Publishing Reports manual on OTN at: http://download-west.oracle.com/docs/html/A92102_01/toc.htm.
On the other hand, if you just need to invoke the Reports Builder program from your PL/SQL routine, you would need to use the default builtin for calling external applications from PL/SQL.
Thanks,
The Oracle Reports Team. -
Invoking XML Publisher Report from PL/SQL
Hi,
I have a PL/SQL procecedure which invokes the Concurrent Request for the XML Publisher Report. This one finishes with a warning and I get 'Unable to publish output' when I try to view the output. Exact Error: "Unable to find the published output for this request "
But if I run the same report using Concurrent program, the Report executes with no error. Also the desired output is coming. I am not sure where I am doing wrong in code.
My code which invokes the XML Publisher Report (from PL/SQL package)is something like this:
declare
x boolean;
l_no_of_copies varchar2(45);
l_printername varchar2(45);
l_print_style varchar2(45);
l_result boolean;
y number;
begin
x := fnd_request.add_layout (template_appl_name => 'XXTMG', template_code => 'XXT_5001_BOL_T', template_language => 'EN', template_territory => 'US', output_format => 'XML');
l_no_of_copies := fnd_profile.VALUE ('XXTMG_SH_BOL_REPORT_NO_OF_COPIES');
l_printername := fnd_profile.VALUE ('XXTMG_SH_BOL_REPORT_PRINTER');
l_print_style := NULL; --For setting the Printer Options
l_result := fnd_request.set_print_options (l_printername, l_print_style, l_no_of_copies, TRUE, 'N');
l_result := fnd_request.add_printer (l_printername, 0);
y := fnd_request.submit_request ('XXTMG', 'XXT_5001_BOL', '', TO_CHAR (SYSDATE, 'YYYY/MM/DD HH24:MI:SS'), FALSE, 'CH-120079') ;
end;
Please let me know where I might be going wrong
ThanksHi Sumit,
You can try with this code:
exec dbms_application_info.set_client_info(org_id)
exec fnd_global.APPS_INITIALIZE(user_id,resp_id,appl_id);
declare
x boolean;
l_no_of_copies varchar2(45);
l_printername varchar2(45);
l_print_style varchar2(45);
l_result boolean;
y number;
begin
x := fnd_request.add_layout ('XXTMG' --template_appl_name
,'XXT_5001_BOL_T' --template_code
,'en' --template_language
,'US' --template_territory
,'XML' --output_format
if (x=TRUE) then
y := fnd_request.submit_request (
'XXTMG' --application
,'XXT_5001_BOL' --program
,SYSDATE --start_time
,FALSE --sub_request
,'CH-120079' --argument1 (Program's Parameter)
if y>0 then
dbms_output.put_line('Request ID '||y);
end if;
end if; --if (x=TRUE) then
end;
Make sure that program has only one input parameter. If program has other parameters then you can pass those parameters like argument1, argument2... etc.
Now you can see this submited request in your application using your user id. If you able to see your request in concurrent request then you can add printer parameters in this programs.
You don't need to pass all 100 parameters.
I am executing many programs/reports using this code.
Thanks
Ravi
[email protected]
Message was edited by:
Ravi Tripathi -
Execute report from pl/sql procedure
hi all
please, can i know whether there's any way to execute a report from pl/sql stored procedure??
thank you.Hallo,
usually you would use 21.1 The Event-Driven Publishing API
You can search the forum for examples Google: site:forums.oracle.com call report from pl/sql
Regards
Marcus -
Run report from PL/sql procedure
Please any one tell how to I run a report from pl/sql procedure.
I am not sure, but depending on your environment you can create a script to run your PL/SQL code and then generate the report. As is customary in an UNIX environment utilizing shell scripts.
-
Calling a report from pl/sql
Is it possible to call a report from pl/sql. I want to create a package which when invoked by dbms_jobs will create parameters and then call a report.
Thanks in advance,
Mark.Mark,
cf: http://download-uk.oracle.com/docs/cd/B10464_05/bi.904/b13673/pbr_evnt.htm#sthref1477
Patrick. -
Run multiple reports from PL/SQL
I am planning to run reports from a PL/SQL batch program. My requirement is i need to generate multiple(around 50) reports with only a difference in one numeric parameter which will go from 1 to 50. I am planning to invoke the report inside a loop which goes from 1..50. I heard that i need to use a utl_http package which i havent used till now. Does somone has a sample code for running a report from pl/sql. i need it ASAP. Thanks in advance
hi rejesh,
we have an pl/sql API in reports to do exactly what you want to do.
The Reports Event Driven Publishing API
find the documentation including examples in the reports getting
started on technet.
http://otn.oracle.com/products/reports/htdocs/getstart/docs/a92102_01.pdf
Chapter 11
regards,
christian -
Generating reports from PL/SQL
I'm new to the world of BI Publisher - so far I'm impressed with what I've seen. I've managed to create a report and an RTF template and generate some nice looking PDF's :)
What I need to do now is to have a nightly job that produces PDF shipment reports using my template for all new shipments generated during the day and I'm having a little difficulty putting it all together.
I've looked at the BI Publisher API's that allow me to generate an XSL from my RTF template and the using the FO engine merge the XSL and XML data to produce the PDF. Then using the delivery manager API's I can send these reports out via email.
I'm a little unsure of how to get the XML source - I've played around with the DataEngine API to generate XML from a SQL query so I think that's where I should be heading.
Does this all sounds right ? Ideally, I want to be able to do all of this from within a scheduled PL/SQL job every night but all the interaction with the BI server seems to be via Java.
Is there an easy(ish) way to run all of this from within PL/SQL ?
And should I be going about this by:
1/ generate XML data using dataengine API
2/ create an RTF template using word and the xml data generated above
3/ use the RTF processor to generate an XSL-FO from my RTF template
(1-3 will only need to be done once)
4/ Then my nightly job will use the dataengine to generate new shipment XML data
5/ use FO processor to generate PDF's from each
6/ use delivery manager API's to email out
All sounds very cumbersome and intense -is there no easier way ?! :) Also, I'm thinking i should be using the bursting engine to split one query containing all the new shipment data and generate/mail a PDF for each shipment ? Is that necessary if all going to the same email address ?
Help/guidance/suggestions greatly appreciated !
Many thanks,
Brentrepost .... Has anyone successfully called BIP web services from within the database using Java stored procedures ?
Still struggling to work out how to generate my reports from PL/SQL ! :(( -
Can I call a report from pl/sql?
How can I call a report from pl/sql? I would like the output to be pdf and have it outputted to the screen?
We are running Oracle 10g database and 10.1.2.3 application server on LInux Redhat 4.
Thanks.
Shirley
Edited by: jonesfnalgov on Jul 12, 2011 2:17 PM
Edited by: jonesfnalgov on Jul 12, 2011 2:18 PMHello,
a package is provided : srwAPIins.sql installs the Event-Driven Publishing API.
http://download.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_evnt.htm
The Event-Driven Publishing API is a PL/SQL package that provides the basic functions required for the development of procedures that respond to events in the database. Event-driven jobs are submitted using the HTTP protocol. The server assigns a unique job_ident record to every call, useful for tracking the status of the job.
Regards -
Change Build Status From PL/SQL
Apex 3.2
Please see my previous thread
Change Build Status From PL/SQL
We tried this code
CREATE OR REPLACE procedure APEX_030200.pr_sup_unfreeze_apex
as
begin
for l_app in (select id
,security_group_id
from APEX_030200.wwv_flows
loop
wwv_flow_api.set_security_group_id(l_app.security_group_id);
wwv_flow_api.set_flow_status (p_flow_id => l_app.id
,p_flow_status => 'AVAILABLE'
end loop;
commit;
exception when others then
dbms_output.put_line (sqlcode);
dbms_output.put_line (substr(sqlerrm,1,250));
dbms_output.put_line (substr(sqlerrm,250,250));
rollback;
raise;
end;but recieved error
BEGIN APEX_030200.pr_sup_freeze_apex; END;
Error at line 1
ORA-20001: Package variable g_security_group_id must be set.
ORA-06512: at "APEX_030200.PR_SUP_FREEZE_APEX", line 51
ORA-06512: at line 1
Any ideas ?
If I just run
select id,security_group_id
from APEX_030200.wwv_flows
ID SECURITY_GROUP_ID
4000 10
4050 10
4155 10
4300 10
4350 10
4400 10
4411 10
4500 10
4550 10
4700 10
125 1.07701203277056E15
1000 1.08971536719791E15
1010 1.08971536719791E15
114 1.41432144152464E15
123 1.43440509319107E15
160 2.25192481868561E15
190 2.41432896355852E15
100 3.93632559648557E15
103 3.93632559648557E15
130 5.9543257997941E15
140 5.95501879180405E15
Edited by: Gus C on Nov 8, 2012 5:43 AM
Edited by: Gus C on Nov 8, 2012 5:50 AMHi Gus,
as Rod already mentioned, wwv_flow_api.set_flow_status would be the way to go. It's no officially documented or supported API but it will do what you want. Just be prepared that it might be removed in the future. The API is defined as following:
procedure set_flow_status (
p_flow_id in number,
p_flow_status in varchar2,
p_flow_status_message in varchar2 default null,
p_restrict_to_user_list in varchar2 default null )Example code to make all applications unavailable (has to be executed as APEX_040200).
begin
for l_app in ( select id,
security_group_id
from wwv_flows )
loop
wwv_flow_api.set_security_group_id(l_app.security_group_id);
wwv_flow_api.set_flow_status (
p_flow_id => l_app.id,
p_flow_status => 'UNAVAILABLE' );
end loop;
commit;
end;Regards
Patrick
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf -
Build Reports from XML output from Reports
Hi,
I was just wondering if it is possible to build reports from output in XML format, originally generated by Oracle Reports.
The XML output produced by Reports is stored in a database for further processing.
TIA
HienHi Hien
If I have understood this right, you need to create report in XML format from an XML Report Definition File. From the Builder, Generate to File from the File menu and choose XML format for the output.
Remember that XML output from Reports is Data driven and faithfully reproduces the Data Model. It is NOT layout driven.
Regards
Sripathy -
How to Start report from pl sql procedure
I need to create a procedure which runs report and email report output to specified email adress.
I don't know how to start report from pl/sql. Any help will be appreciated.I want to start oracle report from plsql procedure. Is there any OS system command I can use or any other method? My database is installed on windows 2000 machine.
-
Hello, i want to run reports from pl/sql, how can i do it, i suppose i can use
RWRUN60 with the appropiate parameters, but i don4t know how to execute RWRUN60 from pl/sql.
Thanks in advance.Hi,
I believe by mistake you posted the same question twice. See my response in the other one.
Thanks,
Rohit -
Call report from pl-sql routine
I just got started on the report-tool, so, this might be a very basic question, but, would appreciate your
response.
I have a pl-sql routine registered as a concurrent program. How do I make call to report-builder from this routine.
Thxs,Hello Chirag,
If you want to invoke and run a report from your PL/SQL code in the database, you can do so by installing and using the SRW package supplied with Reports. This package allows you to run parametrized report jobs on a specified Reports Server from your PL/SQL program and track the job status. Please take a look at the documentation for this package in the Publishing Reports manual on OTN at: http://download-west.oracle.com/docs/html/A92102_01/toc.htm.
On the other hand, if you just need to invoke the Reports Builder program from your PL/SQL routine, you would need to use the default builtin for calling external applications from PL/SQL.
Thanks,
The Oracle Reports Team. -
How to run Report Builder Report from Command line
Hello,
Can Oracle Report Builder Report (run time report) run from Command line ( SQL prompt or Shell script).
Quick response will be appreciated.
Thanks,
AtifHi Atif,
please see Note 74648.1 on Metalink.
Monica
Maybe you are looking for
-
HP 8560w Panel Driver for Windows 8.1
Hi, I am trying to locate the correct driver for the HP 8560w Dreamcolor 2 panel as Windows 8.1 only recognises it as an Generic Plug-n-Play monitor and there appear to be no drivers on the HP driver site for Windows 8.1 X64. Thanks in advance, T
-
HT204370 How do I download a purchased movie from the cloud to my iPad I?
How do I download a purchased movie from the cloud to my iPad I?
-
Interactive report - strip HTML
Hi, Where is the option to strip HTML for an Interactive report? Is it possible to set this option for each column? N.B. This setting can be found under Layout and Pagination for classic report. Thanks, Louis-Guillaume Homepage: http://www.insum.ca B
-
When will JDeveloper support Java 6?
-
Skype Community needs a search feature
Skype community has always been about discovering new friends or similiar ideas.I think it would be a lot easier if we can add a search feature to find people around our age or trying to learn a similiar language etc.It would make skype community a l