Custom Report Layout in APEX 3.0 PDF

How much freedom do we have when developing a custom report layout using BI Publisher when we create the template file using the Word XML add-on?
Why I am asking is, I am trying to replicate several Crystal based reports that use multiple lines of for data. They group on several columns and display the grouped data on separate lines in the report.
Grouping 1 Line one has customer detail information
Next grouping 1 or more lines are provider of service line information
Last Line count of detail lines for customer
Or would I be better off porting these reports to Oracle Reports?
Thank you!
Tony Miller
UTMB/EHN

Marc, I was able to create reports based on a layout and a report query...Is it possible to let the end user (not apex developers) download the report layout, make modifications and load it again. They will only be changing the text and very rarely will modify the fields..
Thanks
Ashlee
update: i found the following logic in the f4000 app on page 1405 for download
declare
l_report_document blob;
l_file_ext varchar2(255);
l_mime_type varchar2(255);
begin
for c1 in (
select *
from wwv_flow_report_layouts
where id = :P1405_ID
) loop
if c1.report_layout_type = 'RTF_FILE' then
l_mime_type := 'application/rtf';
l_file_ext := 'rtf';
else
l_mime_type := 'application/xml';
l_file_ext := 'xml';
end if;
l_report_document := wwv_flow_utilities.clob_to_blob(c1.page_template,wwv_flow_lang.get_db_charset);
sys.owa_util.mime_header (l_mime_type ,false);
sys.htp.p('Content-Disposition: attachment; filename='||lower(replace(c1.report_layout_name,' ','_'))||'.'||l_file_ext);
wpg_docload.download_file( l_report_document );
end loop;
end;
and 1406 for upload
declare
l_report_layout clob;
l_report_layout_id number;
begin
for c1 in (
select blob_content from wwv_flow_files
where name = :P1406_LAYOUT_FILE
) loop
l_report_layout_id := wwv_flow_id.next_val;
l_report_layout := wwv_flow_utilities.blob_to_clob(c1.blob_content);
insert into wwv_flow_report_layouts (
id,
flow_id,
report_layout_name,
report_layout_type,
page_template
) values (
l_report_layout_id,
:FB_FLOW_ID,
:P1406_REPORT_LAYOUT_NAME,
'RTF_FILE',
l_report_layout
end loop;
end;
are these the tables/apis i could use ?

Similar Messages

  • Custom Report Layout with mutliple child tables

    I am trying to create a custom report layout (using Bi Publisher) where I have parent data (multiple jobs on a page) and several child tables for each job (JobDays and JobStops) and several child tables for JobDays (JobDayProviders, JobDayCrew). On the apex screen, I have a join on Jobs and JobDays and I am using functions to string each child row value for JobDayProviders and JobDayCrew together and putting a <br> in between so that they will format on separate lines within a cell. It works fine on the screen but when trying to print to pdf, it ignores these line breaks. I have also tried using <br></br> (saw an article that said just use HTML in bi pulisher) which puts two lines in between each value on the screen and is still ignored on the pdf.
    for example:
    Table hierarchy:
    Jobs table
    Job Stops
    Job Days
    Job Day Service Providers
    Job Day Crew
    Report Layout per job (will have mutlipe jobs to print, just printing 1 day per job):
    Jobs.col1 JobStops.row1 JobDay.col1 JobDayProviders.row1 JobDayCrew.r1
    JobStops.row2 JobDayProviders.row2 JobDayCrew.r2
    JobDayProviders.row3
    Thanks,
    Linda
    First, is there a way to get bi publisher to recognize the line breaks? If not, what is the best way to create a custom report for this scenario? I tried to create a report query with mutliple queries, but cannot determine how to link the child queries to the paren query. I have seen an example where a button is pressed to print one parent row and the id of that row is saved and referenced as a parameter in each of the queries, but if printing mutliple parents on a report, how would I link the child queries to the parent query?

    Helen,
    The best way for your case is to use a content folder and customize it whichever way you like.
    however, your question is about reports. the problem in reports is this that you have to use just one single query and the layout of the results of this query are displayed in a peculiar way.
    anyway. something similar but not exactly the same as what you wanted do is the following.
    use a query like the following: (with a union in between)
    SELECT COLUMN1,NULL , NULL ,NULL ,NULL
    FROM my_source_table
    WHERE myCriteria LIKE 'SoAndSo%'
    UNION
    SELECT NULL,COLUMN2 , COLUMN3, COLUMN4, COLUMN5
    FROM my_source_table
    WHERE myCriteria LIKE 'SoAndSo%'
    ---------- Now, have the following codes in the layout segments:
    <!--- header --->
    <table border="0" cellpadding="1" cellspacing="1" width="20%" align="center">
    <!--- body --->
    <tr align="center">
    <td><table border="0" cellpadding="1" cellspacing="0" width="30%" align="center">
    <tr align="center">
    <TH><#COLUMN1.FIELD#></TH>
    </tr>
    </table>
    </td>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN2.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN3.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN4.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN5.FIELD#></TD>
    </tr>
    <!--- footer --->
    <TR><TD></TD></TR>
    this should produce a report with a table structure (you may see the whole if you give BORDER="1" in the main table tag). Within this table, the first column of the first row should be showing top-leftmost column value once (COLUMN1 value) and then the next rows would show last four column values as a table block on the right-bottom part.
    with kind regards,
    naqvi

  • Problem with creating customized report layout

    Hello,
    I want to create customized report layout. However, it doesn't work. Can somebody help me?
    I have a page 24 in apex.oracle.com(workspace: houbcm, username: apex, password: apex1). Here is the code in my .xslt.
    <?xml version="1.0"?>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
    <fo:simple-page-master master-name="content"
    page-width="210mm" page-height="297mm">
    <fo:region-body/>
    </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="content">
    <fo:flow flow-name="xsl-region-body">
    <fo:table table-layout="fixed" width="100%">
    <fo:table-body>
    <fo:table-row >
    <fo:table-cell> <fo:block text-align='right' > <fo:inline> Product Name: </fo:inline> </fo:block> </fo:table-cell>
    <fo:table-cell> <fo:block text-align='left' > <fo:inline> <xsl:value-of select='.//PRODUCT_NAME' /> </fo:inline> </fo:block> </fo:table-cell>
    </fo:table-row>
    <fo:table-row >
    <fo:table-cell> <fo:block text-align='right' > <fo:inline> Description: </fo:inline> </fo:block> </fo:table-cell>
    <fo:table-cell> <fo:block text-align='left' > <fo:inline> <xsl:value-of select='.//PRODUCT_DESCRIPTION' /> </fo:inline> </fo:block> </fo:table-cell>
    </fo:table-row>
    <fo:table-row >
    <fo:table-cell> <fo:block text-align='right' > <fo:inline> Category: </fo:inline> </fo:block> </fo:table-cell>
    <fo:table-cell> <fo:block text-align='left' > <fo:inline> <xsl:value-of select='.//CATEGORY' /> </fo:inline> </fo:block> </fo:table-cell>
    </fo:table-row>
    <fo:table-row >
    <fo:table-cell> <fo:block text-align='right' > <fo:inline> Availability: </fo:inline> </fo:block> </fo:table-cell>
    <fo:table-cell> <fo:block text-align='left' > <fo:inline> <xsl:value-of select='.//PRODUCT_AVAIL' /> </fo:inline> </fo:block> </fo:table-cell>
    </fo:table-row>
    <fo:table-row>
    <fo:table-cell> <fo:block text-align='right' > <fo:inline> List Price: </fo:inline> </fo:block> </fo:table-cell>
    <fo:table-cell> <fo:block text-align='left' > <fo:inline> <xsl:value-of select='.//LIST_PRICE' /> </fo:inline> </fo:block> </fo:table-cell>
    </fo:table-row>
    </fo:table-body>
    </fo:table>
    </fo:flow>
    </fo:page-sequence>
    </fo:root>
    Thanks,
    Jen

    Hi,
    Thanks for the reply. I have created following report definition.
    SELECT Call_Type.EnterpriseName, Call_Type.Description AS DNIS, Call_Type_Interval.CallTypeID,
    SUM(Call_Type_Interval.ServiceLevelCallsOffered) AS CallsOffered,
    SUM(Call_Type_Interval.CallsAnswered) AS CallsAnswered,
    SUM(Call_Type_Interval.TotalCallsAband) AS TotalCallsAband,
    SUM(Call_Type_Interval.ServiceLevelAband) AS ServiceLevelAband,
    SUM(Call_Type_Interval.ShortCalls) AS ShortCalls,
    SUM(Call_Type_Interval.CallDelayAbandTime) AS CallDelayAbandTime,
    SUM(Call_Type_Interval.AnswerWaitTime) AS AnswerWaitTime,
    SUM(Call_Type_Interval.AnsInterval1) AS AnsInterval1,
    SUM(Call_Type_Interval.AnsInterval2) AS AnsInterval2,
    SUM(Call_Type_Interval.AnsInterval3) AS AnsInterval3,
    SUM(Call_Type_Interval.AnsInterval4) AS AnsInterval4,
    SUM(Call_Type_Interval.AnsInterval5) AS AnsInterval5,
    SUM(Call_Type_Interval.AnsInterval6) AS AnsInterval6,
    SUM(Call_Type_Interval.AnsInterval7) AS AnsInterval7,
    SUM(Call_Type_Interval.AnsInterval8) AS AnsInterval8,
    SUM(Call_Type_Interval.AnsInterval9) AS AnsInterval9,
    SUM(Call_Type_Interval.AnsInterval10) AS AnsInterval10
    FROM        
    Call_Type (nolock),
    Call_Type_Interval (nolock)
    WHERE Call_Type.CallTypeID = Call_Type_Interval.CallTypeID
    AND Call_Type.CallTypeID in (:calltype_list)
    AND Call_Type_Interval.DateTime >= :start_date
    AND Call_Type_Interval.DateTime <= :end_date
    GROUP BY Call_Type.EnterpriseName,
    Call_Type.Description,
    Call_Type_Interval.CallTypeID
    For this definition i wanted to create a customized report which is apparently not possible.

  • Reports Layout- storing custom report layouts that aren't FOP/RTF

    I am actually setting up a similar environment to the supported FOP processor, but with a JasperReports custom j2ee web application (WAR).
    I am having some degree of success. Instead of relying on passing user/pass for a JDBC connection, I have reports mapped by XML elements. The reports just pick up off of the document already being sent with the xPath record root at /DOCUMENT/REGION/ROWSET/ROW.
    I have planned on saving the jrxml reports as Report Layouts into APEX, so that the templates are also saved directly with the application and sent with the request, making the server side more of a dumb processor.
    I have had some success in this setup except for what looks like one issue.
    It appears that the jrxml remains intact on the upload, verified by viewing the CLOB contents of WWV_FLOW_REPORT_LAYOUTS.PAGE_TEMPLATE.
    I was going to say that it appeared that the "+" characters were being stripped, but after starting up my packet sniffer, it appears that is is actually because the fields (xml, template, etc) are not url_encoded prior to transmission. They are getting to the OC4J server, but not read correctly by the default HttpServletRequest.
    I realize that should this remain consistant, I can call the .Reader of the request object and actually pick up the POST parameters manually.
    Question:
    Is there anyway that this could be corrected in a future release, patch, or is there a way I can modify this behavior?
    Am I the only one who has seen this or does anyone suspect I have done something wrong in my setup?
    -Richard
    Configuration
    OS: Windows Vista 32bit
    Database: 10gR2 XE
    APEX: 3.2.0.00.27
    OC4J: JDev 10.1.3.4 (running in debug)
    Edited by: rwendel on Aug 5, 2009 1:48 AM - Added Configuration
    Edited by: rwendel on Aug 5, 2009 12:15 PM - Shameless mid-day bump

    I guess I have further confirmed this, by manually setting the particular character, "+" to its URL encoded equivalent "%2B" in the table WWW_FLOW_REPORT_LAYOUTS. After this, on receipt of the object at the Java receiver, it is formatted correctly. Furthermore, the getReader or getInputStream of the HttpServletRequest doesn't help because at this point it is empty.
    I figure if all else fails, I can put a dreaded trigger on to the WWV_FLOW_REPORT_LAYOUTS, or an after the fact process to URL encode the contents. Heck, I am already unsupported as far as the printing goes, amirite
    -Richard

  • Custom report layout question...can't find any answers anywhere

    I am trying to build a report in Portal, using the custom report layout. The report displays like so, before I do any customization:
    COLUMN1 COLUMN2 COLUMN3
    COLUMN1 COLUMN2 COLUMN3
    COLUMN1 COLUMN2 COLUMN3
    COLUMN1 COLUMN2 COLUMN3
    where COLUMN1 is the same value, always per report; COLUMN2 and COLUMN3 vary.
    What I want is:
    COLUMN1
    COLUMN2 COLUMN3
    COLUMN2 COLUMN3
    COLUMN2 COLUMN3
    COLUMN2 COLUMN3
    In the report layout editor, Body section, this is what I see:
    <TD ALIGN="LEFT"><#COLUMN1.FIELD#></TD>
    <TD ALIGN="LEFT"><#COLUMN2.FIELD#></TD>
    <TD ALIGN="LEFT"><#COLUMN3.FIELD#></TD>
    so #COLUMN1.FIELD# must be some kind of array, but I am not finding any documentation anywhere on how to reference the individual values. All I need is the very first value of the COLUMN1 variable. Once I have that value, I can put it where I need it, but I can't get at that value, just the array.
    I have searched portal center, the app server documentation, html documentation. I have googled everything I could think of, but came up with nothing. I found a similar question on this forum, but no one responded with an answer. Any help would be greatly appreciated.

    Helen,
    The best way for your case is to use a content folder and customize it whichever way you like.
    however, your question is about reports. the problem in reports is this that you have to use just one single query and the layout of the results of this query are displayed in a peculiar way.
    anyway. something similar but not exactly the same as what you wanted do is the following.
    use a query like the following: (with a union in between)
    SELECT COLUMN1,NULL , NULL ,NULL ,NULL
    FROM my_source_table
    WHERE myCriteria LIKE 'SoAndSo%'
    UNION
    SELECT NULL,COLUMN2 , COLUMN3, COLUMN4, COLUMN5
    FROM my_source_table
    WHERE myCriteria LIKE 'SoAndSo%'
    ---------- Now, have the following codes in the layout segments:
    <!--- header --->
    <table border="0" cellpadding="1" cellspacing="1" width="20%" align="center">
    <!--- body --->
    <tr align="center">
    <td><table border="0" cellpadding="1" cellspacing="0" width="30%" align="center">
    <tr align="center">
    <TH><#COLUMN1.FIELD#></TH>
    </tr>
    </table>
    </td>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN2.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN3.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN4.FIELD#></TD>
    <TD class="report_cell" ALIGN="LEFT"><#COLUMN5.FIELD#></TD>
    </tr>
    <!--- footer --->
    <TR><TD></TD></TR>
    this should produce a report with a table structure (you may see the whole if you give BORDER="1" in the main table tag). Within this table, the first column of the first row should be showing top-leftmost column value once (COLUMN1 value) and then the next rows would show last four column values as a table block on the right-bottom part.
    with kind regards,
    naqvi

  • Custom report layout, works in BI Publ. Desktop preview, not in apex

    Hi
    I've usually haven't had any problems using custom RTF-files made with BI Publ. Desktop, but here goes: I've had a problem with this one template in different apex-installs and different versions; never got it working.
    The funny thing is; when I create a Report Query through apex, XML is generated for download. I then load this XML as sample data in BI Publ. desktop (MS-Word), and make my report. I then preview the file as PDF - and this works like a charm.
    The query is also very simple.
    However, when I try to access the report through Apex: I just get an empty .pdf-file.
    Any tips/suggestions?
    Best regards,
    Vidar
    Message was edited by:
    Vidar
    Solution found: template contained a %-character, replaced it with %25 (which is rendered as a % by BI Publisher). This is a reported bug.

    Thanks Dimitri,
    just incase someone else didn't see my edit of original post:
    "Solution found: template contained a %-character, replaced it with %25 (which is rendered as a % by BI Publisher). This is a reported bug."
    So the data was OK, but the template wasn't.
    Cheers,
    Vidar

  • Custom Report layout Using FOP

    I am using FOP as report server to print my apex regions as PDF. How can i print a report with custom layout. Plz provide me a starting point.

    I want to make a report withe the parent and child hirerechy. e.g
    parent data line 1
    parent data lie 2
    parent data line 3
    child No.1 data
    childe no. 2 data
    Child No. 3 data
    In case I print this report using the standard layout. It prints in one table withe the parent repeating for each child. I want to also inculde some things in the header and footer like company logo and signature.
    thanks,

  • Report print attributes - custom report layout

    Hi there,
    I've looked for this information in the web and in this forum without luck so far...
    We have here BI Publisher and I use the "Enable Report Printing" option in a traditional report in Apex 4.0.2. That works great.
    But instead of using the "Default Report Layout", I want to use a custom one based on a RTF file. However I have no idea what the data XML looks like in order to build a custom layout.
    To be clear: if you go to Shared Components > Report Queries, you have a Download XML Data option so you can build your report layout based on the XML structure. For instance, you can use <?for-each:ROWSET1_ROW?>, <?COLUMN_NAME?> etc
    Any ideas about what that XML structure is for a traditional report?
    Thanks
    Luis

    Found it: change temporarily the output format to XML and download the report. The XML structure is all there. Very helpful to know that all page items are included in the XML as well. It would be good to have this functionality detailed somewhere in the Apex documentation.
    What I still need to know is how to access the substitution strings below in my RTF (NOT XSL-FO) template:
    Select Default Report Layout to use the built-in generic report layout.
    To use a custom generic report layout, select it from the list.
    You can use the following substitution strings when building custom XSL-FO report layouts:
    #PAGE_HEADER#
    #PAGE_HEADERFONT_COLOR#
    #PAGE_HEADER_FONT_FAMILY#
    ...Any ideas?

  • Report Layouts in APEX 3.0

    Hello,
    i am interested in the report layouts in the new apex 3.0 version.
    Does anybody have experiences with that?
    Is it true, that I can edit the xml file only with a licensed version of XML publisher and not the desktop version?
    By the way is ther a users guide for apex 3.0 in which the report layout section is described?
    Thank you,
    Tim

    Hello Tim,
    First, you can experience APEX 3 your self, registering to the evaluation instance.
    There isn't yet a proper documentation to the new version, and even some of the internal help screens are not available yet. Still, there are several threads in this forum about the new PDF native support, that can help you understand the principles. Search the forum using the keyword "PDF" and user name "Marc Sewtz". These threads will answer the rest of your questions.
    Regards,
    Arie.

  • Custom substitution strings in custom report layout (XSL-FO)

    I copied the default generic column report layout (XSL-FO) and made my own template. Everything worked except that I would need to pass some of my custom substition strings to the XSL-FO template. For example, I had a subsitution string named PDF_HEADER_TITLE. I could not simply hard-code it as &PDF_HEADER_TITLE. because it would fail to generate the pdf file. Does anyone know how I can solve this problem?
    Thanks.
    Andy

    Hey Smitha Mohan,
    In fact SAP BW MDX supports limited string manipulation and only with NAME and UNIQUENAME attributes.
    Here are some samples that you can use in universes:
    MID([0COSTELMNT].currentmember.NAME,1,4)
    LEFT([0COSTELMNT].currentmember.NAME,2)
    RIGHT([0COSTELMNT].currentmember.NAME,3)
    MID([0COSTELMNT].currentmember.UNIQUENAME ,1,4)
    LEFT([0COSTELMNT].currentmember.UNIQUENAME ,2)
    RIGHT([0COSTELMNT].currentmember.UNIQUENAME ,3)
    Use them along with Concate()
    Hope it should solves the req.
    Gracias...!!
    Let's play with Aurora (BO XI 4.0)
    Edited by: BOCP-BOE on Oct 28, 2010 3:10 PM

  • How to set it up to use BI Publisher Report layout in APEX

    Hi all,
    I downloaded the xml file from APEX to create a BI Publisher report layout and uploaded it to APEX report layout in share component. When I click the test report button, nothing showed. Would you show me what else I need to do to make it work?
    Any suggestions are appreciated.
    Thanks much@

    You need to use the desktop layout editor that works under Word to develop report layouts..
    Thank you,
    Tony Miller
    Webster, TX
    On the road of life...There are 'windshields', and there are 'bugs'
    (splat!)
    "Squeegees Wanted"
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Custom Report LayOut in BI Publisher

    I have uploaded an xml file to the word plugin in order to make a report layout.
    I have inserted all the fields in one line. When I preview the report it shows only one line and not all data. What may be cause of the problem?

    Hi -
    1) Add Query just for column headings under Source Query (you can obviously pass in bind variables to select the correct column values if need be).
    2) For layout, pull in the headers from data model (just like any other field) and use them to replace any existing "hard coded" headers.
    Good luck.

  • Custom Report layout

    I have a simple question to ask (simple I hope a tleast). In the past, I have been able to use the out of the box layout for most reports. However at my current job, we will be needing some custom layouts done to the report region to show parent child style reports.
    I know that the region is just HTML with some CSS thrown in along with placeholder columns, but am confused as to if I can get the formatting to look like this:
    Name ID # DOB Race Office Location (Parent row of data)
    Appt Loc Appt Date/Time Appt Descript Appt Meet With (Child Row)
    Where there will be a number of child rows per employee. I could do this manually (HTP.p processing), but would prefer to have the pagination and other features the product provides.
    Can any suggest a solution here?
    Thank you,
    Tony Miller
    UTMB/EHN

    Guess I will look at customizing the HTML layout, or doing it via htp.p output. My main goal is getting reports for the users, and it works well with the PDF out option with BI Publisher..
    Thank you,
    Tony Miller
    UTMB/EHN

  • Customizing Reports Layout

    Hi All,
    I need to find a way to customize the layout of our reports. But not modifying the default layout for all the users. Just for specific reports for an specific client (kind of Report Template)
    is it possible to do that? Can anyone help me of give me a clue to do this?.
    Thank you all, I'm investigating and all I found was different ways to modify layouts but for the entire OBIEE application.
    Regards,
    Belen

    Hi,
    Use section level security.(Section properties->permissions)
    Consider Group A and B. A wants reports with different layout and B wants reports with default view.Lets consider a report R.Place report R with different layout in Section 1 and report R with default view in Section 2. Now apply security to sections. For Section 1 give access for Group A and no access for Group B.Now for Section 2 give access to Group B and no access to Group A.
    Hope this solves your issue.
    Regards,
    Srikanth
    http://bintelligencegroup.wordpress.com/

  • Creating a query for a custom report layout

    hello guys,
    i am really stuck with this task - i need to populate a report with rows with "0" values based on a particular criteria, here is the example: lets say we have a table BROKERS with company names, their transaction types and cumulative amounts for a current month and all months ever.
    COMPANY TRAN_TYPE CURR_MNTH ALL_MNTH
    Broker1 CURRENCY_SELL $1000.00 $1500000.00
    Broker1 GOLD_SELL $50000.00 $2500000.00
    Broker1 GOLD_BUY $80000.00 $8500000.00
    Broker1 STOCKS_SELL $35000.00 $3500000.00
    table BROKERS does not have a field TRAN_TYPE, but has a field TRAN_TYPE_CD which reffers to another table called TRAN_TYPE_CD_EXPL, where all the codes are explained:
    TRAN_TYPE_CD TRAN_TYPE_CD_EXPLD
    1 STOCKS_SELL
    2 STOCKS_BUY
    3 GOLD_SELL
    4 GOLD_BUY
    5 SILVER_SELL
    6 SILVER_BUY
    7 COPPER_SELL
    8 COPPER_BUY
    9 CURRENCY_SELL
    10 CURRENCY_BUY
    so the results shown above is just a simple join of those two tables:
    select b.COMPANY, tt.TRAN_TYPE, b.CURR_MONTH, b.ALL_MNTH
    from BROKERS b, TRAN_TYPE_CD_EXPL tt
    where b.TRAN_TYPE_CD = tt.TRAN_TYPE_CD;
    everything is pretty simple, but here is where the problem starts : the report i am working on should look like this:
    COMPANY MARKET TRAN_TYPE CURR_MNTH ALL_MNTH
    Broker1 FOREX CURRENCY_SELL $1000.00 $1500000.00
    Broker1 FOREX CURRENCY_BUY $0.00 $5500000.00
    Broker1 CONTRACTS GOLD_SELL $50000.00 $2500000.00
    Broker1 CONTRACTS GOLD_BUY $80000.00 $8500000.00
    Broker1 STOCKMARKET STOCKS_SELL $35000.00 $3500000.00
    Broker1 STOCKMARKET STOCKS_BUY $0.00 $9500000.00
    so let me explain :
    firstable, report should contains a column MARKET, which should be populated based on the values in the column TRAN_TYPE, but the thing is there is no table MARKET in database, so each time when you need to populate it in a report or somewhere else, you need to use decode like this (assumed everybody knows where all kind of tran_types belong to):
    SELECT DECODE (TRAN_TYPE_CD_EXPL.TRAN_TYPE_CD_EXPLD,
    'CURRENCY_SELL', 'FOREX',
    'CURRENCY_BUY', 'FOREX',
    'STOCKS_SELL', 'STOCKMARKET',
    'STOCKS_BUY', 'STOCKMARKET') AS MARKET,
    or based on TRAN_TYPE_CD value:
    SELECT DECODE (BROKERS.TRAN_TYPE_CD,
    9, 'FOREX',
    10, 'FOREX',
    1, 'STOCKMARKET',
    2, 'STOCKMARKET') AS MARKET,
    2) problem number 2 is more complicated : the report logic says - is a company has at least one transaction in a particular group (lets say CURRENCY_SELL for market type 'FOREX'), the report should be populated with other tran_types from the market type group with $0 even thou this company did not have any of those transactions during current month. so in this case it should be populated with the rows
    Broker1 FOREX CURRENCY_BUY $0.00 $5500000.00
    and
    Broker1 STOCKMARKET STOCKS_BUY $0.00 $9500000.00
    The thing is that it will be executed thru plsql batch on unix, so it must be a single query.
    Any ideas and/or suggestions are very appreciated!
    Thanks
    P.S.
    Its oracle 11gr2, with read-only role.

    Hi,
    This sounds like a jo for a partitioned outer join.
    Here's one way:
    WITH     broker_summary     AS
         SELECT     b.company
         ,      tt.tran_type
         ,      b.curr_mnth
         ,      b.all_mnth
         FROM     broker               b
         JOIN      tran_type_cd_expl     tt  ON     WHERE     b.tran_type_cd     = tt.tran_type_cd
    ,     market          AS
         SELECT     'CURRENCY_SELL' AS tran_type,       'FOREX' AS market     from DUAL  UNION ALL
         SELECT     'CURRENCY_BUY',               'FOREX'           from DUAL  UNION ALL
         SELECT     'STOCKS_SELL',               'STOCKMARKET'          from DUAL  UNION ALL
    ,     got_market_cnt     AS
         SELECT     bs.company
         ,     m.market
         ,     m.tran_type
         ,     b.curr_mnth
         ,     b.all_mnth
         ,     COUNT (*) OVER ( PARTITION BY       bs.company
                         ,          m.market
                          )     AS market_cnt
         FROM           market          m
         LEFT OUTER JOIN     broker_summary     bs   PARTITION BY (bs.company)
                             ON   bs.tran_type     = m.tran_type
    SELECT       company
    ,       market
    ,       tran_type
    ,       NVL (curr_mnth, 0)     AS curr_mnth
    ,       NVL (all_mnth,  0)     AS all_mnth
    FROM       got_market_cnt
    WHERE       market_cnt     > 0
    ORDER BY  company
    ,       market
    ,       tran_type
    ;If you'd care to post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data, then I could test it.
    You should create a market table. Do it once, then you won't have to do it over and over again in every query that needs it.

Maybe you are looking for