Forcing one particular query to be rewritten to custom SQL

Hi everyone,
MapBuilder produces Queries that look like this
SELECT ROWID, GEOM, 'C.AT_1410_GW_ROAD', null, 'null', -1, 'rule#0'
FROM MYTABLE
WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 31468, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh)), 'querytype=WINDOW') = 'TRUE' AND (areatype = 'ROAD') UNION ALL
SELECT ROWID, GEOM, 'C.AT_1410_GW_RIVER', null, 'null', -1, 'rule#1'
FROM MYTABLE
WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 31468, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh)), 'querytype=WINDOW') = 'TRUE' AND (areatype = 'RIVER') UNION ALL
SELECT ROWID, GEOM, 'C.AT_1410_GW_FOREST', null, 'null', -1, 'rule#2'
FROM MYTABLE
WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 31468, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh)), 'querytype=WINDOW') = 'TRUE' AND (areatype = 'FOREST') UNION ALL
...Where geom is the sdo_geometry to be drawn and areatype determines the type of which a polygon is (for example a river or forest). As you can see there multiple queries to the same table, union-all'd together. This is unnecessary. It causes a lot of expensive spatial queries when it really only serves to create the literal strings like 'C.AT_1410_GW_ROAD' that MapBuilder needs to distinguish for example forests and rivers.
I was thinking of making a materialized view that contains the literals 'C.AT_1410_GW_ROAD' and so on which MapBuilder/Viewer needs, plus the geometries. That would allow to get the same result in just one simple
SELECT rowid, geom, layertype, null, null, rule
FROM mymatview
WHERE MDSYS.SDO_ORDINATE_ARRAY(:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh)), 'querytype=WINDOW') = 'TRUE'Where layertype would contain the 'C.AT_1410_GW_ROAD' and rule the 'rule#0'. Basically the result of the huge union-all-query above, without the bounding box, in an MV. That part works, but now I need Oracle to actually use this MV instead of running the query that MapBuilder sends. How do I do this? I don't think Oracle can realize that the MV has a column containing the literals MapBuilder sends in its SELECT. Basically I need a "query search and replace" in Oracle 11g, or a "custom query rewrite" if that's what you want to call it.
Kind of hard to explain, I hope it is understandable, any help would be very very much appreciated,
Christian
Edited by: Christian Menke on 02.09.2010 07:26
Edited by: Christian Menke on 02.09.2010 07:27

Use the case statement to determine two of the columns, which means you can remove the UNION ALL since there is no difference in the WHERE clause apart from the areatype;
something like this:
SELECT ROWID
      ,GEOM                 as Geom
      ,null                 as Null_value
      ,'null'               as Literal_Null_String
      ,case
          when area_type = 'ROAD' then
            'C.AT_1410_GW_ROAD'
          when area_type = 'RIVER' then
            'C.AT_1410_GW_RIVER'
          when area_type = 'FOREST' then
            'C.AT_1410_GW_FOREST'
       end as location_literal
      ,-1                   as Negative_One
      ,case
          when area_type = 'ROAD' then
            'rule#0'
          when area_type = 'RIVER' then
            'rule#1'
          when area_type = 'FOREST' then
            'rule#2'
       end as rule_string
FROM  MYTABLE
WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 31468, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh)), 'querytype=WINDOW') = 'TRUE'

Similar Messages

  • Query not executing for one particular value

    Hi
    I have query on multi provider. and this multi provider is combination of Info objects only but not any ODS or cubes. I have one key figure in this multi provider.while executing the query i need to give input for variabl which has 7 different values. Query is executing fine for 6 values but not for one particular value.
    query executed in listcube transaction and it is executed fine here for the same selection. then what might be the reason?
    Please advise as soon as possible.
    Thanks

    Hi Kiran,
    are you maintaining any filters in the query? or is there any logic in the exit for this variable.
    regards.

  • Select * query is slow on one particular table

    Hi ,
    I am using forms and reports of AppServer 10g,one particular form accesing one table ...The select * from statement on that table is slow.Any amendmends to be taken care of at the tablespace level??
    Help needed urgent...
    Regards,
    Ashlee

    Hi,
    This is a general type of question. please be specific. Golden Thumb rule is that don't use '*", instead use the column names. Analyze the table and take a execution plan and check for index usage .
    Please give the problem statement also so that we can help you.

  • SharePoint Sandbox Custom Search in one particular folder

    Hello:
    Could someone please guide me or refer me some useful like for the following:
    1) User will have the option to search some files
    2) Search criteria are meta tag for that/those file(s)
    - so there will be some text box or drop down to select some meta data
    3) When user click the search button, a search should be performed only in one particular folder inside the SPSite
    (i.e "Documents/UserGuest/Contact")
    How can this be achieved with sandbox solution. Does SPServices would help anyway in this case? 

    function searchList(folderName) {
        var nURL = "/_vti_bin/lists.asmx";
        var soapEnv = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
                                 <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
                                  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
                                  xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
                                  <soap:Body> \
                                  <GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">
                                  <listName>{YourList}</listName> \
                                  <viewFields></viewFields> \
                                  <query><Query><Where><Contains><FieldRef Name='FileRef'
    /><Value Type='Text'>"+folderName+"</Where></Query></query> \
                                  <queryOptions><QueryOptions><ViewAttributes Scope='Recursive'/></QueryOptions></queryOptions>
                                  </GetListItems> \
                                      </soap:Body> \
                                  </soap:Envelope>";
        $.ajax({
            url: nURL,
            beforeSend: function(xhr) {
                xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems");
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResults,
            contentType: "text/xml; charset=utf-8"
    function processResults(xData, status)
       result = $(xData.responseText).find("z\\:row, row");
        if (result == undefined) {
            result = $(xData.responseXML).find("z\\:row, row");
        $(result).each(function(i, data) {
        //Magic   
    Brandon James SharePoint Developer/Administrator

  • ODS not picking one particular master data record

    Hi All,
    Problem is when we run a query on ODS,it is not displaying the one particular data records.Then we check the ods that particular record values are not available,but it is in master data tables.
    My question is what will be the reason for this.we are using Generic extraction.
    thanks

    Hi,
    Check for primary keys of master data tables and key fields of ODS . I think there should be mismatch which is why some records are getting overwritten.
    Also in the ods request check number of records transfered and number of records added.
    ODS key fields should be exactly same as Primary key of master data table otherwise there are chances of loosing data.
    Hope that helps.
    Regards
    Mr Kapadia
    Assigning points is the way to say thanks in SDN.

  • Not able to see that particular query which is executed from application

    Hi Friends,
    I have one application which is executing a number of queries in the current session. I want to know which query is taking how much time?
    So I have executed following query in Toad for this purpose, but this is giving details of those queries only which are executed from either Toad or SQL developer.
    I am not able to see that particular query which is executed from application. Please suggest me if I am missing something.
    select ss.schemaname,ss.machine,ss.program,ss.logon_time,ss.sql_exec_start,ss.wait_time,
    sa.first_load_time,sa.application_wait_time,sa.plsql_exec_time,sa.cpu_time,sa.elapsed_time,sa.sql_fulltext
    from v$session ss, v$sqlarea sa
    where sa.hash_value=ss.sql_hash_value
    order by sa.first_load_time desc;
    Oracle Version - Release 11.2.0.1.0 Production
    Toad Version - 9.5.0.31
    Regards,
    Sachin

    Dear Friends,
    is there any option for this through Oracle Enterprise Manager 11g?
    Actually I have done little bit research on EM console and go through SQL Monitoring Executions page but did not get the particular query details executed through the application.
    I have also checked the link - AWR Baseline but not get any result.
    As I am new in database administration activities, Please help me regarding this. You can also suggest me other solution except Oracle EM console.
    Thanks.
    Sachin Jaiswal

  • Find the database in which a particular query is executing

    Hi,
    Is there a way to find out the name of the database of a particular query which is running currently.
    I ran the below query to find out the long running queries in sql
    SELECT DISTINCT TOP 10
    t.TEXT QueryName,s.creation_time,db_name(t.dbid)as Database_Name,
    s.execution_count AS ExecutionCount,
    s.max_elapsed_time AS MaxElapsedTime,
    ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
    s.creation_time AS LogCreatedOn,
    ISNULL(s.execution_count/nullif(DATEDIFF(s, s.creation_time, GETDATE()),0) , 0) AS FrequencyPerSec
    FROM sys.dm_exec_query_stats s
    CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
    ORDER BY
    s.max_elapsed_time DESC
    I am getting database_name a s null for few queries. Can any one elaborate how this can happen?
    Thanks,
    Preetha

    Thats because its a prepared or adhoc statement
    Try taking db_id from dm_exec_query_stats
    ie like below
    ,db_name(s.dbid)as Database_Name
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • MS Word 2008 keeps crashing on one particular file - HELP!

    Hello all..
    just trying to help out a friend.. I am a PC person myself (please dont shoot me! :P )
    when I open just one particular .doc file in MS Word 2008, about ~10 secs later it freezes up with that funky lil rainbow wheel.. anyone know what the problem might be? I ran MS update on it & installed but it didnt help
    its just the one file & I have nooo idea!

    I'm having the same problem. When I open a .docx file created in Word 2007 for Windows in my new Word 2008 for Mac (updated to the latest edition), I can work for a few minutes, then the spinning wheel pops up and the app freezes. I then have to force-quit it. I have tried this with several files, and the problem reappears each time. The files do not use anything special except for having comments and marked changes in the text. (I work as an academic economist and write papers with colleagues in files from Word 2007 for Windows, and we have to use comments and marked changes when working on joint papers.) Any ideas about how to solve this problem would be greatly appreciated.

  • Why does one particular website not open on my ipad*,

    Why does one particular website not open on my ipad, when it alwasys did, but the same website is available upstairs on my PC, I'm using the same remote connection but for some reason it doesn't want to open.  I;ve tried refreshing etc... but nothing works.
    When I bring the ipad to work the website in question opens OK.
    Any suggestions??
    Thanks

    Try updating via iTune (computer)

  • I transfered my purchases from my iphone to my mac. All transfers completed. One particular album shows up on the phone but the songs are greyed out and don't play. Itunes shows album as purchased but album is not in my Mac library.

    I transfered my purchases from my iphone to my mac. All transfers completed. One particular album shows up on the phone but the songs are greyed out and don't play. Itunes store shows album as purchased but album does not show up in my Mac library. How can I retrieve the album.

    So i've found the answer to this by clicking on every menu and setting in the itunes store. It turns out some purchases in the cloud can be hidden probably as the result of an interrupted transfer/sync/backup or a network outage. To unhide purchases 'greyed out ' items , go to the Itunes store (on the PC) click on your account name and select view account. (you'll be prompted for your itunes password) once you are in scroll down to the purchase history section. there should be an option for hidden purchases. click through and click on unhide purchases, redownloadble purchases. any hidden purchases will then show up. click on unhide to reactivate and download. This may only work for purchases in the cloud.
    hope others find this useful.

  • When I open one particular folder to play the games in it the pointer turns into a pinwheel and I cant open the game or close the folder unless I shut down my computer.  Never happened before and does not happen with any other folder on the desktop.

    why does pointer become a pinwheel when I open one particular folder only and prevent me from opening the apps in it and then keep me from closing the folder unless I shut down the computer completely.  I can open all other folders on the desk top without a problem.  My game folder never gave me trouble before.

    Try this. Open one of your files. The window that contains your picture is named at the top. Command click on the name and you'll see the entire path starting with its name and then moving to the folder, the folder it is contained in, etc all the way to down to the hard drive volume name. This should tell you where to find the folder.

  • I have sent a file to the trash bin. When I come to empty the trash bin everything goes out except this one particular file and I get a note saying the file is 'in use' but it is not. How can I delete this file from trash?

    I have a Macbook Pro with OS X Lion 10.7.2. I have sent a work file to the trash bin along with many other files. When I empty the trash this one particular file remains and I get a message that this file is still in use. I have tried returning the file to my documents, opening it, closing it and then sending it to trash and again I try to empty trash but the same message comes up - Q - How can I trash this file permanently?

    First just try logging out and back in.  Whatever is holding on to it may not be running after the logout thus freeing it so you can trash it after logging back in.
    You might also try Trash It!
    Lastly, look at the following for suggestions:
    The X Lab: Solving Trash Problems

  • Network problem with one particular iMac in a home network

    I want to report a problem involving one particular iMac (2008 Al 24").
    On my home network (Apple Airport Extreme and Express extensions, about five Macs and couple of iDevices), all other Macs can see and connect to each other as well as printing to the networked Brother printer without problem.
    However, on one particular iMac, I can see all other Macs, can set Brother printer as default with green dot next to it in Print Preference Pane, but I can not connect to other macs, nor print to the printer. Meanwhile, the iMac can get on the internet without any problem. I checked Share Preference Pane and all settings are same as other macs.
    The iMac used to work flawlessly until recently, and I first noticed the problem because I could not print, getting a message the printer can not be found (and the dots turn yellow for a while then went back to normal green). Then, I found neither the iMac, nor other macs on the network can connect to each other, even though I can see all of them in Finder.
    I opened Apple Remote Network on my own mac, and I can see and connect all other shared macs, but this iMac's status showed not online, even though the IP adress is valid. As a results, no other macs can connect to the iMac, either. It seems to be a problem with the intranet only, not internet.
    One more thing, about a month ago, the iMac popped out a warning about network name, saying the old name was in use (conflict) in the network, so I have to change it in Share Pane. Not sure if this is related to the intranet problem.
    Reboot and repaired permission several times, no change. Hate to reinstall everything. Any help would be greatly appreciated.

    Another update:
    For unknown reason, my iMac was suddenly back onto the home "intranet". It can be accessed by my MacBook Air through Finder Connect, and can also be seen by Apple Remote Desktop.
    However, printing is still a problem while other macs have no problem printing to the same printer. Whenever I send a print task, either Word document, or other programs such as GraphicConverter image, the iMac tried to connect to the default printer, but failed, and wanted to try again in 30 seconds 9and continued to fail). Meanwhile, the green dot next to the printer selection turned to yellow in Preference Pane. But as soon as I cancel the print job, the printer status went back to normal green.
    The printer is a Brother color laser HL-4070CDW, connected through wireless (g only), with it own DHCP but specific IP address. I printed out a setting for the printer and all looks normal, and all other macs can print to it without problem. Other macs can also get access to the printer profile, and check inks copy counts, etc, but the iMac cannot.
    Only thing changed since last post was a new update for Apple Airport firmware (to 7.5.2 I think). So my problem is still half solved: can connect to other macs on the same network, but still not be able to print.

  • How to use different filter in 3 sheets of one BI query?

    I have one BI query. I want to have 3 queries in one excel file, but there will be different company code selected in those 3 queries. Once I refresh this excel file, then I can get 3 different results in the 3 different sheets of the excel file. Could anyone tell me how to make it?
    Thanks,
    Sudree.

    Hi,
    this is possible as already suggested earlier here. Create three data providers based on the same query and ensure that the option "restore initial query view on refresh" is not set. Furthermore, if the query contains variables, uncheck the workbook property on the variables tab to display duplicate variables only once.
    Now you can specify individual filter values for each query and save the workbook. On opening/refreshing the workbook the specified filter values should still be valid.
    You can also watch BEx Analyzer doing this. open any query with one characteristic that does not have too much values. Take this characteristic out of the drilldown, right click it in the navigation pane and choose "Add Drilldown according to <name> in new worksheets". Now BEx Analyzer creates a copy of the data provider based on the same query and sets a filter value on this query.
    Regards
    Matthias

  • I am getting dump error while running one report in one select query

    Hi,
    While running a report program, I am getting a dump error in one select query. So could you please correct the select query so that I can't face the dump error.
    SELECT vbeln parvw kunnr INTO CORRESPONDING FIELDS OF TABLE l_t_vbpa
      FROM vbpa
      FOR ALL ENTRIES IN l_t_backorder_item
      WHERE vbeln = l_t_backorder_item-vbeln AND
      ( ( parvw = c_we AND kunnr IN rng_shipto ) OR  ( parvw = c_ag AND
      kunnr IN rng_soldto ) ) .
    <removed by moderator>
    Best Regards,
    BDP
    Edited by: Thomas Zloch on Apr 30, 2010 12:31 PM

    Hi Bansidhar,
    It would be helpful if you could tell what type of dump it is.
    If it is a timeout you should check whether l_t_backorder_item is empty - in this case ALL document numbers are selected. f you get the timeout with a populated table consider converting the l_t_backorder_item table into one ore more ranges tables - the select with ranges tables is way quicker than 'for all entries'. But take care the ranges table has not to many entries - the SAP SQL converter puts this into one huge SQL statement and this might become too big to be handled by the database (depends on the actual underlying database).
    I would also consider splitting the SELECT into two (2nd one with 'appending into table') to make the code easier to understand It also helps the database system determining a strategy for the select.
    Regards,
    Gerd Rother

Maybe you are looking for

  • UPGRADING FROM 10.3.9

    I have iMac G4 800Mhz running 10.3.9 and would like to get to 10.5 so I can use iLife '09. I just bought a new Nikon camera which takes raw pictures (NEF format) that my current version of iPhoto in iLife '06 does not recognize, among other DVD relat

  • Query Drilldown problem

    Hi All, We are working on BI7.0 and facing a weird problem. As in BW 3.5, when i execute a query on the web and utilize change drilldown feature for characterstics in the rows to "horizontal" option, the characteristic jumps from rows to columns in t

  • Acrobat X vs. Acrobat Pro Extended

    Hi, Currently I have Adobe Acrobat Pro Extended 9.0 installed in my machine and I am a heavy LiveCycle Designer user. I was wondering if I could install Acrobat X without uninstalling the current version in my machine (Acrobat Pro Extended). Also, if

  • Created new Database in OTM

    Hello, I've created new database in OTM application. After a hard time, it was succussfully done. unfortunately, one issue is still pending and am not able to re-solve that. once i logged into the application, i got an error 'syntax error - ...otm/tr

  • Installing Oracle Apps 11i (11.5.7) on W2K Server, Bootstrap Failed

    Installing Oracle Apps 11i (11.5.7) on W2K Server: System Configuration: Oracle 11i E-Business Suite 11.5.7 Windows 2000 Server with Service Pack 2 Microsoft VC++ Installed from Microsoft Visual Studio 6.0 MKS tool kit for Developers 8.1 Gnu -> make-