Embedding javascript in a sql query

Hello everybody,
that is the question, how can a JavaScript function like: getElementById
can be (if at all be embedded in a sql query? the thing is that when I do the query
SELECT firstname, lastname etc
WHERE branchnumber = here is where I want to include the javascript function so that it gets the value from a manually inserted value in a text field that the user enters.
the item name is P3_X (which is a textfield)
I would like to put something like
WHERE branchnumber = getElementById('P3_X').value);
but it does not parse it ..
so I may be close but there is something that is not right

Thank you for your good will Mennam from Turkey. I have found another way of solving it, in the data expresss edition each item you create carries the name you give it, then you make a reference to it on your SQL query, that item can be a combo box, a text field, etc any means for the user to enter data. that works fine.a reference as easy as this one: WHERE ( bookings.branchnumber = :PTEXT )
Alvaro

Similar Messages

  • SQL Query in Javascript

    Hi All,
    I have an SQL query which needs to be invoked when ever javscript function is called.
    Is it possible in Oracle Apex to embed a SQL query in the javascript function...If so, Please can anyone provide me with a right syntax ???
    Regards,
    Sandeep Reddy

    Thank you so much for your reply..
    I tried implementing it but facing the problem in PL/SQL code defined in the application process.. I am getting the coloum name is invalid..however, the coloum is valid for the table.
    declare
    lineprice LINEITEM%rowtype;
    Begin
    select LineUnitPrice
    into lineprice
    from LINEITEM
    where PriceCategoryID = :PRICECATEGORY AND LineItemID = :LINEITEM;
    htp.prn(lineprice);
    exception when others then htp.prn('An error occurred retrieving record');
    end;
    sqlerrm:ORA-06550: line 7, column 45:PL/SQL: ORA-00904: "LINEITEMID": invalid identifierORA-06550: line 4, column 1:PL/SQL: SQL Statement ignoredORA-06550: line 8, column 1:PLS-00306: wrong number or types of arguments in call to 'PRN'ORA-06550: line 8, column 1:PL/SQL: Statement ignored
    Please let me the know the correct path to sort out this problem..

  • Javascript embedded in button pl/sql event handler not being executed

    Javascript calls not working from pl/sql button event handler. What am I missing? Are specific settings needed to execute javascript from pl/sql proceedures?
    Example: Want to toggle target='_blank' off and on in a button pl/sql event handler to open url call in new window & then reset when processing submit is done & the app returns to the form.
    portal form button's pl/sql submit handler:
    begin
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    end ;
    Putting the following in the button's javascript on_click event handler works great:
    this.form.target='_blank'
    to force opening new window with a call in the button's submit pl/sql code via:
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    but then the target='_blank' is left on when the submit is done & we return to the form.
    putting the above javascript as a function (called fcn_newpage) elsewhere (e.g., after form opens) & calling in the submit pl/sql with
    htp.p('fcn_newpage') ;
    also doesn't work.
    Metalink thought this was an application issue instead of a bug, so thought I'd see if anyone knows what's going wrong here. (Portal 9.0.4.1)

    thanks for your discussion of my post.
    Please clarify:
    "htp.p('fcn_newwindow') sends a string":
    What would you suggest the proper syntax for a function fcn_newwindow() call from a pl/sql javascript block that differs from
    htp.p('<script language="Javascript">') ;
    htp.p('fcn_newwindow');
    htp.p('</script>');
    or more simply
    htp.p('fcn_newwindow') ;
    More generally, what I'm trying to figure out is under what conditions javascript is executed, if ever, in the pl/sql of a button (either the submit or custom event handler, depending on the button).
    I've seen lots of posts asking how to do a simple htp.p('alert("THIS IS TROUBLE")') ; in a pl/sql event handler for a button on a form, but no description of how this can be done successfully.
    In addition to alerts, in my case, I'd like to call a javascript fcn from a pl/sql event handle that would pass a URL (e.g., http://www.oracle.com) where the javascript fcn executed
    window.open(URL). The API call to set_target(URL) in pl/sql has no ability to open in a new window, so calling that is inadequate to my needs and I must resort to javascript.
    Its clear in the PL/SQL of a button, you can effect form components since p_session..set_target & p_session.get_target set or get the contents of form components.
    So to see if javascript ever works, I tried to focus on something simple that only had to set what amounts to an enviromental variable when we returned to the form after a post. I chose to try to change the html value of TARGET from javascript in the PL/SQL button because it doesn't need to be implemented until we finish the post and return to the form.
    So I focused on a hack, setting this.form.TARGET='_blank' in the on_click event handler that forced every subsequent URL call or refresh of the form to be a new window. I then wanted to turn off opening new windows once I'd opened the URL call in a new window by setting TARGET='' in the portal form. I can achieve what I want by coding this.form.TARGET='' in the javascript (on_focus, on_change, or on_mousedown, ...) of every form component that might refresh the form. However, that is a ridiculous hack when a simple htp.p('<script>') ; htp.p('this.form.target=""') ; htp.p('</script>') ; at the end of the button's pl/sql event handle should do the same thing reliably if javascript ever works in the pl/sql event handler.
    If we didn't have access to form components through p_session calls, I'd assume it was a scope issue (what is available from the pl/sql event handler). But unless my syntax is just off, when, if ever, can javascript be used in a portal form's pl/sql event handler for a button?
    if I code a javascript funtion in the forms' pl/sql before displaying form:
    htp.p('<script language="JavaScript">') ;
    htp.p('function fcn_new_window(URL)') ;
    htp.p('window.open(URL)' ) ;
    htp.p('</script>') ;
    the function can be called from a button's on_click javascript event handler:
    fcn_new_window('http://www.oracle.com')
    but from the same button's pl/sql submit event handler this call doesn't work: htp.p('fcn_new_window("http://www.oracle.com")')
    So my questions remain: Is there other syntax I need, or does javascript ever work properly from the pl/sql of a form button's event handler? If it doesn't work, isn't this a bug that should be fixed by Oracle?
    I can probably figure out hacks to make things work the way I need, but executing javascript from pl/sql event handlers seems to be the expected way to affect portal html pages (forms, reports, ...) and it seems not to work as expected. I don't feel I should have to implement hacks for something as simple as calling a javascript function from pl/sql when almost every example I've found in metalink or the forums or Oracle Press's "portal bible" suggests using javascript from pl/sql via the utility htp.p() to effect web page components in portal.
    My TAR on the subject, while still open, returned the result basically: "We can reproduce your situation. Everything looks okay to us, but we can't explain how to use javascript where you want or point you to any documentation that would solve your problem or expain why it should not work the way you want it to. We don't feel its a technical issue. Why don't you post the problem on the portal applications forum."
    I'm hoping I'm just missing something fundamental and everything will work if I implement it a little differently. So if anyone sees my error, please let me know.
    by the way, not sure this is germain, but in reference to your comment:
    "redirections in pl/sql procedures give a peculiar result. in a pl/sql procedure, usually, portals give the last redirection statement and ignore anything else coming after it."
    if I try to raise an alert:
    htp.p('alert("you screwed up")');
    return;
    in a pl/sql event handler, it still doesn't raise the alert, even though its the last thing implemented in the event handler. But if I set the value of a text box using p_session..set_value_as_string() at the same spot, it correctly sets the text box value when I return to the form.

  • Executing sql query in maviewer 10.1.3 javascript api

    Hi, i want to execute a sql query according to my applications requirement i.e. for retrieving some fields from the oracle database.How to do that? Please someone help me. Thanks.

    Im sorry..
    But how can I use JSP for querying non spatial data???
    Can you give me some example please..
    I've read about doQuery.. but I don't quite understand how to use it.. ^^

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • Dynamic Link in SQL Query Report

    Andy,
    I refromatted the message since it was all garbled, I didn't realize it came out like that the first time.
    1) I am not sure what you meant by the "#" in your message until I did the substitution of #'s for < > I didn't have that in my URL.
    2) Since the whole statement is enclosed in single quotes to be inside of a decode statement I think this is an issue with the javascript and it's double quotes or is it?
    3) I took care of the passing values for items, even if I can just get the link to work some what I would be happy I can worry abou those values later..
    Hello I have a a link that is generated in a report
    sql based on an SQL query and I would like to turn it
    into a popup instead of a direct link. But I seem to
    be having some problems going from a link to a popup
    link...
    <b> I replaced the brackets < > with "#" </b>
    This statement works;
    SELECT decode(create_date, NULL, NULL, '#a
    href="f?p=&APP_ID.:71:&SESSION.::NO:100:P71_EQUIPMENT_
    ID,P71_CONTAINER_TYPE_ID:' || equipment_id || ',' ||
    container_type_id || '"/#' || create_date ||'#/#>' )
    AS "HIST_NOTE",
    </br>
    </br>
    but I would like to turn make it a popup instead of a
    direct link, I think the problem has something to do
    with the parenthesis (double and single mixed) any
    ideas?
    </br>
    </br>
    I tried doubling them up (using three single ticks
    for double parens inside of single ticks and
    everything
    </br>
    </br>
    <b> I replaced the brackets < > with "#" </b>
    decode(create_date,
    NULL,
    NULL,
    '#a href="javascript:popupPage('f?p=&APP_ID.:71:&SESSION.::NO:100:P71_EQUIPMENT_ID,P71_CONTAINER_TYPE_ID:' || equipment_id || ',' || container_type_id || '"/#' || create_date ||'#/a#')" ' AS "HIST_NOTE",
    </br>
    </br>
    Any ideas?
    The error I usually get mostly complains about "ORA-00907: missing right parenthesis"....
    I put an example up on apex.oracle.com if you want to debug it there (it of course does not work right now)
    http://apex.oracle.com/pls/otn/f?p=18490:5
    guest/apex123
    Thanks
    Justin
    Message was edited by:
    Justin P

    Denes,
    I was able to get it working based on one of your examples, it gets ugly when you embed the popup javascript into the link as you know. You have some really great examples, I hadn't been to your page in awhile.
    Here is my end result (this is embedded in a decode statement so single ticks would go around the entire example below)
    &lt;a href="javascript:popUp2('''
    || 'f?p=&APP_ID.:71:&SESSION.::NO:100:'
    || 'P71_EQUIPMENT_ID,P71_CONTAINER_TYPE_ID:'
    || equipment_id || ',' || '&F110_CONTAINER_TYPE_IP.'
    || ''', 900, 600);">'
    || create_date
    || '&lt;/a>
    Thanks to all that helped me out here,
    Justin

  • How to schedule a sql query on Windows

    Hi Experts;
    I got a sql query that I need to put on schedule, (on windows) in order it runs everyday at specific time.
    I got the query, but I want to know the next:
    How to invoke SQLPlus from this query? Explain how to include the user/password@SID
    Do I need to create this query in a .bat file?
    Also I want to know, how to send the results to an email?
    Thanks for your help.
    Regards
    Al

    I would suggest to put your sql query to a separate file and spool the result to a concrete file:
    query.sql:
    spool query.lst
    select * from emp;
    spool off;create a bat file query.bat:
    sqlplus <connection> @query.sql
    ...work with content of query.lst, send mail etcThen schedule your bat file with Windows scheduler
    The above could be simplified with JavaScript or VBScript
    Thanks.

  • Is there a simple way to refresh a SQL Query (Updatable report) region

    I have a page in APex 4.1 that has many regions. I would like to be able to refresh a single region.
    Currently, I have the following
    Region (sql query updateable report).
    STATIC ID = LANDINGS
    in the region footer, I have:
    <script type="text/javascript">
    $s('P110_LANDINGS_REGION_ID','#REGION_STATIC_ID#');
    </script>
    P110_LANDINGS_REGION_ID is a hidden field.
    I use javascript to refresh....but it does not seem to be working. Previously, we had hard-coded the region id ( $a_report('1363338167540162011','1','100','100');) ...but that ID was somehow corrupted, which has lead me to the 'OMG...there must be an easier way!' lament.
    the javascript is:
    $a_report('P110_LANDINGS_REGION_ID','1','100','100');
    thanks!
    Karen
    ps. could I just directly reference the static id in my javascript...
    $a_report('LANDINGS','1','100','100');

    Karen,
    First off: please post code in &#123;code&#125;...&#123;code&#125; tags!
    function AddFavoriteSpecies()
    get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=favorite_species_collection',0);
    gReturn = get.get();
    rowCount = rowCount + parseInt(gReturn);
    pHMS_add = '&G_HMS_FLAG.';
    $a_report('1363338167540162011','1','100','100');
    //$a_report($x('P110_LANDINGS_ID').value,'1','15','15');the statement:
    $a_report('1363338167540162011','1','100','100'); works, but the statement $a_report($x('P110_LANDINGS_ID').value,'1','15','15'); does not.
    Can anyone help.
    I am assigning the page field P110_LANDINGS_ID in the footer of a region with a static id = LANDINGS.
    <script type="text/javascript">
    $s('P110_LANDINGS_ID','#REGION_STATIC_ID#');
    </script>
    Well, let's start by dumping $a_report. This is undocumented code, and it has long been replaced by triggering a refresh.
    Next, don't use $x(pNode).value to retrieve a value. Rather use $v(pNode) to do this.
    function AddFavoriteSpecies()
       get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=favorite_species_collection',0);
       gReturn = get.get();
       rowCount = rowCount + parseInt(gReturn);
       pHMS_add = '&G_HMS_FLAG.';
       //get the region id from the item
       //use it in a jQuery selector to get the region
       //trigger the refresh event on this object
       $("#" + $v('P110_LANDINGS_ID')).trigger('apexrefresh');
    }Now if you want to make sure that P110_LANDINGS_ID contains a value, add an alert with its value before you use it.
    alert('P110_LANDINGS_ID value: '+$v('P110_LANDINGS_ID'))

  • SQL Query (report region) without full page reset

    Hello,
    I have a page with several items, some of them with default values, and a report region, performing SQL query based on one of the items – text field (always submits page when Enter pressed). When the page submits, the HTML DB engine performs and display the query, but at the same time, reset the other page items to their default values.
    Is it possible to run the query without the HTML DB reset the item values to their default state?
    Thanks,
    Arie.

    Hi Peter,
    Well, this is not exactly the case. I have an Item – File Browse – which defined as "Only when current value in session state is null", and a HTML text region, which contain Iframe, with default src tag (which I'm changing, using JavaScript, prior to the running of the SQL query). After running the query – in a report region – both the item and the Iframe reset to their original state.
    Any Ideas on how to prevent that?
    Thanks,
    Arie.

  • Update Field On Change For A SQL Query (updateable report)

    Hi,
    I'd like to request help from anyone with ideas on how to solve this.
    We are using APEX 4.2, 10GR2, RedHat5.
    I have a report that comes from SQL Query (updateable report).
    I'm using the apex_item.text and apex_item.hidden on fields.
    I'm using a button to submit and after submit process to add some logic that I need.
    There could be 1 - 10 records in the report.
    There is only 1 field that is needed to enter a value, but the value of this field determines the value of another field.
    I think that I can do this with a submit button and an after submit process where I loop through all the records. I think I have this handled.
    This is the question
    When the value of that field is changed then the value of another field in the same row changes immediately.
    Is this possible?
    All the examples I've seen so far are for a single record and that doesn't work for us.
    I guess this is a MRU process but I haven't seen an example where a dynamic action is possible on a Multi Row Update.
    Could anyone direct me to where I can see an example or help me get directions?
    I appreciate all your help an comments and I thank you in advance.

    Yes why not...what you looking for is a ajax call
    See {message:id=10390979}
    Please note:-you can also do this as a dynamic action as shown below
    Event: Change
    Selection type: jQuery Selector
    jQuery Selector: input[name="f01"]
    True action with Execute JavaScript Code and put all code inside the test funtion, you may need to amend the code to use this.triggeringElemnt in place of this

  • Help needed in executing SQL query...

    Hi,
    I am very new to JDeveloper. Curently i am tryin to execute an SQL query from the BPEL process, the output of the query is to be mapped to a variable field from a target xsd file. the query is fairly simple, like
    SELECT emp
    FROM emp_table
    WHERE emp_id=123
    The target field, namely "employee", is an element from the xsd file. I tried using Java embedding activity to connect to the db and execute the query through a piece of Java code, but couldn't find a way to assign the output of the query to the field. however lately i also discovered the Database Adapter services which helps me create a database connection, but still i am not sure as of how to handle and map the output of the query to the variable field.
    Can somebody please help me in resolving the issue either through Java Embed activity or Database Adapter services??
    Thanks in advance
    Anjan

    Anjan,
    I suggest you try the [url http://forums.oracle.com/forums/forum.jspa?forumID=212]BPEL Forum
    John

  • Default value of date picker not showing in sql query

    Hi,
    I have a tabular form page with a query similar to the following:
    select emp_name, salary from emp_table where trunc(hire_date)=trunc(to_date(:P42_START_DATE))
    where P42_START_DATE is the name of a date picker item.
    I set the source type of the date picker to be "Only when current value in session state is null" and the value to be "select trunc(next_day(sysdate,'MON')-7) from dual;" - basically the monday of the current week. I set the sequence of the date picker to be 5, and the sequence of the region to be 10. Now, when I open this page, no data gets pulled. I checked the page source, and the value of the date picker input is being set to "17-NOV-2008", but it somehow isn't reflected in the sql query.
    Data does get retrieved if I manually set the date in the date picker, but I'd like it to default to the monday of the current week. What am I doing wrong?
    Thanks

    nope, still same problem.
    I used javascript alerts to help debug, and here might be some useful information.
    The computation to set the value of :P42_START_DATE is set to run "before header", but when I put this following javascript in the header:
    <script language="javascript">
    var c = $v('P42_START_DATE');
    alert(c);
    </script>
    the alert box is blank (ie :P42_START_DATE is empty). Putting the same exact script in the footer gives 24-Nov-2008 in the alert box. Now, the SQL query is run sometime after the first alert and before the second alert, I believe. Why would the value of :P42_START_DATE not be getting set at the correct time?
    P42_START_DATE is a date picker item that belongs to the region SCHEDULE (which is where the sql query is). I set the sequence of the region to 10, and the sequence of the date picker and computation to be 5 and 6. Even so, does this mean that the sql query is executing before the call to the computation, because the region needs to be created before any items can be created that belong to the region?

  • Sql query is hung, doesn't comes back

    Hello Every one,
    Two node Rac on Linux 5 64-bit, 11.2.0.1.0
    In our data ware housing environment, i have a sql query which doesn't comes back at all, when i run, it is just hung for a long time with no output. I did following basic testing
    1. All the indexes are valid and stats are up to date(count(*) matches num rows)
    2. There is a union clause in the query, i divided the query in two parts - the first part prior to union and second part after union, then i ran those two parts separately - the first part comes back quickly with no rows selected but the second part has a main problem(its just hung).
    Please note that one table in the query has a partitioned table. following is the query and the tables involved in it.
    Please let me know if you need any further information, it will be of great help if i get through this. Thanks in advance.
    OWNER                          TABLE_NAME                     STATUS   LAST_ANAL   NUM_ROWS
    MAINTENANCE_DM                 D_VEHICLE                      VALID    21-NOV-12     752590
    PTL_HOLD                       R_COMP_CODES                   VALID    21-NOV-12        108
    PTL_HOLD                       USER_GEO                       VALID    20-DEC-12        300
    PTL_EDW                        D_CUSTOMER                     VALID    20-DEC-12     219498
    PTL_EDW                        D_LOCN                         VALID    20-DEC-12      19456
    PTL_EDW                        D_VEHICLE                      VALID    20-DEC-12    3973271
    PTL_EDW                        F_VEH_LOCN                     VALID    20-DEC-12    3131138
    PTL_EDW                        F_RO_DETL                      VALID    21-NOV-12   29234052
    8 rows selected.
    SELECT
      '../../opendoc/',
      '&hideSave=true&hideEdit=true&hideRefresh=true&hideUserPromptInput=true',
      'Data As Of:',
      'Run Date:',
      ptl_hold.get_stgextr_time('FACT_FPNA_RO'),
      'RO Date',
      PTL_EDW.F_RO_DETL.RO_TYP,
      PTL_EDW.D_CUSTOMER.CUST_NUM,
      (PTL_EDW.D_CUSTOMER.CUST_NUM )||' - '||( PTL_EDW.D_CUSTOMER.CUST_PRIME_NM),
      PTL_EDW.D_CUSTOMER.BILL_GRP,
      CASE WHEN PTL_EDW.D_LOCN.CORP_CD='HPTL' THEN 'US' ELSE CASE WHEN  PTL_EDW.D_LOCN.CORP_CD='2000' THEN 'CANADA' ELSE 'UNKNOWN' END END,
      PTL_EDW.D_LOCN.REGN_NUM,
      PTL_EDW.D_LOCN.REGN_NUM ||' - '||PTL_EDW.D_LOCN.REGN_NM,
      PTL_EDW.D_LOCN.AREA_NUM,
      PTL_EDW.D_LOCN.AREA_NUM||' - '||PTL_EDW.D_LOCN.AREA_NM,
      PTL_EDW.D_LOCN.RDIST_NUM,
      PTL_EDW.D_LOCN.RDIST_NUM||' - '||PTL_EDW.D_LOCN.RDIST_NM,
      PTL_EDW.D_LOCN.DIST_NUM,
      PTL_EDW.D_LOCN.DIST_NUM||' - '||PTL_EDW.D_LOCN.DIST_NM,
      CASE WHEN TRIM(PTL_EDW.D_VEHICLE.VEH_CAP_STAT) IN ('ACTIVE','ACCRUED') THEN 'Active' ELSE 'Inactive' END,
      DECODE(PTL_EDW.D_VEHICLE.CONTR_GRP, 'X' ,'NON-CONTRACT',PTL_EDW.D_VEHICLE.VEH_CAT),
      PTL_EDW.D_VEHICLE.VEH_UNIT_TYP,
      PTL_EDW.D_VEHICLE.VEH_MODL_YR,
      PTL_EDW.D_VEHICLE.VEH_MAKE,
      PTL_EDW.D_VEHICLE.VEH_MODEL,
      CASE WHEN ( PTL_HOLD.R_COMP_CODES.COMP_CD ) IN ('057','061') THEN 'Accident/Incident' ELSE 'Non-Accident/Incident' END,
      PTL_HOLD.R_COMP_CODES.COMP_CD,
      PTL_HOLD.R_COMP_CODES.COMP_DESC,
      PTL_HOLD.R_COMP_CODES.COMP_CD||' - '||PTL_HOLD.R_COMP_CODES.COMP_DESC,
      PTL_EDW.D_VEHICLE.UNIT_NUM,
      PTL_EDW_D_RO_LOCN.DIST_NUM || PTL_EDW_D_RO_LOCN.DIST_SUFX ||  PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM,
      PTL_EDW_D_RO_LOCN.DIST_NUM || PTL_EDW_D_RO_LOCN.DIST_SUFX || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM || PTL_EDW.F_RO_DETL.RO_SEQ_NUM
      PTL_EDW.F_RO_DETL.RO_SRC,
      PTL_EDW.F_RO_DETL.TOTAL_LABOR_HRS,
      PTL_EDW.F_RO_DETL.TOTAL_LABOR_COST,
      PTL_EDW.F_RO_DETL.OUT_COST,
      PTL_EDW.F_RO_DETL.PARTS_COST,
      PTL_EDW.F_RO_DETL.RO_COST,
      TO_CHAR(PTL_EDW_D_RO_LOCN.LOCN_KEY),
      PTL_EDW.F_RO_DETL.RO_NUM,
      PTL_EDW.F_RO_DETL.RO_SEQ_NUM,
      PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    FROM
      PTL_EDW.F_RO_DETL,
      PTL_EDW.D_CUSTOMER,
      PTL_EDW.D_LOCN,
      PTL_EDW.D_VEHICLE,
      PTL_HOLD.R_COMP_CODES,
      PTL_EDW.D_LOCN  PTL_EDW_D_RO_LOCN,
      PTL_EDW.D_LOCN  PTL_EDW_D_CHRG_LOCN,
      PTL_EDW.D_TIME,
      PTL_EDW.D_LOCN  CURRENT_VEH_LOCN,
      PTL_EDW.F_VEH_LOCN,
      PTL_EDW.D_VEHICLE  CURRENT_VEH
    WHERE
      ( PTL_EDW.F_RO_DETL.CUST_KEY=PTL_EDW.D_CUSTOMER.CUST_KEY  )
      AND  ( PTL_EDW.F_RO_DETL.LOCN_KEY=PTL_EDW.D_LOCN.LOCN_KEY  )
      AND  ( PTL_EDW.D_TIME.TIME_KEY=PTL_EDW.F_RO_DETL.RO_TIME_KEY  )
      AND  ( PTL_EDW.D_VEHICLE.VEH_KEY=PTL_EDW.F_RO_DETL.VEH_KEY  )
      AND  ( PTL_EDW_D_RO_LOCN.LOCN_KEY=PTL_EDW.F_RO_DETL.RO_LOCN_KEY  )
      AND  ( PTL_EDW.F_RO_DETL.CHRG_LOCN_KEY=PTL_EDW_D_CHRG_LOCN.LOCN_KEY  )
      AND  ( CURRENT_VEH_LOCN.LOCN_KEY=PTL_EDW.F_VEH_LOCN.LOCN_KEY  )
      AND  ( CURRENT_VEH.SCD_FLG='A'  )
      AND  ( CURRENT_VEH.CONTR_GRP='P'  )
      AND  ( CURRENT_VEH.CORP_CD=PTL_EDW.D_VEHICLE.CORP_CD and CURRENT_VEH.UNIT_NUM=PTL_EDW.D_VEHICLE.UNIT_NUM  )
      AND  ( CURRENT_VEH.VEH_KEY=PTL_EDW.F_VEH_LOCN.VEH_KEY  )
      AND  ( PTL_HOLD.R_COMP_CODES.COMP_CD=PTL_EDW.F_RO_DETL.COMP_CD  )
      AND 
       ( 'Accounting Month' = 'RO Date'  )
       AND
       ( '2500' = 'NO-MIN'
    OR    EXISTS(SELECT RO_TOTAL_COST.RO_LOCN_KEY, RO_TOTAL_COST.ORIGINAL_RO_NUM 
    FROM      PTL_EDW.F_RO_DETL RO_TOTAL_COST,
        PTL_EDW.D_TIME DTIME
    WHERE
        ('I' = 'I'
        OR ('I' = 'E'
            AND RO_TOTAL_COST.RO_TYP  <>  'W'))
        AND RO_TOTAL_COST.RO_LOCN_KEY = PTL_EDW.F_RO_DETL.RO_LOCN_KEY
        AND RO_TOTAL_COST.ORIGINAL_RO_NUM = PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
        AND RO_TOTAL_COST.RO_TIME_KEY = DTIME.TIME_KEY
        AND DTIME.CALENDAR_DT BETWEEN to_date('2011-JAN-01') AND to_date('2012-SEP-24')
    GROUP BY
        RO_TOTAL_COST.RO_LOCN_KEY,
        RO_TOTAL_COST.ORIGINAL_RO_NUM
    HAVING
    Sum(RO_TOTAL_COST.RO_COST) >= TO_NUMBER(translate('2500','NO-MIN',' ')))
       AND
       PTL_EDW_D_CHRG_LOCN.DIST_NUM_SUFX  IN  ('014810')
       AND
       ( PTL_EDW.D_TIME.CALENDAR_DT  BETWEEN  to_date('2011-JAN-01') AND to_date('2012-SEP-24')  )
       AND
       ( 'I'  = 'I'
      OR
      ( 'I' = 'E'
         And ( ( PTL_EDW.F_RO_DETL.RO_TYP ) <> 'W'
       AND
       ( EXISTS(SELECT *  FROM PTL_HOLD.USER_GEO WHERE USERID='600125729' AND PTL_HOLD.USER_GEO.GEO IN (CURRENT_VEH_LOCN.CORP_CD, CURRENT_VEH_LOCN.REGN_NUM, CURRENT_VEH_LOCN.AREA_NUM, CURRENT_VEH_LOCN.RDIST_NUM, CURRENT_VEH_LOCN.DIST_NUM))  )
    UNION 
    SELECT
      '../../opendoc/',
      '&hideSave=true&hideEdit=true&hideRefresh=true&hideUserPromptInput=true',
      'Data As Of:',
      'Run Date:',
      ptl_hold.get_stgextr_time('FACT_FPNA_RO'),
      'Accounting Month',
      PTL_EDW.F_RO_DETL.RO_TYP,
      PTL_EDW.D_CUSTOMER.CUST_NUM,
      (PTL_EDW.D_CUSTOMER.CUST_NUM )||' - '||( PTL_EDW.D_CUSTOMER.CUST_PRIME_NM),
      PTL_EDW.D_CUSTOMER.BILL_GRP,
      CASE WHEN PTL_EDW.D_LOCN.CORP_CD='HPTL' THEN 'US' ELSE CASE WHEN  PTL_EDW.D_LOCN.CORP_CD='2000' THEN 'CANADA' ELSE 'UNKNOWN' END END,
      PTL_EDW.D_LOCN.REGN_NUM,
      PTL_EDW.D_LOCN.REGN_NUM ||' - '||PTL_EDW.D_LOCN.REGN_NM,
      PTL_EDW.D_LOCN.AREA_NUM,
      PTL_EDW.D_LOCN.AREA_NUM||' - '||PTL_EDW.D_LOCN.AREA_NM,
      PTL_EDW.D_LOCN.RDIST_NUM,
      PTL_EDW.D_LOCN.RDIST_NUM||' - '||PTL_EDW.D_LOCN.RDIST_NM,
      PTL_EDW.D_LOCN.DIST_NUM,
      PTL_EDW.D_LOCN.DIST_NUM||' - '||PTL_EDW.D_LOCN.DIST_NM,
      CASE WHEN TRIM(PTL_EDW.D_VEHICLE.VEH_CAP_STAT) IN ('ACTIVE','ACCRUED') THEN 'Active' ELSE 'Inactive' END,
      DECODE(PTL_EDW.D_VEHICLE.CONTR_GRP, 'X' ,'NON-CONTRACT',PTL_EDW.D_VEHICLE.VEH_CAT),
      PTL_EDW.D_VEHICLE.VEH_UNIT_TYP,
      PTL_EDW.D_VEHICLE.VEH_MODL_YR,
      PTL_EDW.D_VEHICLE.VEH_MAKE,
      PTL_EDW.D_VEHICLE.VEH_MODEL,
      CASE WHEN ( PTL_HOLD.R_COMP_CODES.COMP_CD ) IN ('057','061') THEN 'Accident/Incident' ELSE 'Non-Accident/Incident' END,
      PTL_HOLD.R_COMP_CODES.COMP_CD,
      PTL_HOLD.R_COMP_CODES.COMP_DESC,
      PTL_HOLD.R_COMP_CODES.COMP_CD||' - '||PTL_HOLD.R_COMP_CODES.COMP_DESC,
      PTL_EDW.D_VEHICLE.UNIT_NUM,
      PTL_EDW_D_RO_LOCN.DIST_NUM || PTL_EDW_D_RO_LOCN.DIST_SUFX ||  PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM,
      PTL_EDW_D_RO_LOCN.DIST_NUM || PTL_EDW_D_RO_LOCN.DIST_SUFX || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM || PTL_EDW.F_RO_DETL.RO_SEQ_NUM
      PTL_EDW.F_RO_DETL.RO_SRC,
      PTL_EDW.F_RO_DETL.TOTAL_LABOR_HRS,
      PTL_EDW.F_RO_DETL.TOTAL_LABOR_COST,
      PTL_EDW.F_RO_DETL.OUT_COST,
      PTL_EDW.F_RO_DETL.PARTS_COST,
      PTL_EDW.F_RO_DETL.RO_COST,
      TO_CHAR(PTL_EDW_D_RO_LOCN.LOCN_KEY),
      PTL_EDW.F_RO_DETL.RO_NUM,
      PTL_EDW.F_RO_DETL.RO_SEQ_NUM,
      PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    FROM
      PTL_EDW.F_RO_DETL,
      PTL_EDW.D_CUSTOMER,
      PTL_EDW.D_LOCN,
      PTL_EDW.D_VEHICLE,
      PTL_HOLD.R_COMP_CODES,
      PTL_EDW.D_LOCN  PTL_EDW_D_RO_LOCN,
      PTL_EDW.D_LOCN  PTL_EDW_D_CHRG_LOCN,
      PTL_EDW.D_LOCN  CURRENT_VEH_LOCN,
      PTL_EDW.F_VEH_LOCN,
      PTL_EDW.D_VEHICLE  CURRENT_VEH
    WHERE
      ( PTL_EDW.F_RO_DETL.CUST_KEY=PTL_EDW.D_CUSTOMER.CUST_KEY  )
      AND  ( PTL_EDW.F_RO_DETL.LOCN_KEY=PTL_EDW.D_LOCN.LOCN_KEY  )
      AND  ( PTL_EDW.D_VEHICLE.VEH_KEY=PTL_EDW.F_RO_DETL.VEH_KEY  )
      AND  ( PTL_EDW_D_RO_LOCN.LOCN_KEY=PTL_EDW.F_RO_DETL.RO_LOCN_KEY  )
      AND  ( PTL_EDW.F_RO_DETL.CHRG_LOCN_KEY=PTL_EDW_D_CHRG_LOCN.LOCN_KEY  )
      AND  ( CURRENT_VEH_LOCN.LOCN_KEY=PTL_EDW.F_VEH_LOCN.LOCN_KEY  )
      AND  ( CURRENT_VEH.SCD_FLG='A'  )
      AND  ( CURRENT_VEH.CONTR_GRP='P'  )
      AND  ( CURRENT_VEH.CORP_CD=PTL_EDW.D_VEHICLE.CORP_CD and CURRENT_VEH.UNIT_NUM=PTL_EDW.D_VEHICLE.UNIT_NUM  )
      AND  ( CURRENT_VEH.VEH_KEY=PTL_EDW.F_VEH_LOCN.VEH_KEY  )
      AND  ( PTL_HOLD.R_COMP_CODES.COMP_CD=PTL_EDW.F_RO_DETL.COMP_CD  )
      AND 
       ( 'Accounting Month' = 'Accounting Month'  )
       AND
       ( '2500' = 'NO-MIN'
    OR           EXISTS(SELECT RO_TOTAL_COST.RO_LOCN_KEY, RO_TOTAL_COST.ORIGINAL_RO_NUM
    FROM      PTL_EDW.F_RO_DETL RO_TOTAL_COST
    WHERE
        ('I' = 'I'
        OR ('I' = 'E'
            AND RO_TOTAL_COST.RO_TYP  <>  'W'))
        AND RO_TOTAL_COST.RO_LOCN_KEY = PTL_EDW.F_RO_DETL.RO_LOCN_KEY
        AND RO_TOTAL_COST.ORIGINAL_RO_NUM = PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
        AND RO_TOTAL_COST.PARTITION_KEY BETWEEN 
           to_number(to_char(to_date('2011-JAN-01','YYYY-MON-DD'),'yyyymm')) 
           AND  to_number(to_char(to_date('2012-SEP-24','YYYY-MON-DD'),'yyyymm'))
    GROUP BY
        RO_TOTAL_COST.RO_LOCN_KEY,
        RO_TOTAL_COST.ORIGINAL_RO_NUM
    HAVING
    Sum(RO_TOTAL_COST.RO_COST) >= TO_NUMBER(translate('2500','NO-MIN',' ')))  )
       AND
       PTL_EDW_D_CHRG_LOCN.DIST_NUM_SUFX  IN  ('014810')
       AND
       ( (PTL_EDW.F_RO_DETL.PARTITION_KEY BETWEEN 
           to_number(to_char(to_date('2011-JAN-01','YYYY-MON-DD'),'yyyymm')) 
           AND  to_number(to_char(to_date('2012-SEP-24','YYYY-MON-DD'),'yyyymm'))
       AND
       ( 'I'  = 'I'
      OR
      ( 'I' = 'E'
         And ( ( PTL_EDW.F_RO_DETL.RO_TYP ) <> 'W'
       AND
       ( EXISTS(SELECT *  FROM PTL_HOLD.USER_GEO WHERE USERID='600125729' AND PTL_HOLD.USER_GEO.GEO IN (CURRENT_VEH_LOCN.CORP_CD, CURRENT_VEH_LOCN.REGN_NUM, CURRENT_VEH_LOCN.AREA_NUM, CURRENT_VEH_LOCN.RDIST_NUM, CURRENT_VEH_LOCN.DIST_NUM))  )
    );Thank you.

    For your own sanity, you should learn to format your code. For the sake of the forum members, you should preserve the formatting by using the \ tags. 
    I've done that for you here, and some other questions popped right out.  Look for my embedded comments near the bottomSELECT
    '../../opendoc/',
    '&hideSave=true&hideEdit=true&hideRefresh=true&hideUserPromptInput=true'
    'Data As Of:' ,
    'Run Date:' ,
    ptl_hold.get_stgextr_time('FACT_FPNA_RO'),
    'RO Date' ,
    PTL_EDW.F_RO_DETL.RO_TYP ,
    PTL_EDW.D_CUSTOMER.CUST_NUM ,
    (PTL_EDW.D_CUSTOMER.CUST_NUM )
    ||' - '
    ||( PTL_EDW.D_CUSTOMER.CUST_PRIME_NM),
    PTL_EDW.D_CUSTOMER.BILL_GRP ,
    CASE
    WHEN PTL_EDW.D_LOCN.CORP_CD='HPTL'
    THEN 'US'
    ELSE
    CASE
    WHEN PTL_EDW.D_LOCN.CORP_CD='2000'
    THEN 'CANADA'
    ELSE 'UNKNOWN'
    END
    END ,
    PTL_EDW.D_LOCN.REGN_NUM,
    PTL_EDW.D_LOCN.REGN_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.REGN_NM,
    PTL_EDW.D_LOCN.AREA_NUM ,
    PTL_EDW.D_LOCN.AREA_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.AREA_NM,
    PTL_EDW.D_LOCN.RDIST_NUM,
    PTL_EDW.D_LOCN.RDIST_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.RDIST_NM,
    PTL_EDW.D_LOCN.DIST_NUM ,
    PTL_EDW.D_LOCN.DIST_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.DIST_NM,
    CASE
    WHEN TRIM(PTL_EDW.D_VEHICLE.VEH_CAP_STAT) IN
    ('ACTIVE','ACCRUED')
    THEN 'Active'
    ELSE 'Inactive'
    END,
    DECODE(PTL_EDW.D_VEHICLE.CONTR_GRP, 'X' ,
    'NON-CONTRACT',PTL_EDW.D_VEHICLE.VEH_CAT),
    PTL_EDW.D_VEHICLE.VEH_UNIT_TYP ,
    PTL_EDW.D_VEHICLE.VEH_MODL_YR ,
    PTL_EDW.D_VEHICLE.VEH_MAKE ,
    PTL_EDW.D_VEHICLE.VEH_MODEL ,
    CASE
    WHEN
    PTL_HOLD.R_COMP_CODES.COMP_CD
    IN ('057','061')
    THEN 'Accident/Incident'
    ELSE 'Non-Accident/Incident'
    END ,
    PTL_HOLD.R_COMP_CODES.COMP_CD ,
    PTL_HOLD.R_COMP_CODES.COMP_DESC,
    PTL_HOLD.R_COMP_CODES.COMP_CD
    ||' - '
    ||PTL_HOLD.R_COMP_CODES.COMP_DESC,
    PTL_EDW.D_VEHICLE.UNIT_NUM ,
    PTL_EDW_D_RO_LOCN.DIST_NUM
    || PTL_EDW_D_RO_LOCN.DIST_SUFX
    || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM,
    PTL_EDW_D_RO_LOCN.DIST_NUM
    || PTL_EDW_D_RO_LOCN.DIST_SUFX
    || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    || PTL_EDW.F_RO_DETL.RO_SEQ_NUM ,
    PTL_EDW.F_RO_DETL.RO_SRC ,
    PTL_EDW.F_RO_DETL.TOTAL_LABOR_HRS ,
    PTL_EDW.F_RO_DETL.TOTAL_LABOR_COST ,
    PTL_EDW.F_RO_DETL.OUT_COST ,
    PTL_EDW.F_RO_DETL.PARTS_COST ,
    PTL_EDW.F_RO_DETL.RO_COST ,
    TO_CHAR(PTL_EDW_D_RO_LOCN.LOCN_KEY),
    PTL_EDW.F_RO_DETL.RO_NUM ,
    PTL_EDW.F_RO_DETL.RO_SEQ_NUM ,
    PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    FROM
    PTL_EDW.F_RO_DETL ,
    PTL_EDW.D_CUSTOMER ,
    PTL_EDW.D_LOCN ,
    PTL_EDW.D_VEHICLE ,
    PTL_HOLD.R_COMP_CODES ,
    PTL_EDW.D_LOCN PTL_EDW_D_RO_LOCN ,
    PTL_EDW.D_LOCN PTL_EDW_D_CHRG_LOCN,
    PTL_EDW.D_TIME ,
    PTL_EDW.D_LOCN CURRENT_VEH_LOCN ,
    PTL_EDW.F_VEH_LOCN ,
    PTL_EDW.D_VEHICLE CURRENT_VEH
    WHERE
    PTL_EDW.F_RO_DETL.CUST_KEY =
    PTL_EDW.D_CUSTOMER.CUST_KEY
    AND
    PTL_EDW.F_RO_DETL.LOCN_KEY =
    PTL_EDW.D_LOCN.LOCN_KEY
    AND
    PTL_EDW.D_TIME.TIME_KEY =
    PTL_EDW.F_RO_DETL.RO_TIME_KEY
    AND
    PTL_EDW.D_VEHICLE.VEH_KEY =
    PTL_EDW.F_RO_DETL.VEH_KEY
    AND
    PTL_EDW_D_RO_LOCN.LOCN_KEY =
    PTL_EDW.F_RO_DETL.RO_LOCN_KEY
    AND
    PTL_EDW.F_RO_DETL.CHRG_LOCN_KEY=
    PTL_EDW_D_CHRG_LOCN.LOCN_KEY
    AND
    CURRENT_VEH_LOCN.LOCN_KEY =
    PTL_EDW.F_VEH_LOCN.LOCN_KEY
    AND
    CURRENT_VEH.SCD_FLG ='A'
    AND
    CURRENT_VEH.CONTR_GRP ='P'
    AND
    CURRENT_VEH.CORP_CD =
    PTL_EDW.D_VEHICLE.CORP_CD
    AND CURRENT_VEH.UNIT_NUM =
    PTL_EDW.D_VEHICLE.UNIT_NUM
    AND
    CURRENT_VEH.VEH_KEY =
    PTL_EDW.F_VEH_LOCN.VEH_KEY
    AND
    PTL_HOLD.R_COMP_CODES.COMP_CD =
    PTL_EDW.F_RO_DETL.COMP_CD
    AND
    'Accounting Month' = 'RO Date'
    AND
    '2500' = 'NO-MIN'
    OR EXISTS
    SELECT
    RO_TOTAL_COST.RO_LOCN_KEY,
    RO_TOTAL_COST.ORIGINAL_RO_NUM
    FROM
    PTL_EDW.F_RO_DETL RO_TOTAL_COST,
    PTL_EDW.D_TIME DTIME
    WHERE
    'I' = 'I'
    OR
    'I' = 'E'
    AND RO_TOTAL_COST.RO_TYP 'W'
    AND RO_TOTAL_COST.RO_LOCN_KEY =
    PTL_EDW.F_RO_DETL.RO_LOCN_KEY
    AND RO_TOTAL_COST.ORIGINAL_RO_NUM =
    PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    AND RO_TOTAL_COST.RO_TIME_KEY =
    DTIME.TIME_KEY
    AND DTIME.CALENDAR_DT BETWEEN to_date(
    '2011-JAN-01') AND to_date(
    '2012-SEP-24')
    GROUP BY
    RO_TOTAL_COST.RO_LOCN_KEY,
    RO_TOTAL_COST.ORIGINAL_RO_NUM
    HAVING
    SUM(RO_TOTAL_COST.RO_COST) >= TO_NUMBER
    (TRANSLATE('2500','NO-MIN',' '))
    AND PTL_EDW_D_CHRG_LOCN.DIST_NUM_SUFX IN (
    '014810')
    AND
    PTL_EDW.D_TIME.CALENDAR_DT BETWEEN to_date(
    '2011-JAN-01') AND to_date('2012-SEP-24')
    AND
    'I' = 'I'
    OR
    'I' = 'E'
    AND
    PTL_EDW.F_RO_DETL.RO_TYP
    'W'
    AND
    EXISTS
    SELECT
    FROM
    PTL_HOLD.USER_GEO
    WHERE
    USERID ='600125729'
    AND PTL_HOLD.USER_GEO.GEO IN (
    CURRENT_VEH_LOCN.CORP_CD,
    CURRENT_VEH_LOCN.REGN_NUM,
    CURRENT_VEH_LOCN.AREA_NUM,
    CURRENT_VEH_LOCN.RDIST_NUM,
    CURRENT_VEH_LOCN.DIST_NUM)
    UNION
    SELECT
    '../../opendoc/',
    '&hideSave=true&hideEdit=true&hideRefresh=true&hideUserPromptInput=true'
    'Data As Of:' ,
    'Run Date:' ,
    ptl_hold.get_stgextr_time('FACT_FPNA_RO'),
    'Accounting Month' ,
    PTL_EDW.F_RO_DETL.RO_TYP ,
    PTL_EDW.D_CUSTOMER.CUST_NUM ,
    (PTL_EDW.D_CUSTOMER.CUST_NUM )
    ||' - '
    ||( PTL_EDW.D_CUSTOMER.CUST_PRIME_NM),
    PTL_EDW.D_CUSTOMER.BILL_GRP ,
    CASE
    WHEN PTL_EDW.D_LOCN.CORP_CD='HPTL'
    THEN 'US'
    ELSE
    CASE
    WHEN PTL_EDW.D_LOCN.CORP_CD='2000'
    THEN 'CANADA'
    ELSE 'UNKNOWN'
    END
    END ,
    PTL_EDW.D_LOCN.REGN_NUM,
    PTL_EDW.D_LOCN.REGN_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.REGN_NM,
    PTL_EDW.D_LOCN.AREA_NUM ,
    PTL_EDW.D_LOCN.AREA_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.AREA_NM,
    PTL_EDW.D_LOCN.RDIST_NUM,
    PTL_EDW.D_LOCN.RDIST_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.RDIST_NM,
    PTL_EDW.D_LOCN.DIST_NUM ,
    PTL_EDW.D_LOCN.DIST_NUM
    ||' - '
    ||PTL_EDW.D_LOCN.DIST_NM,
    CASE
    WHEN TRIM(PTL_EDW.D_VEHICLE.VEH_CAP_STAT) IN
    ('ACTIVE','ACCRUED')
    THEN 'Active'
    ELSE 'Inactive'
    END,
    DECODE(PTL_EDW.D_VEHICLE.CONTR_GRP, 'X' ,
    'NON-CONTRACT',PTL_EDW.D_VEHICLE.VEH_CAT),
    PTL_EDW.D_VEHICLE.VEH_UNIT_TYP ,
    PTL_EDW.D_VEHICLE.VEH_MODL_YR ,
    PTL_EDW.D_VEHICLE.VEH_MAKE ,
    PTL_EDW.D_VEHICLE.VEH_MODEL ,
    CASE
    WHEN
    PTL_HOLD.R_COMP_CODES.COMP_CD
    IN ('057','061')
    THEN 'Accident/Incident'
    ELSE 'Non-Accident/Incident'
    END ,
    PTL_HOLD.R_COMP_CODES.COMP_CD ,
    PTL_HOLD.R_COMP_CODES.COMP_DESC,
    PTL_HOLD.R_COMP_CODES.COMP_CD
    ||' - '
    ||PTL_HOLD.R_COMP_CODES.COMP_DESC,
    PTL_EDW.D_VEHICLE.UNIT_NUM ,
    PTL_EDW_D_RO_LOCN.DIST_NUM
    || PTL_EDW_D_RO_LOCN.DIST_SUFX
    || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM,
    PTL_EDW_D_RO_LOCN.DIST_NUM
    || PTL_EDW_D_RO_LOCN.DIST_SUFX
    || PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    || PTL_EDW.F_RO_DETL.RO_SEQ_NUM ,
    PTL_EDW.F_RO_DETL.RO_SRC ,
    PTL_EDW.F_RO_DETL.TOTAL_LABOR_HRS ,
    PTL_EDW.F_RO_DETL.TOTAL_LABOR_COST ,
    PTL_EDW.F_RO_DETL.OUT_COST ,
    PTL_EDW.F_RO_DETL.PARTS_COST ,
    PTL_EDW.F_RO_DETL.RO_COST ,
    TO_CHAR(PTL_EDW_D_RO_LOCN.LOCN_KEY),
    PTL_EDW.F_RO_DETL.RO_NUM ,
    PTL_EDW.F_RO_DETL.RO_SEQ_NUM ,
    PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    FROM
    PTL_EDW.F_RO_DETL ,
    PTL_EDW.D_CUSTOMER ,
    PTL_EDW.D_LOCN ,
    PTL_EDW.D_VEHICLE ,
    PTL_HOLD.R_COMP_CODES ,
    PTL_EDW.D_LOCN PTL_EDW_D_RO_LOCN ,
    PTL_EDW.D_LOCN PTL_EDW_D_CHRG_LOCN,
    PTL_EDW.D_LOCN CURRENT_VEH_LOCN ,
    PTL_EDW.F_VEH_LOCN ,
    PTL_EDW.D_VEHICLE CURRENT_VEH
    WHERE
    PTL_EDW.F_RO_DETL.CUST_KEY =
    PTL_EDW.D_CUSTOMER.CUST_KEY
    AND
    PTL_EDW.F_RO_DETL.LOCN_KEY =
    PTL_EDW.D_LOCN.LOCN_KEY
    AND
    PTL_EDW.D_VEHICLE.VEH_KEY =
    PTL_EDW.F_RO_DETL.VEH_KEY
    AND
    PTL_EDW_D_RO_LOCN.LOCN_KEY =
    PTL_EDW.F_RO_DETL.RO_LOCN_KEY
    AND
    PTL_EDW.F_RO_DETL.CHRG_LOCN_KEY=
    PTL_EDW_D_CHRG_LOCN.LOCN_KEY
    AND
    CURRENT_VEH_LOCN.LOCN_KEY =
    PTL_EDW.F_VEH_LOCN.LOCN_KEY
    AND
    CURRENT_VEH.SCD_FLG ='A'
    AND
    CURRENT_VEH.CONTR_GRP ='P'
    AND
    CURRENT_VEH.CORP_CD =
    PTL_EDW.D_VEHICLE.CORP_CD
    AND CURRENT_VEH.UNIT_NUM =
    PTL_EDW.D_VEHICLE.UNIT_NUM
    AND
    CURRENT_VEH.VEH_KEY =
    PTL_EDW.F_VEH_LOCN.VEH_KEY
    AND
    PTL_HOLD.R_COMP_CODES.COMP_CD =
    PTL_EDW.F_RO_DETL.COMP_CD
    AND
    'Accounting Month' = 'Accounting Month'
    AND
    '2500' = 'NO-MIN'
    OR EXISTS
    SELECT
    RO_TOTAL_COST.RO_LOCN_KEY,
    RO_TOTAL_COST.ORIGINAL_RO_NUM
    FROM
    PTL_EDW.F_RO_DETL RO_TOTAL_COST
    WHERE
    'I' = 'I'
    /* what's the point? A literal always equals itself. /*
    OR
    'I' = 'E'
    /* again, what's the point? This will never be true */
    AND RO_TOTAL_COST.RO_TYP 'W'
    AND RO_TOTAL_COST.RO_LOCN_KEY =
    PTL_EDW.F_RO_DETL.RO_LOCN_KEY
    AND RO_TOTAL_COST.ORIGINAL_RO_NUM =
    PTL_EDW.F_RO_DETL.ORIGINAL_RO_NUM
    AND RO_TOTAL_COST.PARTITION_KEY BETWEEN
    to_number(TO_CHAR(to_date('2011-JAN-01','YYYY-MON-DD'),'yyyymm')) AND
    to_number(TO_CHAR(to_date('2012-SEP-24','YYYY-MON-DD'),'yyyymm'))
    /* what is the data type of PARTITION_KEY? This manipulation strongly suggests that it should be DATE and isn't.
    GROUP BY
    RO_TOTAL_COST.RO_LOCN_KEY,
    RO_TOTAL_COST.ORIGINAL_RO_NUM
    HAVING
    SUM(RO_TOTAL_COST.RO_COST) >= TO_NUMBER(TRANSLATE('2500','NO-MIN',' '))
    AND PTL_EDW_D_CHRG_LOCN.DIST_NUM_SUFX IN (
    '014810')
    AND
    PTL_EDW.F_RO_DETL.PARTITION_KEY BETWEEN
    to_number(TO_CHAR(to_date('2011-JAN-01',
    'YYYY-MON-DD'),'yyyymm')) AND to_number(
    TO_CHAR(to_date('2012-SEP-24',
    'YYYY-MON-DD'),'yyyymm'))
    AND
    'I' = 'I'
    OR
    'I' = 'E'
    AND
    PTL_EDW.F_RO_DETL.RO_TYP
    'W'
    AND
    EXISTS
    SELECT
    FROM
    PTL_HOLD.USER_GEO
    WHERE
    USERID ='600125729'
    AND PTL_HOLD.USER_GEO.GEO IN (
    CURRENT_VEH_LOCN.CORP_CD,
    CURRENT_VEH_LOCN.REGN_NUM,
    CURRENT_VEH_LOCN.AREA_NUM,
    CURRENT_VEH_LOCN.RDIST_NUM,
    CURRENT_VEH_LOCN.DIST_NUM)

  • Ajax Autocomplete Tabular does not work using apex_item.text in SQL Query.

    Hello,
    Is it possible to use the search function which is used in, Dennis Kubicek example, ENAME topic Ajax Autocomplete Tabular
    in a sql query using apex_items?
    Query line :
    , apex_item.text(17,xp.part_nr,null,null,'onfocus="f_register(this);" autocomplete="off"') PART
    At first I followed the example by adding 'onfocus="f_register(this);" autocomplete="off" in the element attributes in the report field.
    This didn't work... so tried to add the it in the attirbutes parameter of the apex_item.
    But this still doesn't work. No errors are given, it does not respond.
    Could somebody please help me?
    Thx!
    Astrid

    Well, I'm trying to take this one step further, but I seem to be having some difficulty.
    I'm trying to make a Filter screen to create a dynamic where clause filter screen.
    This is a page I made with Popup LOVS, just to show you my goal (now trying to use autofilters)
    http://apex.oracle.com/pls/otn/f?p=29989:5
    I have a table on my system that tells you where the field is, and I'm using that to get the table (didn't want to change the javascript, so I pass in a static value).
    This is the javascript code I used
    <pre>
    <script language="JavaScript" type="text/javascript">
    function f_register(p_this,p_name)
    var p_registered = $x('P5_ITEM_ID').value;
         var p_this_name = $x(p_this).id;
    //alert(p_this_name);
    if (p_registered != p_this_name)
    register(p_this_name, "COSTING_M", p_name, "blue", "red");
    $x('P5_ITEM_ID').value = p_this_name;
    </script>
    </pre>
    This is my query
    <pre>
    select column_name || apex_item.hidden(1,column_name) Col_name,
    apex_item.SELECT_LIST_FROM_lov(2,'=','OPERATOR') OPERATOR,
    apex_item.text (3,
    NULL,
    20,
    200,
    'onfocus="f_register(this,''' || column_name || ''');" autocomplete="off"',
    'f3_' || '#ROWNUM#',
    NULL
    ) value,column_id
    from user_tab_cols
    where table_name = 'COSTING_M'
    ORDER BY ROWNUM
    </pre>
    and here is my on-demand process
    <pre>
    declare
    TYPE CurTyp IS REF CURSOR;
    v_row varchar2(4000);
    rec CurTyp;
    V_TABLENAME NKW.UTFIELD_M.TABLE_NAME%TYPE;
    begin
    BEGIN
    SELECT TABLENAME INTO V_TABLENAME
    FROM NKW.UTFIELD_M
    WHERE FIELD_NAME = :TF_SL_COLUMN;
    EXCEPTION WHEN NO_DATA_FOUND THEN RETURN; END;
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&amp;','&');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&lt;','<');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&gt;','>');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&quot;','"');
    owa_util.mime_header('text/xml', FALSE);
    htp.p('Cache-Control: no-cache');
    htp.p('Pragma: no-cache');
    owa_util.http_header_close;
    htp.prn('<rowset>');
    open rec for
    'select distinct ' || :TF_SL_COLUMN || ' ' ||
    'from NKW.' || V_TABLE_NAME || ' ' ||
    'where '||:TF_SL_COLUMN||' like :1||''%'' ' ||
    'and rownum < 100 ' ||
    'order by '||:TF_SL_COLUMN
    using :TF_SL_SEARCH;
    loop
    fetch rec into v_row;
    exit when rec%NOTFOUND;
    htp.prn('<row>' || htf.escape_sc(v_row) || '</row>');
    end loop;
    htp.prn('</rowset>');
    end;
    </PRE>
    I made some slight mods to make the table dynamic from my source table (this is to grab master files when they exist and not to when they don't).
    I get my select list, but it's blank on all fields, any suggestions?
    thanks,
    Scott

  • Sql Query(Updateable Report) with pagination

    Hi,
    We're on APEX 3.2 I have a question on Sql Query(Updateable Report) and pagination. I have an updateable report which we have set to show 20 rows. When the userwhi has more than 20 rows enters the data and clicks next the data disappears. I have been reviewing other posts, but haven't come to a clear conclusion on how to prevent this from happening. I have been trying to use javascript to show a save popup when clicking 'Next' Any help is appreciated.
    Thanks,
    Joe

    any ideas?

Maybe you are looking for

  • Camera Raw update for CS2

    Will Adobe be supporting camera raw for CS2 any more? I got CS2 last year and I can't afford to update to CS3. CS2 camera raw 3.7 does not read Canon D40 raw file.

  • Font Different in InDesign & Pages

    Hello.  I'm new to InDesign and this forum, but I'm having a problem and thought somebody might be able to help. The problem is with a book I've laid out and am in the process of printing in InDesign CS4 (for Mac)...The typeface (Baskerville) looks d

  • ZVM - Classical Mu

    Hi all?I suspect this is a problem not many people will have, but I am finding the cataloguing/menu system on the ZVM?frustrating for storing classical music. The most logical way of cataloguing classical music is under Composer, then Work, then Arti

  • JTable cell add Image

    hi, pls let me know how to add image in JTable particular cell. I am trying to add image in a particular column each row at runtime ( developing database application), those images are in remote location and also directory files. I am trying to use b

  • Can I use Fireworks CS4 with Photoshop Extended CS3?

    I plan to upgrade to the Master Collection later this year, if business keeps going as well as it has, but I need a feature of FW now, namely the more-excellent PNG-8 saving capabilities of FW, based on what I've read on the web. Will I need to backs