About using cursor expressions in Oracle Reports
I've just discovered a rather old syntax of the mighty select statement. It seems related to the concept of inline view or more precisely scalar view. It's the cursor syntax in a select statement.
Example:
select d.dname
,cursor(select e.empno,e.ename,sal
from scott.emp e
where e.deptno = d.deptno)
from scott.dept d
I have two questions:
1) Performance: how is the performance of this select in comparison to standard join?
2) Usage: I've use this from sqlplus and it's ok, but can't use it on a tool like Oracle Reports. Although the select statement is correctly processed, can't display it since the datatype is Database - Unknown ...
It seems there´s no way to use cursor expressions at least if datasource is a SQL Query.
Thanks in advance ....
I think you have answered your own question: CURSOR is not something you can display.
Similar Messages
-
Can we use Dynamic SQL in Oracle Reports ?
Hi ,
Can we use Dynamic SQL in Oracle Reports ?
If yes please give some examples .
Thanx
sriniI believe the built-in package SRW.Do_Sql is what you are looking for
Example from the document:
/* Suppose you want to create a "table of contents" by getting the
** first character of a columns value, and page number on which its
** field fires to print. Assume that you want to put the "table of
contents"
** into a table named SHIP. You could write the following construct:
DECLARE
PAGE_NO NUMBER;
PAGE_FOR INDEX NUMBER;
SORT_CHAR CHAR(1);
CMD_LINE CHAR(200);
BEGIN
SORT_CHAR := :SORT_NAME ;
IF :CALLED = Y THEN
SRW.GET_PAGE_NUM(PAGE_FOR_INDEX);
SRW.USER_EXIT(RWECOP PAGE_FOR_INDEX
P_START_PAGENO);
SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO));
END IF;
SRW.GET_PAGE_NUM(PAGE_NO);
CMD_LINE := INSERT INTO SHIP VALUES
(||SORT_CHAR||,||TO_CHAR(PAGE_NO)||);
SRW.MESSAGE(2,CMD_LINE);
SRW.DO_SQL(CMD_LINE);
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
WHEN SRW.DO_SQL_FAILURE THEN
SRW.MESSAGE(1,FAILED TO INSERT ROW INTO SHIP TABLE);
WHEN OTHERS THEN
COMMIT;
END; -
How to write REF-CURSOR Query in Oracle Reports
Hello Guys!!
I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
The issue I have is with the query inside the Oracle reports(attached to this file).
The query works fine until the last two EXISTS conditions.
IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.
Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
appreciated.
Thanks,
Vishal
-------------------------------------------------------Query in Oracle Reports---------------------------------------------------------
select c.key_segment, p.supplier_id,
decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
sum(a.ext_price) sales_dols,
sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
a.doc_dt, a.ext_price, a.units)) cust_reb_dols,
sum(a.units) units,
sum(a.ext_cost) cost_dols
from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
where a.doc_dt between :in_start_dt and :in_end_dt
and a.customer_oc = h.control_loc_id
and a.sold_to_customer_id = h.sold_to_cust_id
and a.ship_to_customer_id = h.ship_to_cust_id
and ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
and a.product_id = p.product_id
and p.product_gl_class_cd = 'CHEM'
and p.product_legal_name = c.product_legal_name
and c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
-- and (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
-- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
and a.sale_type_cd in ('02','08')
and a.document_type_cd in ('I','C','D')
and (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
and a.units <> 0
and a.unit_cost <> 0
and a.unit_price <> 0
-- NEW FILTERS ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
and ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
FROM report_param
WHERE report_id = :IN_REPORT_ID
AND session_id= :IN_SESSION_ID
AND USER_ID = :IN_USER_ID
AND param_name='LOCATION_TYPE')))
and ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
and ((:in_sales_rep = 'ALL') or (nvl(a.territory_id,'<blank>') in (SELECT param_value
FROM report_param
WHERE report_id = :IN_REPORT_ID
AND session_id= :IN_SESSION_ID
AND USER_ID = :IN_USER_ID
AND param_name='SALES_REP_TYPE')))
and EXISTS
(SELECT '1'
FROM locations l, report_param rp
WHERE rp.report_id = :IN_REPORT_ID
AND rp.session_id= :IN_SESSION_ID
AND rp.user_id = :IN_USER_ID
AND rp.param_value = l.region
AND rp.param_name = 'REGION_TYPE'
AND a.warehouse_id = L.ARS_LOCATION)
and EXISTS
(SELECT '1'
FROM locations l, report_param rp
WHERE rp.report_id = :IN_REPORT_ID
AND rp.session_id= :IN_SESSION_ID
AND rp.user_id = :IN_USER_ID
AND rp.param_value = l.region
AND rp.param_name = 'DIVISION_TYPE'
AND a.warehouse_id = L.ARS_LOCATION)
group by c.key_segment, P.supplier_id,
decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))Hi,
I need your help to create a report using Ref-Cursor. please see the below thread
Report using ref cursor or dynamic Sql -
How can I use unix commands from oracle report
I have to use the following command from oracle reports.
In oracle forms we can use the HOST command but what about oracle reports2.5.
I have to email the attached file 100245.pdf from oracle reports to the given email id
uuencode 100245.pdf 100245.pdf | mailx -s "test" [email protected]Hi,
It's because .bat (or .cmd) files are scripts and not executables and are interpreted using the command line executable - which is normally cmd.exe (although you can buy others).
So you need to call cmd.exe passing the bat file name as a parameter, something like
cmd.exe /c batchfilename
Without the /c you will never get a response.
However, this brings us to the bizarre conclusion that you are going to:
call cmd.exe (a shell interpreter)
to launch a batch file
that calls cygwin (another shell interpreter)
which then runs ls
When shouldn't that just be:
call cmd.exe to run the dir command
Or better yet, If you are just after a file name listing and you seem to understand Java stored procs, why not just write a JSP to list the contents of a directory? No problems with OS dependant commands, scripts and 3rd party interpreters. Plenty of examples of that out on the internet as well.
HTH
Chris -
How to use lexical paramter in oracle reports
I have a query like,
select * from t1 where &c1=:v_srep;
where t1 is tablename
c1 is column name
How do I create &c1 and how should I populate it ?
Thanks,From Oracle 8.1.5 database, we can use dynamic ref cursors.
With dynamic ref cursor we can really avoid the use of lexical parameters in Reports.
With static ref cursor this is not possible in all cases.
For example, if we need dynamic WHERE, we practically can't use static ref cursor.
But, problem is that Reports needs static ref cursor type for building Report Layout.
Solution (as i know, first published in my post in MetaLink Reports Forum,
thread "Report based on Ref Cursor or PL/SQL Table", 24-Aug-01) is:
in package specification we must have both ref cursor types,
static for Report Layout and dynamic for ref cursor query.
Dynamic ref cursor examples:
"Dynamic Table in the Second Query with Oracle Reports"
http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#JULY
"Using a Collection Instead of a Temporary Table in Complex Reports"
http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#NOVEMBER
Regards,
Zlatko Sirotic -
My question is about performance:
If I have a java program to call a stored procedure using a cursor, the code segment is like this:
ResultSet rs = oracleCallableStatement.getObject(a_cursor);
while (rs.hasNext()) {
rs.getString(column_name);
My question is -- how does this work behind scene? Would my java process talk to oracle to get the next record for EACH call inside the while loop? If yes, this seems to slow down my program and we should avoid using cursor.
Thanks in advance for any reply.
tomVictor,
Is there something similar using PL/SQL, we use a gateway connection to AS400. I see that a PL/SQL cursor is fetching as many times as there are number of rows.
Thanks for your help in advance.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Victor Yu ([email protected]):
Hi, Tom,
Actually, Oracle JDBC will cache some rows in client side to reduce the round trip. It's called prefetching. Once your next() calls have run through those rows, JDBC will go back to fetch the next N rows. The default number of rows to prefetch to the client is 10. If your cursor return a lot of rows, say 1000 or more, you can change the number of rows to prefetch. Use the setRowPrefetch() method at the Statement level or setDefaultRowPrefetch() at the Connection level.<HR></BLOCKQUOTE>
null -
Using CBO hints in Oracle reports 6i
Hi everyone,
I'm trying to add a simple hint to my a query defined in the datamodel of my report. The hint never shows up in v$sql at execution time.
I have a stong feeling that report chops the hint out because reports thinks it's a comment like any other comment.
Is there a way I can put hints in queries of Oracle Report 6i ????
Best regards,
Guillaume Goulet-VallièresOne alternative is having the hints in functions/packages in DB, if possible.
-
Problem in finding Exact result by using the following in Oracle Reports 6i
Hello,
I am finding difficulty in producing the required result by using the following query in Reports 6i
(Note: - The query actual output and the my required output are as follows: -)
SELECT
DISTINCT
SH.S_HEAD_CODE,
B.BILL_ID,
B.SANCTION_DATE,
E.EMP_NAME,
E.EMP_DESIGNATION,
B.TOTAL_BILL,
NVL((SH.INITIAL_ALLOCATION-B.TOTAL_BILL), 0) BALANCE
FROM BILL B, PARAMETERS P,SUB_HEAD SH, EMPLOYEES E, BILL_DETAIL BD
WHERE
SH.S_HEAD_CODE=B.S_HEAD_CODE
AND B.S_HEAD_CODE=BD.S_HEAD_CODE
AND B.EMP_ID_NO=E.EMP_ID_NO
AND B.BILL_ID=BD.BILL_ID
The Output of the above query is as follows: -
Let say we have Total Amount Sanctioned Rs. 15,000,00/-
Name Total Bill (Rs.) Balance (Rs.)
Sohail 7147 1492853
Saqib 2131 1497869
Amir 6802 1493198
Shafiq 1214 1498786
Note:- In the above output the above query is subtracting the current balance from Total Sanctioned Amount (Rs. 1500000) each time, but
it should actually subtract the current bill amount from the previous balance like the below said result.
Name Total Bill (Rs.) Balance (Rs.)
Sohail 7147 1492853 {Previous Balance - Current Bill Amount (1500000-7147) }........ The previous balance was actual amount Rs. 1500000
Saqib 2131 1490722 {Previous Balance - Current Bill Amount (1492853 - 2131)}
Amir 6802 1483920 {Previous Balance - Current Bill Amount (1490722 - 6802)}
Shafiq 1214 1482706 {Previous Balance - Current Bill Amount (1483920 - 1214)}
Results Continue...........................
Please help me to solve this problem.
Thank you in advanceIts more like the case of a running total ...
You could analytical functions to achieve it or make the BILL a subquery of the BALANCE.
Try posting your query in the "SQL and PL/SQL" forum, veteran members there, can provide better answers. -
A question about using regular expression
Hi,
This is a part of HTML file.
<SPAN>how</span>
<SPAN>are</span>
<SPAN>you</span>
I want to search string between each pair of <SPAN> , </SPAN> tags by using Regular Expression.
For example:
how
are
you
If I use following method
String regx="<SPAN>(.+)<SPAN>";
Matcher m=Pattern.compile(regx).matcher(str);
int currentLoc=0;
while(currentLoc<str.length()){
if(m.find(currentLoc))
System.out.println(m.group(1));
currentLoc=m.end();
}The content between first <SPAN> and last </SPAN> will be searched.
How to solve this problem?Use a non-greedy match:
(?s)<SPAN>(.+?)<SPAN>(?s) makes the dot match the line terminator (same as setting the dot all option) -
HELP:About the OCP exam with Oracle Reports??
Hello
Can i achieve OCP with SQL exam , PL / SQL exam and oracle 9i reports exam / xml publisher exam
I'm not intrested in giving an oracle forms exam.
I'm working as an oracle reports writer on oracle applications.
Kindly guide me in the right direction with appropriate oracle links etc.
Regards
Fahad Hameed.You can achieve "PL/SQL Developer Certified Associate" by passing "Introduction to Oracle9i SQL 1Z0-007" OR "Introduction to Oracle: SQL and PL/SQL 1Z0-001" OR "Oracle Database SQL Expert 1Z0-047".
For "Oracle Forms Developer Certified Professional", you need to pass "Oracle Forms: Build Internet Applications 1Z0-141" after getting the "PL/SQL Developer Certified Associate" certificate.
Oracle PL/SQL and Oracle Forms Developer
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=155
Oracle Certification Program - Oracle Middleware
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=140 -
Use css file in oracle 10g report builder
hi every one
i am using oracle 10g report buidler. i want control paramform by usign css file.
any body have idea how can i use css file in oracle report builder 10g and how can i modify it's path and i how can i manage any css class on a perticular field.Thanks Billy.
Yes you are right.
Here why I discarded that option is,
I may get the source files with changing layouts.
My Actual scenario is as follows.
Initially we developped all the things using PL/SQL packages. Its working fine.
But as per the inputs we received from requirements group, the file structure changes dynamically. and we would able to consider those new columns also. We should be able to changes the rules dynamically.
Lets say, we doing fullouter join on Src_A and Src_B. on columns col1_A and col1_B.
Now the requirement changes in a way that, the join should be done on Src_A and Src_C. on columns col1_A and col_C.
For this I need to define a new package.
Instead of that, I would like to do everything dynamically based on configuration parameters given as input.
Thank you,
Regards,
Gowtham Sen -
Programmatically change the query used to generate Oracle Reports
I have two queries. Depending on some parameter value, I would like to use one of these queries to generate my report. Is it possible to programmatically change the SQL query used to generate the Oracle Report.
ThanksThere are two options:
- The easy way
In the report paper layout create two frames, one for each query , and at runtime
display only one based on your parameters. (using format triggers on the frames)
- the not so easy way (but more elegant)
create the query at runtime using xml customizations using the examples from
the following documentation:
http://download-
uk.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_xml.htm#i1006734
16.3 Creating XML Data Models
16.4.1.3 Applying an XML Report Definition in PL/SQL
16.4.1.3.2 Applying an XML Definition Stored in Memory
Regards and Good Luck
Ionut S -
Pl/sql in oracle reports 6.0
Hi ,
I am new to oracle reports, is there any way to use pl/sql in oracle reports.I mean i have to take aggregate data from Oracle and to print/populate the data according to slabs(Say distance slab or time slab).Can u please provide me sample code...
mail id : [email protected]
thanks & regards
Anand Myou can use ref cursor in your pl/sql stored procedure and then call it in your reports
-
Insert multiple rows using Cursors.
I am trying to insert rows into a table based on information from another table.
For example:
When Table 1: Num_Rows = 100 my proc will insert 100 rows into Table 2 with relevent data.
Do I need to use a Cursor and iterate through Num_Rows doing an INSERT each time? Is there a better way to do it other than using Cursors?
Rob.It is not about using cursors or not using cursors. All SQLs wind up as cursors in the Oracle Shared Pool. So there is no such concept as not using cursors. Oracle needs to parse and compile and execute SQLs as cursors.
The issue is WHERE* you do the work?
Do you use the cursor (SQL) to do it for you? Or do you pull the data into another language, like PL or Java and process it there?
And the performance mantra in this case is a very fundemantal Maximize SQL and minimize PL/Java/etc+.
So do not do in PL/SQL what you can do in SQL only. It is a lot slower to pull data from the SQL engine into the PL engine. And then push that very same data from the PL engine back to the SQL engine. Like the following for example:
-- poor design, poor performance
for employee in (select e.* from emp e where e.deptid = 123 )
loop
insert into tab2 values( employee.empid, employee.name );
end loop;You do not need to use PL (or Java) in this case. The SQL language is more than able to do this better and faster than any other language... as it is closer to the data.
So the following is far more optimal code. Instead of the above PL/SQL code, we can simply do it as:
-- optimal design: maximizing SQL and letting it to as much of the work as possible
insert into tab2 select e.empid, e.name from emp e where e.deptid = 123; -
How to use 2 d barcodes in reports 6i
Hi,
We have a requirement to use 2 D barcodes in Oracle reports 6i. Can anyone please advise as to how to do this?
Thanks & Regards,
ShailajaHello,
2D Barcode or matrix barcode are not supported in Oracle Reports(6i, 10g and 11g).
An Enhancement request is logged in order to have the possibility to use 2D barcode with Oracle Reports.
Please see Bug 8401811 ENH: NEED ABILITY TO DISPLAY AND PRINT TWO-DIMENSIONAL (2D) BARCODES which is still under review.
I think IDautomation Java Component can create 2D Barcodes: http://www.idautomation.com/java/
Oracle using Java:
http://www.idautomation.com/oracle/java_barcode.html
Regards,
Alex
Edited by: AlexDiniasi on 16.07.2012 17:07
Maybe you are looking for
-
Hi I have an IPad mini WiFi (not cellular) and an IPhone 5. I use the bluetooth connection between both devices when on the road. I downloaded a navigation system on my IPad using GPS positioning. Is the Bluetooth connection working to use GPS positi
-
How to Transfer Objects from one Package to another?
Hi, I have Objects(Form Layouts,ABAP Programs....ect) in Package. Is there a particular Transaction that could be used to move these objects to another Package. Thanks Kishan
-
Change Column Value based on Characteristic in Rows
I am not sure it is possible. We have product prices at different levels of customer hierarchy. Channel > Division > Region > Market One Region can have multiple Markets. Each market can have different Rates. But the Region will have a different Ra
-
Starting Over With Time Machine
My old backup disk died so I replaced it with a new 2 TB disk. Changed TM preferences to use the new drive. Backup starts, takes about 2 seconds and quits. Looks like Time Machine thinks I have a full backup but I don't. I tried reformatting the new
-
i purchased the "hancock" movie recently, it does not work in my iphone and so with my pc laptop, it stops all the time. also, do we have a video to use at the old iphone? i feel like i need to know more about this. manual doesn't explain that much i