1

I am trying to build an Oracle Apex web page. I have the SQL query which I run in Db Visualizer and is fine. It's supposed to fetch about 7 million records but stops at 1000 because of limiting the rows in DB Vis.

This is my SQL query:

    select t.*, t.rowid from table t
    where  custedp =
           ( select min(custedp) from tablex
             where  fullorderno like substr('${ORD}$',1,8) || '%' );

I am trying to enter the ORD variable through a page item which is P2_new so my new SQL query is

    select t.*, t.rowid from table t
    where  custedp = 
           ( select min(custedp) from tablex
             where  fullorderno like substr(:P2_new,1,8) || '%' );

I created a region in the web page new (static content),page item (text field) p2_new and button submit which is going to submit the page. Everything until here is fine when I change the region new to a classic report from a static content the page doesn't load at all . It has a loading... on the tab and the address bar shows "about:blank" . I tried to validate the code and it also showed me an

     ajax call returned server error ora-20001 :error at line 1 error when I 
     tried to validate the code using the in built validator .
5
  • Maybe removing the semicolon? Commented Jun 8, 2018 at 19:44
  • Does the value P2_new have at least 8 chars? Commented Jun 8, 2018 at 19:45
  • No . It wasn't that . Commented Jun 8, 2018 at 19:54
  • the page is not loading for me to enter any value . The page in theory looks perfect but it's not loading at all . The SQL is fine . Commented Jun 8, 2018 at 19:55
  • It is probably because of the SQL . When I try it with a simple table it returns values quickly and also loads Commented Jun 8, 2018 at 20:28

1 Answer 1

1

What do you plan to do with 7 million rows presented on a single page?

Anyway: classic report's query runs as soon as you navigate to that page. Thanks to || '%', query searches for min(custedp) throughout the whole tablex, without waiting for you to enter something into the P2_NEW item and press the SUBMIT button. So, if you wait long enough, it might return something.

Or, modify that query so that it runs if P2_NEW contains some value. For example:

select t.*, t.rowid 
from table t       
where custedp = (select min(custedp) 
                 from tablex 
                 where 1 = case when :P2_NEW is null then 2
                                else 1
                           end
                    and fullorderno like SUBSTR(:P2_new,1,8) || '%'
                ); 

Also, consider setting P2_NEW's source Always, replacing any existing value in session state.

Sign up to request clarification or add additional context in comments.

9 Comments

I don't want it to display 7 million rows . I wanted it to display one out of the 7 million . Your explanation makes sense . I don't understand how it can run the query when its not given with the value for the variable .
The first CASE condition will evaluate to 1 = 2 (i.e. false) when P2_NEW is null and query won't return anything. Once you put something into the item, it'll become 1 = 1 (i.e. true) and query might return the result (if fullorderno like SUBSTR(:P2_new,1,8) || '%' condition is met).
The "Always, replacing any existing value in session state" helped I think . I also changed the like to '=' .
Changing LIKE to = can't help, unless FULLORDERNO ends with a percentage sign. Besides, it is usual to "reward" someone who helped either by accepting their answer or upvoting it (instead of accepting your own (apparently, wrong) solution).
Calm down . I did up vote your answer . I just don't have a high enough reputation for my up votes to show . I accepted my answer because I thought that was the right solution with your supporting explanation and I deleted it when it didn't work .
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.