More elegant solution to reporting query?

I was recently asked to produce a one-time report that would identify any products that were or are currently being sold/stocked out of two different locations (821,822) at once, and where the product is currently is in stock at both. The table layout is basically like this:
Sales_Staging
Location_ID
Product_ID
Sales_Current
Sales_1ago
Sales_2ago
Sales_72ago
On_Hand_Current
On_Hand_1ago
On_Hand_62ago
(sales/OH stored horizontally on table, shifted once a week)
I wanted to produce a report of the products selling out of the two location IDs (821,822)--a list ordered by product, showing the historical sales/inventory at each location side-by-side. For example:
Location  Product  Sales_Current  Sales_1ago  ... On_Hand_Current ...
821        ABC       0                    1                   3
822        ABC       0                    1                   4
821        DEF
822        DEFTo get results turned around quickly, I used this ugly SQL below. The Sales_Staging table has millions of records, and the query plodded. I feel like I'm asking Oracle to process the same data for each location twice.
I'm working in 10gR2. For my own education and future reference, I figured I'd see if the experts had a more elegant solution? Thanks in advance.
SELECT location_id, product_id, sales..., on_hand...
  FROM Sales_Staging
WHERE location_id = 821
  AND on_hand_current > 0
  AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0
  AND product_id in
    (SELECT product_id
        FROM Sales_Staging
      WHERE location_id = 822
         AND on_hand_current > 0
         AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0)
UNION
SELECT location_id, product_id, sales..., on_hand...
  FROM Sales_Staging
WHERE location_id = 822
  AND on_hand_current > 0
  AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0
  AND product_id in
      (SELECT product_id
      FROM Sales_Staging
      WHERE location_id = 821
         AND on_hand_current > 0
         AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0)
ORDER BY product_id, location_id

The below query is obviously untested, but at least it shows a different approach to this problem
with subset_of_sales_staging as
( select *
    from sales_staging
   where location_id in (821,822)
     and on_hand_current > 0
     and ( sales_current + ... ) > 0
select distinct s1.*
  from subset_of_sales_staging s1
     , subset_of_sales_staging s2
where s1.product_id = s2.product_id
   and (  s1.location_id = 821 and s2.location_id = 822
       or s1.location_id = 822 and s2.locatino_id = 821
order by product_id
     , location_idChances are good that this query will operate on smaller subsets than your original query. But this depends of course on the data volumes and distributions, which I don't know.
Regards,
Rob.

Similar Messages

  • More elegant solution for error "Current version of data in database..."

    When two users try to manipulate the same record in a form, one of them gets the "Current version of data in database has changed since user initiated update process." when updating.
    I'd like a more elegant solution (or prevention) of this situation by disabling the update button on the form of the second user who opens the record and display a message on the page that the record is currently opened by another user, so it is only available in "read-only mode" by the other user.
    How can I do something like this? Or what are the multi user policies that other apex developers on the forum use and how are they implemented?

    I don't think I would disable anything, as you need to consider the situation where someone opens a record, then goes to lunch.
    You might update 2 columns such as "last_opened_on" and "last_opened_by" for the row. Then when the 2nd person opens it you could display a prominent indicator (red+bold) if it was opened by someone else in the last 10 min, as well as showing who opened it last. If it hasn't been opened in over 8 hours, you could basically de-emphasize that indicator by making it light gray or something. The goal is not to lock or disable anything, but warn a user when they open a record that was recently opened. If logistically possible, this gives them the opportunity to call / IM each other to coordinate.
    Tyler Muth
    http://tylermuth.wordpress.com
    [Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book]

  • Comment to "How do I get a memo onto my iPhone?" -- more elegant solution

    Since I can't post a reply or comment to my archived post, I thought this might be an alternative.
    Even though Tamara had a solution, software now available for the Mac and iPhone gives a more general solution.
    iPhone Explorer lets you use an iPhone or iPod touch as a USB or pen drive. You can create, delete, and rename files and folders, and use drag-and-drop. OS X 10.5 or later. From www.iphone-explorer.com (myPodApps) It's free.
    Good Reader is one solution to read those files and many others (like e-books and PDFs) on your iPhone. It's in the app store. Normally $4.99, was on sale (may still be) for $0.99.
    I've started to use both. I have no financial interest in either product.
    Hope this helps someone else.
    harv47

    Well that's Cool.
    Here's what usually pixxes me off.
    Apple promotes a app, and they never tested it.
    Some tried almost made it out the window at 90.
    So, I think this is commendable that an app that's needed and tested at the same time deserves an automatic star magnet for the fridge.
    Unless you can't fine the door handle anymore.
    Cheers

  • More elegant timing solution

    Hi all.
    Im am looking for some advice regarding a GUI that I am developing using netbeans.
    When a particular button is clicked on the interface I have a series of jPanels which I wish to make visisble with a delay in between each one.
    I currently have a solution posted here using a Timer and a switch statement within the timer class but it all seems a little cumbersome and basic. I just wondered if anyone had any ideas for a more elegant solution.
    Thanks
    int listCount =1;
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            timer = new Timer(2500, new ListAction());
            timer.start();
    class ListAction implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                switch (listCount) {
                case 1: jLabel32.setVisible(true);  
                        jLabel33.setVisible(true);
                        jLabel34.setVisible(true);
                        jLabel35.setVisible(true);
                        jLabel36.setVisible(true);
                        jLabel37.setVisible(true);
                        jLabel38.setVisible(true);                 
                        listCount++;                  
                        break;
                case 2:
                        jLabel32.setBackground(new Color(241,114,114));               
                        listCount++;
                        break;
                case 3:
                        jLabel32.setBackground(new Color(240,240,240));
                        jLabel33.setBackground(new Color(241,114,114));                                      
                        listCount++;
                        break;
                case 4:
                        jLabel33.setBackground(new Color(240,240,240));
                        jLabel34.setBackground(new Color(241,114,114));  
                        jLabel35.setBackground(new Color(241,114,114));  
                        jLabel28.setVisible(true);
                        jLabel29.setVisible(true);
                        jLabel41.setVisible(true);
                        jLabel30.setVisible(true);
                        jLabel30.setText("NULL");                   
                        listCount++;
                        break;
                case 5: 
                        jLabel34.setBackground(new Color(240,240,240));
                        jLabel35.setBackground(new Color(240,240,240));
                        jLabel36.setBackground(new Color(241,114,114));                                       
                        listCount++;
                        break;
                case 6: 
                        jLabel30.setText("12");
                        jLabel31.setVisible(true);
                        listCount++;
                        break;
                case 7: 
                        jLabel42.setVisible(true);
                        jLabel43.setVisible(true);
                        jLabel44.setVisible(true);
                        listCount++;
                        break;
                case 8: 
                        jLabel45.setVisible(true);
                        jLabel46.setVisible(true);                   
                        listCount++;
                        break;
                case 9:
                        jLabel36.setBackground(new Color(240,240,240));
                        jLabel37.setBackground(new Color(241,114,114));                                      
                        listCount++;
                        break;
                case 10:
                        jLabel30.setText("");
                        jLabel31.setText("");
                        listCount++;
                        break;
                case 11:
                        jLabel30.setText("21");
                        jLabel31.setText("NEXT");
                        jLabel43.setText("NULL");
                        jLabel44.setVisible(false);
                        jLabel45.setVisible(false);
                        jLabel46.setVisible(false);                   
                        listCount++;
                        break;
                case 12:
                        jLabel37.setBackground(new Color(240,240,240));
                        jLabel38.setBackground(new Color(241,114,114));                  
                        listCount++;                   
                        break;
               case 13:
                        jLabel38.setBackground(new Color(240,240,240));                                     
                        listCount=1;
                        timer.stop();
                        break;
                default: System.out.println("Invalid");break;
        }

    Create an Interface. Something like:
    interface PropertyChanger
         public void changeProperty();
    }Then implement the interface for each property. Something like:
    public class VisiblePropertyChanger
        private JComponent compoennt;
        private boolean visibility;
        public VisiblePropertyChanger(JComponent component, boolean visibility)
            this.component = component;
            this. visibility = visibility;
        public void changeProperty()
            component.setVisible( visibility );
    }Now your Timer will need an ArrayList of ArrayLists to store all the property changes:
    ArrayList main = new ArrayList();
    Add property changes information to an array list for each interval
    ArrayList interval1 = new ArrayList();
    interval1.add( new VisiblePropertyChanger(label32, true) );
    interval1.add( new VisiblePropertyChanger(label33. true) );
    main.add(interval1);
    ArrayList interval2 = new ArrayList();
    interval2.add( new BackgroundPropertyChanger(label32, new Color(...)) );
    main.add(interval2);
    ...Now the code in the actionPerformed would need to be change to get the "interval" array list from the main. Then you iterate through each PropertyChanger and invoke the changeProperty() method.

  • Make this query more elegant?

    can anybody tell me how to make this subquery more elegant?
    select 1 lfdidx from dual union
    select 2 lfdidx from dual union
    select 49 lfdidx from dual union
    select 50 lfdidx from dual
    Thanks in advance

    Sergey, thanks, that's what I hoped for.
    http://www.sqlsnippets.com/en/topic-11821.html has some additional info concerning this.
    Regards, Thomas

  • Ora-06502 pl/sql numeric or value error in Report Query in oracle apex

    Hello all,
    I need your help...
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    I am using bi publisher to generate PDF reports in oracle apex.
    We were using APEX 4.0 and migrated to 4.2 just a week ago.
    Now we have apex 4.2.
    When I try to Create report query,
    Shared Components >> Report Queries then create.
    and test a report in a create wizard I am getting a error "ORA-06502: PL/SQL: numeric or value error: character string buffer too small".
    I have also applied a patch "16760897".
    This issue is because of number of columns in a query is more then 26.
    If I run a report with 26 or less number of columns then the is working fine, otherwise getting this error.
    My before migration report queries working perfectly even now, but not new queries.
    This issue is also in apex.oracle.com.
    You can see
    Not working  - http://apex.oracle.com/pls/apex/f?p=619:4
    Working - http://apex.oracle.com/pls/apex/f?p=619:2:
    Please give a solution.
    Thanks you.

    check the DB version compatibility with apex 4 or your DB version to apex 4.0 support for upgrade!
    Oracle Application Express Installation Requirements for 4.0

  • Report-Query Value

    Hi Experts,
    Currently we are using one BW report in 3.5version(report query against multi provider).
    Current issue:
    Cube Fields:
    PO Number: 123
    Order value 100.
    Confirmation value 50
    Final Delivery Indicator: X (YES-No more confirmation is expected)
    Calculation on the Query:
    Outstanding Confirmed Value= Order Value - Net Confirmed Value
    Here Outstanding Confirmed Value = 100-50=50.So in the reports, Outstanding Confirmed Value shows 50.
    But the PO's Final Delivery Indicator is marked. So No more confirmation is expected
    Question:
    I am not able to create any formula against the filed Final Delivery Indicator. But i want to show in the report that if the PO's Final Delivery Indicator marked, then Outstanding Confirmed Value has to be 0(ZERO).
    Please help me achieve this result. Thanks.
    Advance Thanks.
    RR.

    Hi ,
    This can be achived in the following way.
    1. Create your formula
        "Outstanding Confirmed Value= Order Value - Net Confirmed Value" and hide it using the property.
    2. Create one more forumala which will check the condition. i.e. if the Final Delivery Indicator is marked then it will set the outstanding confirmed value as zero else it will show the value which we are getting by using above mentioned formula.
    put the following condition in the formula.
    [Final Delivery Indicator = = 0 ] * 0 + [Final Delivery Indicator <> 0]*Outstanding Confirmed Value
    This will work as follow.
    For example : Outstanding Confrimed Value is 50 and Final Delivery Indicator is marked.
    = [ 0 == 0 ] * 0 + [ 0 <> 0 ] * 50
    = 1* 0 + 0 * 50              " When the condition is satisfied its result is 1. here 0 == 0 condtion is satisfied so its return value is 1.
    = 0
    Hope this will help.
    - Jaimin

  • Performance issues when creating a Report / Query in Discoverer

    Hi forum,
    Hope you are can help, it involves a performance issues when creating a Report / Query.
    I have a Discoverer Report that currently takes less than 5 seconds to run. After I add a condition to bring back Batch Status that = ‘Posted’ we cancelled the query after reaching 20 minutes as this is way too long. If I remove the condition the query time goes back to less than 5 seconds.
    Please see attached the SQL Inspector Plan:
    Before Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    AND-EQUAL
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N2
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_N1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    After Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    TABLE ACCESS FULL GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX RANGE SCAN GL.GL_JE_HEADERS_N1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    INDEX UNIQUE SCAN GL.GL_CODE_COMBINATIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    Is there anything i can do in Discoverer Desktop / Administration to avoid this problem.
    Many thanks,
    Lance

    Hi Rod,
    I've tried the condition (Batch Status||'' = 'Posted') as you suggested, but the qeury time is still over 20 mins. To test i changed it to (Batch Status||'' = 'Unposted') and the query was returned within seconds again.
    I’ve been doing some more digging and have found the database view that is linked to the Journal Batches folder. See below.
    I think the problem is with the column using DECODE. When querying the column in TOAD the value of ‘P’ is returned. But in discoverer the condition is done on the value ‘Posted’. I’m not too sure how DECODE works, but think this could be the causing some sort of issue with Full Table Scans. How do we get around this?
    Lance
    DECODE( JOURNAL_BATCH1.STATUS,
    '+', 'Unable to validate or create CTA',
    '+*', 'Was unable to validate or create CTA',
    '-','Invalid or inactive rounding differences account in journal entry',
    '-*', 'Modified invalid or inactive rounding differences account in journal entry',
    '<', 'Showing sequence assignment failure',
    '<*', 'Was showing sequence assignment failure',
    '>', 'Showing cutoff rule violation',
    '>*', 'Was showing cutoff rule violation',
    'A', 'Journal batch failed funds reservation',
    'A*', 'Journal batch previously failed funds reservation',
    'AU', 'Showing batch with unopened period',
    'B', 'Showing batch control total violation',
    'B*', 'Was showing batch control total violation',
    'BF', 'Showing batch with frozen or inactive budget',
    'BU', 'Showing batch with unopened budget year',
    'C', 'Showing unopened reporting period',
    'C*', 'Was showing unopened reporting period',
    'D', 'Selected for posting to an unopened period',
    'D*', 'Was selected for posting to an unopened period',
    'E', 'Showing no journal entries for this batch',
    'E*', 'Was showing no journal entries for this batch',
    'EU', 'Showing batch with unopened encumbrance year',
    'F', 'Showing unopened reporting encumbrance year',
    'F*', 'Was showing unopened reporting encumbrance year',
    'G', 'Showing journal entry with invalid or inactive suspense account',
    'G*', 'Was showing journal entry with invalid or inactive suspense account',
    'H', 'Showing encumbrance journal entry with invalid or inactive reserve account',
    'H*', 'Was showing encumbrance journal entry with invalid or inactive reserve account',
    'I', 'In the process of being posted',
    'J', 'Showing journal control total violation',
    'J*', 'Was showing journal control total violation',
    'K', 'Showing unbalanced intercompany journal entry',
    'K*', 'Was showing unbalanced intercompany journal entry',
    'L', 'Showing unbalanced journal entry by account category',
    'L*', 'Was showing unbalanced journal entry by account category',
    'M', 'Showing multiple problems preventing posting of batch',
    'M*', 'Was showing multiple problems preventing posting of batch',
    'N', 'Journal produced error during intercompany balance processing',
    'N*', 'Journal produced error during intercompany balance processing',
    'O', 'Unable to convert amounts into reporting currency',
    'O*', 'Was unable to convert amounts into reporting currency',
    'P', 'Posted',
    'Q', 'Showing untaxed journal entry',
    'Q*', 'Was showing untaxed journal entry',
    'R', 'Showing unbalanced encumbrance entry without reserve account',
    'R*', 'Was showing unbalanced encumbrance entry without reserve account',
    'S', 'Already selected for posting',
    'T', 'Showing invalid period and conversion information for this batch',
    'T*', 'Was showing invalid period and conversion information for this batch',
    'U', 'Unposted',
    'V', 'Journal batch is unapproved',
    'V*', 'Journal batch was unapproved',
    'W', 'Showing an encumbrance journal entry with no encumbrance type',
    'W*', 'Was showing an encumbrance journal entry with no encumbrance type',
    'X', 'Showing an unbalanced journal entry but suspense not allowed',
    'X*', 'Was showing an unbalanced journal entry but suspense not allowed',
    'Z', 'Showing invalid journal entry lines or no journal entry lines',
    'Z*', 'Was showing invalid journal entry lines or no journal entry lines', NULL ),

  • Report query with bind variable

    Trying to create a report query for xsl-fo print. For output format I pick "derive from item" then pick the item name from the list, on the next screen, I paste the query with the bind variable. on the next step test query, I always get "data not found" regardless what value I type in. This is the same query that I ran under sql commands without any issues.
    Does anyone run into the same issue as I have when attempted to create a query with bind var ? There is no problem creating a query without bind varibles. . thanks.
    Munshar

    Hi, please did you get any solution to this issue? I am having similar challenge right now.
    select     EMP.DEPTNO as DEPTNO,
         DEPT.DNAME as DNAME,
         EMP.EMPNO as EMPNO,
         EMP.ENAME as ENAME,
         EMP.JOB as JOB,
         EMP.MGR as MGR,
         EMP.HIREDATE as HIREDATE,
         EMP.SAL as SAL
    from     SCOTT.DEPT DEPT,
         SCOTT.EMP EMP
    where EMP.DEPTNO=DEPT.DEPTNO
    and      DEPT.DNAME =upper(:dname)
    This run perfectly in sql developer, toad, and even inside publisher if I login directly to publisher to create report.
    Generating this same query in shared component query builder and testing it returns no data found. If I remove the last line, it works. but with the last line, it return no data found. It seems no one has been able to provide solution to this issue

  • APEX 4.0 Report Query column limitation, 43 column maximum for the result!

    Hi there,
    I'm trying to generate report from Apex 4.0.1, but I got stucked with column limitation when I'm executing the report query.
    Case:
    Environment: oracle 11g, apex 4.0.1, oracle BI 11, windows xp
    Table: My test table is quite simple, by creating a sample table with 44 columns, the column name is random, i.e. column1..column44, column data type is varchar2 (20)
    report query:my report query is also simple, by "select * from testtable"
    Data: no data in my sample table
    Error: then I'll get the error: "HelpORA-06502: PL/SQL: numeric or value error: character string buffer too small"
    solution: If I shrink the table column from 44 to 43, then the report can be generated to xls, pdf, etc.
    Question: Is there any column limitation for Apex report query? I know there's a 32k row size limitation for varchar, but since there's no single data in my table, it shouldn't be the case.
    Does anybody get this issue before? Thanks for any generous input!! :)
    Horatio

    hi marko,
    Thanks for the reply, but i can't find the 45 column limitation from report query and report printing. any clue for this call?
    Regards
    Horatio

  • Comma separated data into IN clause in oracle report query

    i have a field on form as order number it takes more than one value as 1,2,3
    now i want to fetch data in report query for where order no in 1,2 and 3...
    but field takes value as 1,2,3...
    how can i separte the comma from value and how can i pass value in IN clause...or
    how can i get all records with order no 1,2,3...
    please suggest how can i achieve the same....

    Hi Maddy....
    Try this :
    declare
    var varchar2(10);
    v1 varchar2(5);
    v2 varchar2(5);
    v3 varchar2(5);
    vRegExp varchar2(5);
    begin
    var:='1,2,3'; 
    vRegExp:='[^,]+';
    FOR i IN 1..length (regexp_replace (var,vRegExp))  + 1
    LOOP
                v1 := REGEXP_SUBSTR (var,vRegExp);
                v2 := REGEXP_INSTR(var,vRegExp,1,2);
                var := substr(var,v2);
               // here fetch you data from report by passing v1 as a parameter;
          EXIT WHEN v2 = 0;
    END LOOP;
    end;
    Hope this will resolve your question..
    Thanks

  • How do I reference columns in a report query from another report query?

    In Apex 3.1 it is possible to generate a report on more than one query. I have read that these queries can be correlated, but I cannot find how in the documentation.
    I go the Shared Components and create a new Report Query:
    select * from dept
    Then I click Add Query and I add:
    select * from emp
    How do I correlate these two queries (I want to join emp.deptno to dept.deptno) and have a nice hierarchicle XML-file.
    Is it possible in Apex 3.1?
    Dik Dral

    Dik,
    This type of query can't be build. The two queries are independent, you can't reference values in the first query from the second query. However you can reference page and application items - which won't help you all that much with this scenario though. You could also try combining the two queries into one, and then take care of the proper presentation in your template.
    Regards,
    Marc

  • How to change report query dynamically in Oracle APEX?

    Hi,
    I want to dynamically change the where condition in APEX report query. Can anyone help me solve my this problem?
    (Just want to change the query which we change in Oracle Reports using lexical parameter to change &Where, &Order by etc. dynamically!!)
    Thanks, Praful

    Hi
    I've been using flexible queries in APEX for a few years now, and your question just added a whole new dimension to the flexible and powerful nature or writing reports in APEX.
    While APEX Interactive reporting has almost completely removed the need the equivalent of Lexicals in Oracle Reports, I thought it might be fun to try and use lexicals in an APEX report.
    Before we start I should summarise the powerful capability of APEX reporting to have oprtional parameters (lots and lots of them if this is needed).
    For each parameter, you simply add a page item which will hold the value of the parameter.
    The item/parameter can be populated by typing in the value, defining an LOV, using a date-picker etc.
    To make the parameter optional simply use an OR in the where clause.
    So for a apge item P200_PARAM1.....include
    WHERE (:P200_PARAM1 IS NULL
    OR COLUMN1 = :P200_PARAM1)
    This way you can either leave the page item null or type in / select a value from a LOV.
    There is a small quirk in APEX LOV's which sometimes returns a value of '%' or '%null%' - depending on the version - when no value is selected.
    See Patrick Wolf's solution for this at Re: Null value handling in LOVs
    I include this Application Process in all my APEX applications ;)
    Now let's look at using the equivalent of Oracle Reports Lexicals......
    First-off - this is based on the APEX SQL report - NOT Interactive Report.
    It relies on the fact that you can let the query be parsed only at runtime.
    1. Define an SQL report entering the 'core' of your query.
    With a query like SELECT ENAME, JOB FROM EMP
    Select 'Generic Columns' option in the 'Column Headings' section
    Finish the report creation
    2. Define a page item - say P200_LEXICAL - type text on the page
    3. Edit the report and update the SQL query to include your lexical page item
    SELECT ENAME, JOB FROM EMP &P200_LEXICAL. (REMEMBER THE '.' AT THE END)
    Ensure that the option "Use Generic Column Names (parse query at runtime only)" is selected at the bottom of the query
    4. Add a button to the page -using 'Create a button displayed among this region's items' the will submit the page.
    5. Run the page - you will see all the employee names and job desdriptions
    6. Enter a where clause into the 'Lexical' textbox - say "WHERE ENAME LIKE 'K%'" and click the 'Go' button
    Voila! your where clause is magically applied.
    Try any variant you like adding an ORDER BY clause etc...... this is FUN!
    7. Clear the value of the LEXICAL and click go.
    Edit the report and move the &P200_LEXICAL. into the selected columns (or add another one)
    SELECT ENAME, JOB &P200_LEXICAL. FROM EMP
    8. Run the page
    Enter ",SAL" in the textbox and "Go"
    We can add as many columns as we like (subject to the "Maximum number of generic report columns:" set below the SQL query in the report edit section)
    Now because we have all the flexibility in APEX of setting page items using SQL or PLSQL you can set the value of the lexical programatically, or just pre-set a few values in an LOV - the options are limitless.
    While I've never had the need to use lexicals - you can see that APEX provides the most Flexible Lexicals in town.
    Eat your heart out "Oracle Reports"!!!
    Have fun
    Mike

  • How to do a union with a report query

    I've looked all over but can't seem to find any documentation that would suggest how to generate a union for a report query.
    The "all java" method would be two disparate report queries and then co-mingle the results. But we’d really like to have Oracle do the union and process only one result set.
    We are trying desperately to avoid the “code the SQL yourself” solution.
    Why a union? The Toplink expression generates SQL that takes Oracle over a minute to resolve. The Oracle Plan/Optimizer has several joins and full table scans in it that burn up the clock. If we break the expression apart at a very important ‘or’ clause each of the individual expressions takes a second or so – no full table scans. If we manually bolt the two expressions back together with a ‘union’ the ‘home grown’ expression takes a couple of seconds as the Oracle Optimizer executes each select and then combines the results.
    So any suggestions about how to get a Toplink union would be appreciated.

    I'm not much of a DBA or SQL guru, but here are a couple thoughts:
    - Is it possible to use a hint in association with the query to help Oracle with the join? Specifying hints is a new feature in 904 and may be your best solution here.
    - I don't think there is any union facility in the expression framework, but you might want to take a look at making an ExpressionOperator to do this. I think if you search this forum for ExpressionOperator you would hit some ideas.
    - Would it be reasonable or feasable to break the queries in two and then do the union in the middle tier? Just thinking out loud...
    - Don

  • Partial payment Crystal report query

    Hi,
    I have partial payment in outgoing. So I am not able capture this thing correctly so any one can give me the Crystal report query for this thing.
    Regards
    Swapnil

    Try this may it will help you ..
    in this query i have tracked againest PO.
    SELECT     Distinct OPOR.DocNum,OPCH.CardName,OPOR.DocNum
                          ,convert(varchar, OPCH.DocDueDate, 103) As "Payment Date",(OPCH.DocTotal-OPCH.PaidSUM) AS ' Pending Payment',DATEDIFF(DD,OPCH.DocdueDate,GETDATE()) as "Over Due Days"
    FROM         OPOR INNER JOIN
                          POR1 ON OPOR.DocEntry = POR1.DocEntry INNER JOIN
                          OPDN INNER JOIN
                          PDN1 ON OPDN.DocEntry = PDN1.DocEntry INNER JOIN
                          OPCH ON PDN1.TrgetEntry = OPCH.DocEntry INNER JOIN
                          PCH1 ON OPCH.DocEntry = PCH1.DocEntry ON POR1.TrgetEntry = OPDN.DocEntry where OPCH.DocStatus = 'O'
                          order by OPOR.DocNum ASC
    one more think we can design QPLD or CR not PLD.
    Thanks
    Manvendra singh Niranjan
    Edited by: Manvendra Singh Niranjan on Jun 25, 2011 2:57 PM
    Edited by: Manvendra Singh Niranjan on Jun 26, 2011 8:14 AM

Maybe you are looking for

  • Open files from a specific directory

    Dear all, I have the following source code that simply selects files from a directory. private void openFile() JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY ); int result = fileChooser.showOp

  • How can i make this stored procedure work

    Im using MSSQL 2000 im trying to write a stored procedure which first checks if a certain day is already stored if not store the day and the owner and return something to show if it was stored or not create procedure dbo.pickDay @day datetime, @owner

  • The selected context node does not have attributes - Message no. SWDP_WB_TO

    Hello, I am trying out the example in web dynpro documentation -> Creating a Simple Flight Info Application and in part 3 steps 11 - 13 I get the following error The selected context node does not have attributes and the associated message class and

  • Comparing elements inside a vector

    Hello, I am having a hard time understanding how to compare elements inside a vector. I have a vector of six strings and I want to compare the first element at index 0 with all other elements at positions 1-5. After that, compare the element at posit

  • Installing Windows 7 Macbook Air

    Hey all, I've been working on this for days, and I've been trying to install Windows 7 Ultimate (64 bit) onto my MacBook Air I bought last year. I'm having a problem with Bootcamp assistant though; whenever I tell it to create a windows 7 install dis