--HERE IS HOW IT CANBE CALLED
Main Topics
Browse All TopicsHello Guys!!
I have a form in which you can select regions/divisions/location
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
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Vishal. In answer to your first part of the question
>>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.
This query returns no values because that's how you've written the query to behave (with the last EXISTS condition). What is not "correct" about it? If you can provide more information about what is correct/incorrect in terms of the results you ned then we can help you fix your query.
>>Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off
Just to give a Oracle Reports perspective ....
You can use ref cursors (cursor variables) in your report data model. In Oracle reports it's called a "ref cursor query". This allows you to put the SQL used for your report in a stored procedure.
The main benefit is that the SQL in compiled in the database (not in the report), which means it's a lot easier to maintain. Another advantage is that it reduces code duplication when you have the same query used in multiple reports - no need to code and maintain n copies of that query. And since a ref cursor is a standard oracle feature, you can use the same ref cursor as a data-source for other applications/tools.
I did a simple example (see the attached screenshot) ....
From the data model editor in Oracle reports, choose the "Ref Cursor Query" icon from the tool pallet. A new program unit window will popup, where you need to specify the return type of the ref cursor (strongly typed ref cursor). In my example report, I created a package (TEST) which contained the following TYPE:
CREATE OR REPLACE PACKAGE test AS
TYPE tRefCursor IS REF CURSOR RETURN user_objects%ROWTYPE;
END;
I put my query in the program unit QR_1RefCurDS. However you would want to encapsulate the SELECT statement in a package function. This can then be returned as a ref cursor to the report. i.e. your report simply calls the function: e.g.
FUNCTION QR_1RefCurDS RETURN test.tRefCursor IS
BEGIN
return test.getRefCursor(:object_
END;
The following link is worth reading as it contains a step-by-step guide to building a report using ref cursor queries.
Oracle9i Reports Building Reports - Building a Paper Report with Ref Cursors
http://download.oracle.com
Beacuase of the benefits mentioned above, I'd definitely recommend using ref cursors in Oracle reports. Please let me know if you need any more help.
Business Accounts
Answer for Membership
by: ajexpertPosted on 2009-07-31 at 14:06:55ID: 24992459
Ref Cursor is nothing but a dynamic query returning a result set.
For e.g.
Static Cursor is
select * from emp where dept_no= v_dept_no.
In certain situations you dont know the table name and column name but you want to get result seT
Here is example of ref_cursor:
Select allOpen in new window