WITH CLAUSE in SPARQL - Running SPARQL query using JENA

Hi,
Can anybody help me how to use WITH Clause in SPARQL. Below is my Query. I am using Jena 2.6.3 to Run my Query.
"PREFIX assc: <http://www./.../> " +
"WITH " +
     "( " +
                    " select ?associate" +
                    " where {?associate assc:belongsTo <http://www./../Relationship>} " +
                    " AS :associateList" +
     " )" +
               " select ?client ?associate " +
               " where { ?client assc:Sees ?associate . ?associate assc:belongsTo <http://www./../Relationship> ." +
               " :associateList(?associate) }" ;
Thanks and Regards,
Manish Hardasmalani

Hi Zhe,
Actually i am looking for example say,
I have a select query where i get id , name and mark this output as a relationshipName
And then use this relationshipName as a function in second select query.
Example:
WITH
SELECT ... WHERE {...} AS relationName
SELECT ... FROM <graph> where {... :relationName(...) [FILTER(...)]}
In the above pseudo code relationName is populated in first select and used in second select. I am searching something similar to this.

Similar Messages

  • Sparql query using variable paths

    Hi,
    I have a following graph in Oracle that I like to query using Jena 2.6.4 and OracleJenaAdaptor 11.2.0.3
    ind:123 :hasA ind:124
    ind:124 :hasB ind:125
    ind:125 :hasC ind:126
    ind:123 :hasD ind:127
    Is there a way to construct a sparql query to return all ind: without "hard-conding" the full property name? Something in these lines (note, this query doesn't really work).
    select *
    where { ind:123 (:has*)+ ?x }
    Thanks.

    :hasA rdf:type owl:ObjectProperty ;
    rdfs:subPropertyOf :hasRelation .
    :hasB rdf:type owl:ObjectProperty ;
    rdfs:subPropertyOf :hasRelation .
    :hasC rdf:type owl:ObjectProperty ;
    rdfs:subPropertyOf :hasRelation .
    :hasD rdf:type owl:ObjectProperty ;
    rdfs:subPropertyOf :hasRelation .
    String q1 = "SELECT ?x, ?y
    where {?x (:hasRelation)+ ?y} ";
    Stirng q2 = "SELECT ?x, ?y
    where {?x :hasRelation ?y} ";
    Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
    Attachment attachment = Attachment.createInstance(new String[]{"my_asset","my_model"},
    new String[]{"OWLPRIME"}, InferenceMaintenanceMode.UPDATE_WHEN_COMMIT, QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);
    GraphOracleSem graph = new GraphOracleSem(oracle, "vm_model", attachment);
    ModelOracleSem inferencedModel = new ModelOracleSem(graph);
    Query query = QueryFactory.create(q1);
    Edited by: a1239090 on Aug 15, 2012 4:54 PM

  • SPARQL query through Jena adaptor not work when string literals used

    Hi,
    When I executed the following SPARQL query through Oracle Jena adaptor:
    SELECT ?personHasFirstName WHERE
    {?personHasFirstName foaf:firstName ?name . }
    I got the expected results.
    However it won't return anything when I narrowed the query to match a particular name like below:
    SELECT ?personHasFirstName WHERE
    {?personHasFirstName foaf:firstName \"Julie\" . }
    I also tried the Filter approach:
    SELECT ?personHasFirstName WHERE {?personHasFirstName foaf:firstName ?name . FILTER (?name =\"Julie\") }
    It still doesn't return any results.
    I saw from the release notes about the bug dealing with "\". My guess is that the above behavior is caused by that bug. What is the suggested way to walk-around this? Thanks,
    Weihua

    Could you please try this? It works as expected on my machine.
    GraphOracleSem graph = new GraphOracleSem( oracle, modelName);
    ModelOracleSem model = new ModelOracleSem(graph);
    Node sub = Node.createURI("http://test.com/employee123");
    Node pre = Node.createURI("http://xmlns.com/foaf/0.1/firstName");
    Node obj = Node.createLiteral("Julie");
    graph.add(Triple.create(sub, pre, obj));
    String queryString =
    " PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
    "SELECT ?person WHERE { ?person foaf:firstName \"Julie\" . } ";
    QueryExecution qexec = QueryExecutionFactory.create(
    QueryFactory.create(queryString), model);
    try {
    ResultSet results = qexec.execSelect();
    while (results.hasNext()) {
    QuerySolution soln = results.nextSolution();
    psOut.println("runQuery: soln " + soln);
    finally {
    if (qexec != null)
    qexec.close();
    output snippet:
    runQuery: soln ( ?person = <http://test.com/employee123> )

  • Problem running Portal query using precalculated data

    We are trying to use precalcualated data to run queries in our portal and are running into some issues.
    We have a query with an attached template which uses the cost center group parameter (ksg) to show particular cost centers from a hierarchy created in RSH1.  The query works fine from the BW menu and shows only those cost centers which it should, based on the hierarchy.
    In the Reporting Agent Setting of Administrators workbench (RSA1) we created a reporting agent setting to precalcuate the data and scheduled it to run every couple of hours.
    We have an ivew on our portal which runs the query with the template.  If we add a data_mode parameter and set it to stored, the query seems to use the precalculated data but it seems to ignore the users ksg parameter setting and shows the entire hierarchy of cost centers on the first screen.  If we scroll down to the bottom of the screen and use the down arrow to get the next set of rows, the next screen show the data for only our cost centers based on our ksg parameter setting. 
    However, if we change the data_mode parameter setting to u2018newu2019 the query works as it should and we see the correct cost centers, and not all the ones in the hierarchy so it is going to the OLAP engine for new data and not using the precalculated data.
    We have tried various combination of settings on the Parameter tab of the Change Reporting Agent Setting screen.  We have specified the query name in the Cntrl Query screen.  If we switch from u2018no filteringu2019 to u2018explicity through Query Rsltu2019 the process chain errors out and will not precalc the data.
    Can anyone help?  Thanks.

    Issue SET DEFINE OFF in SQL-Plus before your statement runs.

  • Where Clause messing up results of Query using BC4J

    Hello all.
    I am developing a hand-coded JSP application that uses BC4Js and is deployed to a 9iAS on a SPARC box.
    I'm not sure what has been happening, but the results that are printed out to the screen are vastly different from the SQL results. I've gone as far as printing the Query that is executed onto the results page and have run it on SQL*Plus -- the query works on Plus, but displays no rows on the screen.
    I have a pretty complex where clause, I compare around four columns, and while developing I noticed that the sequencing of the columns greatly affected the output.
    Is this the same case?
    Thanks for the help!

    Additional Information:
    One of the Where parameters is a date range, when I made the range narrow I was able to get the right number of rows for the result set (34 in all). But when I widened it to the day right after that, I got no results.
    I'm stumped.

  • Why would my i7 Quad-core with 20 GB RAM run slowly when using PE12 for Mac

    Hi, I am evaluating the trial version of PSE 12 for Mac but it is so slow. Are there any good reasons for this as all other programs run fine.

    I don't know if you can do this with the trial, but try going to editor>help>updates and running the update to 12.1. It greatly improves performance on the mac.

  • Maximum Size of bind variables/model names in a SPARQL query

    I was wondering what the maximum field size is for a bind variable (?'' being used in the subject or object within a triple) in a SPARQL query using the Jena Adapter for Oracle? The reason for this is that I keep getting Oracle exception (ORA-00972: identifier is too long) when executing queries.
    The other question dealt with the max size of the model names? Is there anyway to increase this length by extending certain classes within the Jena Adapter for Oracle?
    Thanks,
    Rahul

    Hi,
    For model names, because we use model names together with some suffixes to create namespace tables, application tables, and indexes, the length
    has to be shorter than 30 bytes - 11 bytes = 19 bytes.
    Note that 30 bytes limit is imposed by Oracle database. You cannot create a table with a name longer than 30 bytes.
    11 bytes is the maximum suffix length imposed by Jena Adapter. We are considering to reduce it to 4 for the next Jena Adapter release.
    For variable names, because we translate SPARQL to SQL queries (and variable name to column alias), there is the same 30 bytes limit.
    Note that there are suffixes for variable names as well. For example, $RDFVID, $RDFLTYP, ... These suffixes are used internally.
    Some simple tests for illustration purpose.
    SQL> create table a23456789012345678901234567890(i int);
    Table created.
    SQL> create table a234567890123456789012345678901(i int);
    create table a234567890123456789012345678901(i int)
    ERROR at line 1:
    ORA-00972: identifier is too long
    -- Assume table X has a column I
    SQL> select i as "v23456789012345678901234567890" from x;
    no rows selected
    SQL> select i as "v234567890123456789012345678901" from x;
    select i as "v234567890123456789012345678901" from x
    ERROR at line 1:
    ORA-00972: identifier is too long
    Hope it helps,
    Zhe Wu

  • ORA-32036 unsupported case for inlining of query name in WITH clause

    I have a query with a WITH clause. In the WITH clause I am using the TABLE command to pull multiple records from a PL/SQL function in the FROM clause:
    WITH select_a AS
    (select x.col1,
    x.col2
    from A,
    TABLE(schema1.function1) x
    where ...)
    select ...
    from ...;
    The query is returning 32036 oracle error. Any thoughts on why I get this error? Is it valid to use the TABLE command with a function in the WITH clause?

    Is it valid to use the TABLE command with a function in the WITH clause?Something else must be going on: Even on my old 9i I can use WITH together with TABLE:
    SQL> select * from v$version where rownum = 1
    BANNER                                                         
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    1 row selected.
    SQL> create or replace function f1 (deptno int) return sys.dbms_debug_vc2coll
    as
    begin
    return sys.dbms_debug_vc2coll(deptno);
    end;
    Function created.
    SQL> with t as (
    select dept.* from dept, table (f1(deptno)) where column_value = deptno
    select * from t
        DEPTNO DNAME          LOC         
            10 ACCOUNTING     NEW YORK    
            20 RESEARCH       DALLAS      
            30 SALES          CHICAGO     
            40 OPERATIONS     BOSTON      
    4 rows selected.

  • ORA-32031: illegal reference of a query name in WITH clause

    Oracle tutorial : http://www.oracle.com/technology/pub/articles/hartley-recursive.html#4
    When Executing this Query 6: Using a Recursive WITH Clause
    WITH C (CNO, PCNO, CNAME) AS
    (SELECT CNO, PCNO, CNAME -- initialization subquery
    FROM COURSEX
    WHERE CNO = 'C22' -- seed
    UNION ALL
    SELECT X.CNO, X.PCNO, X.CNAME -- recursive subquery
    FROM C, COURSEX X
    WHERE C.PCNO = X.CNO)
    SELECT CNO, PCNO, CNAME
    FROM C;
    Error: ORA-32031: illegal reference of a query name in WITH clause
    kindly suggest what need to do in case of recursion using subquery

    SCOTT@orcl> ed
    Wrote file afiedt.buf
      1  with c as
      2  (
      3  select empno,ename from emp
      4  where deptno=20
      5  union all
      6  select c.empno,c.ename from emp c
      7  where c.deptno=30
      8  )
      9* select * from c
    SCOTT@orcl> /
         EMPNO ENAME
          7566 xx
          7788 xx
          7876 xx
          7902 xx
          7499 xx
          7521 xx
          7654 xx
          7698 xx
          7844 xx
          7900 xx
    10 rows selected.
    SCOTT@orcl> ed
    Wrote file afiedt.buf
      1  with emp as
      2  (
      3  select empno,ename from emp
      4  where deptno=20
      5  union all
      6  select c.empno,c.ename from emp c
      7  where c.deptno=30
      8  )
      9* select * from emp
    SCOTT@orcl> /
    select empno,ename from emp
    ERROR at line 3:
    ORA-32031: illegal reference of a query name in WITH clause
    SCOTT@orcl>You can not use the same table name alongwith WITH clause's cursor name. See as above if i says with C as... its works; but if i says with emp as... it returned ora-32031, because it is the name of table.
    HTH
    Girish Sharma

  • WITH clause in CURSOR

    Hi,
    I was going through some docs on using WITH clause in curosr...but coulcn't understand.
    I was going through existing code for customization, that has 'WITH' clause.
    I'm trying to understand below piece of code.
    could you let me know what the below code is about..
      CURSOR CUR_CRK
      IS
      WITH PTLPM_WITH AS
        (SELECT
          /*+ INDEX(P_TR_LOAN_PAST_MONTHLY PK_P_TR_LOAN_PAST_MONTHLY) */
        FROM INF.P_TR_LOAN_PAST_MONTHLY
        WHERE POST_DATE    =P_POST_DATE
        AND TREND_GROUP_ID = 'M'
        AND APPL_ID       IN ('FL','LN')
      UIGL_INF_WITH AS
      (SELECT * FROM INF.U_IM_GALL_LOAN
      XHCC_INF_WITH as
      (SELECT * FROM DWC.XREF_HIER_COST_CENTER_11SEP12 --INF.XREF_HIER_COST_CENTER
      )Thanks.

    Perhaps a simple example will make it clear...
    SQL> ed
    Wrote file afiedt.buf
      1  select e.empno, e.ename, d.dname
      2  from        (select * from emp) e
      3         join (select * from dept) d
      4*        on   (e.deptno = d.deptno)
    SQL> /
         EMPNO ENAME      DNAME
          7369 SMITH      RESEARCH
          7499 ALLEN      SALES
          7521 WARD       SALES
          7566 JONES      RESEARCH
          7654 MARTIN     SALES
          7698 BLAKE      SALES
          7782 CLARK      ACCOUNTING
          7788 SCOTT      RESEARCH
          7839 KING       ACCOUNTING
          7844 TURNER     SALES
          7876 ADAMS      RESEARCH
          7900 JAMES      SALES
          7902 FORD       RESEARCH
          7934 MILLER     ACCOUNTING
    14 rows selected.Ok, a bit of a nonsense query in itself, but it's demonstrating that we have two subqueries that we are getting our data from.
    Now, writing the same query using a WITH clause...
    SQL> ed
    Wrote file afiedt.buf
      1  with e as (select * from emp)
      2      ,d as (select * from dept)
      3  select e.empno, e.ename, d.dname
      4* from   e join d on (e.deptno = d.deptno)
    SQL> /
         EMPNO ENAME      DNAME
          7369 SMITH      RESEARCH
          7499 ALLEN      SALES
          7521 WARD       SALES
          7566 JONES      RESEARCH
          7654 MARTIN     SALES
          7698 BLAKE      SALES
          7782 CLARK      ACCOUNTING
          7788 SCOTT      RESEARCH
          7839 KING       ACCOUNTING
          7844 TURNER     SALES
          7876 ADAMS      RESEARCH
          7900 JAMES      SALES
          7902 FORD       RESEARCH
          7934 MILLER     ACCOUNTING
    14 rows selected.As you can see, the subqueries have been moved out of the main query and put into the WITH clause, and then the main query just references those subqueries aliases.
    In the above example, there's not much point in doing this, but in more complex queries, you may have a subquery that is used several times, in which case having it in the WITH clause means that that subquery is processed just once and used many times, (you can also look at the MATERIALIZE hint to help improve performance with such subqueries if necessary)
    The difficulty with finding this in the documentation is because you will no doubt be trying to search for "WITH", which isn't a very good search term to be using as it's used in the english language too much for an accurate hit... so... when you learn it's called "Subquery Factoring" (because you are factoring out the subqueries from the main query), it then becomes easier to find...
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2161315
    ... and you see it's included as part of the documentation for the SQL SELECT statement.

  • Pb with language logon and data display Query designer

    Hello,
    I do the translations (FR => EN) via RSA1 and SE63 of my variables of my Query for the query designer.
    It works I have no technical name that appears in the query designer.
    But when I run my query using the query designer, the query is displayed in French while I am logged in English.
    I want the query is displayed in english when I'm logged into English.
    How can I do?
    Thank you pour votre aide.
    Edited by: KhalidTaibi on Jul 6, 2010 6:31 PM

    Hello,
    Per I can understand, you are executing the query from Query Designer.
    So, if you are using Query designer 7.0, you are calling the Enterprise Portal.
    Even with English on Query Designer, you have to logon as english on the
    Portal, as well.
    Try to check your Browser configuration.
    On Internet Explorer:
    Tools
    Internet Option
    Language
    Check if English is configured as the first language.
    Also, ensure the query1s objects exists on english version.
    Best regards,
    Edward John

  • Help with WITH clause

    I have a complicated summary report that I am trying to put together. Using the WITH clause is substantially reducing the query time. Here's what I have (it works):
    with ldsntons as
    (select c.DATE_INDEX, j.FACTORY_ID, s.SHORT_NM||' ('||j.STATION_ID||') '||j.PILE_CODE_ALT_FLAG as STN_NM,
           COUNT(j.LOAD_JOB_ID) as LDS,
        CASE SUM(w.SPOT_WEIGHT)
           WHEN 0 THEN SUM(j.MAN_SPOT_WT)
           ELSE SUM(w.SPOT_WEIGHT)
         END TONS
      from TC c, TC_LOAD_JOBS j, SPOT_WEIGHTS w, STATIONS s
    where c.TC_ID = j.TC_ID
       and FN_STN_KEY(j.FACTORY_ID, j.STATION_ID) = s.KEY_ID
       and j.LOAD_RATE_ID = w.LOAD_RATE_ID
       and c.DATE_INDEX = w.DATE_INDEX
       and c.DATE_INDEX BETWEEN to_date(:P2053_DT,'MM/DD/YYYY') AND to_date(:P2053_DT,'MM/DD/YYYY') +15  -- Optional filter
    group by c.DATE_INDEX, j.FACTORY_ID, j.STATION_ID, s.SHORT_NM, j.PILE_CODE_ALT_FLAG)
    SELECT STN_NM as STN,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')    THEN LDS  END), 0) D01LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')    THEN TONS END), 0) D01TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+1  THEN LDS  END), 0) D02LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+1  THEN TONS END), 0) D02TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+2  THEN LDS  END), 0) D03LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+2  THEN TONS END), 0) D03TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+3  THEN LDS  END), 0) D04LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+3  THEN TONS END), 0) D04TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+4  THEN LDS  END), 0) D05LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+4  THEN TONS END), 0) D05TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+5  THEN LDS  END), 0) D06LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+5  THEN TONS END), 0) D06TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+6  THEN LDS  END), 0) D07LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+6  THEN TONS END), 0) D07TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+7  THEN LDS  END), 0) D08LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+7  THEN TONS END), 0) D08TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+8  THEN LDS  END), 0) D09LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+8  THEN TONS END), 0) D09TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+9  THEN LDS  END), 0) D10LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+9  THEN TONS END), 0) D10TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+10 THEN LDS  END), 0) D11LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+10 THEN TONS END), 0) D11TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+11 THEN LDS  END), 0) D12LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+11 THEN TONS END), 0) D12TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+12 THEN LDS  END), 0) D13LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+12 THEN TONS END), 0) D13TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+13 THEN LDS  END), 0) D14LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+13 THEN TONS END), 0) D14TNS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+14 THEN LDS  END), 0) D15LDS,
    NVL(SUM(CASE WHEN DATE_INDEX = to_date(:P2053_DT,'MM/DD/YYYY')+14 THEN TONS END), 0) D15TNS,
    SUM(LDS),
    SUM(TONS)
      FROM ldsntons
    WHERE FACTORY_ID = :P2053_ORG_ID
    GROUP BY STN_NMBasically the report lists a location with daily activity in columns for 15 days from that location. What I need to add are subtotals at the end of the line. I tried duplicating my WITH clause to pull the subtotals, but I kept getting an incorrect join that was listing all the amounts regardless of the date, which isn't correct.
    The other kicker is that I can get it to work fine if I restrict the initial WITH statement to include a WHERE clause (-- Optional filter) that filters it down to only data within the range, but the requestor wants to see all the locations regardless of whether they haul during the time period or not.
    Your help is greatly appreciated.

    This report is a cross-tab of data compiled from 4-5 other tables. I understand what you are asking, but I can't possibly post that much information. This is an aggregation of hundreds of employee timecards per day having dozens of loads; even to get a representative set you would need several hundred lines. The report lists the loads and tons for each of the 15 days on the report by virtue of the case statement. What I need is a sub-total (by line) of those 15 days into one field at the end of the line. It's not that hard to do in a spreadsheet, but we're trying to skip the need to export to csv and do manual manipulations after the fact.
    This is what I want the report to look like:
    STATION     DAY1LOADS   DAY1TONS   DAY2LOADS   DAY2TONS ...  DAY15LOADS   DAY15TONS   SUBTTLLOADS   SUBTTLTONS
    Ada            10           300          12        350             5         150       40        1200SUBTTLTONS = DAY1TONS + DAY2TONS + DAY3TONS, etc.
    I was hoping there was a simpler way of doing it than adding the individual columns into an aggregate. I can develop the query I need, I just need help with joining it in to the base query. This query gets me the subtotals:
    select s.SHORT_NM||' ('||j.STATION_ID||') '||j.PILE_CODE_ALT_FLAG as STN_NM,
           COUNT(j.LOAD_JOB_ID) as LDS,
        CASE SUM(w.SPOT_WEIGHT)
           WHEN 0 THEN SUM(j.MAN_SPOT_WT)
           ELSE SUM(w.SPOT_WEIGHT)
         END TONS
      from TC c, TC_LOAD_JOBS j, SPOT_WEIGHTS w, STATIONS s
    where c.TC_ID = j.TC_ID
       and FN_STN_KEY(j.FACTORY_ID, j.STATION_ID) = s.KEY_ID
       and j.LOAD_RATE_ID = w.LOAD_RATE_ID
       and c.DATE_INDEX = w.DATE_INDEX
       and j.FACTORY_ID = :P2053_ORG_ID
       and c.DATE_INDEX BETWEEN to_date(:P2053_DT,'MM/DD/YYYY') AND to_date(:P2053_DT,'MM/DD/YYYY') +15
    group by s.SHORT_NM||' ('||j.STATION_ID||') '||j.PILE_CODE_ALT_FLAG

  • Distributed query using local BackingMap

    I'm trying to create a distributed query (deriving a task from AbstractInvocable). I want each cluster node to query only it's local storage, aggregate a result and then return that single result to the invoker of the Task.
         To do this I'm using the BackingMap for a NamedCache and running the query on this. My question is, since this is a Map, how can I run the query using Filter objects?
         On the NamedCache (i.e. the entire cache) I can query with a Filter, but to achieve the same thing with a local BackingMap I have to iterate through the entire Map. What am I missing?!
         Many Thanks,
         Jools

    Thanks Cameron.
         We can query the NamedCache using Filters - that's fine.
         What I'm trying to achieve though, is to use distributed tasks running on each node. The reason is that we're planning on using a widely-Distributed cache with nodes in both the US and the UK, and as such we're trying to minimise bandwidth usage by having the distributed task perform some aggregation on the local node and return only the result.
         However, if we can only get a Map interface on the local node, and therefore cannot use Filters (or indexes for that matter) and can only iterate through the contents of the Map looking for properties that match our criteria, then it may end up being too inefficient to do it this way.
         Are there no config settings than govern what type of object gets returned as the backing map on the local node?
         Thanks,
         Jools

  • Difference between global temporary table and with clause

    what is the difference between global temporary table and with claue .(with clause is used as table in select query)

    what is the difference between global temporary table and with claue .(with clause is used as table in select query)Its big difference between the two.
    Global temporary table exists for a session or a transaction while, with clause lives only for a query.
    GTT is a named permanent storage table whose data flushes away on session exit or at end of a transaction while WITH clause just provides names to a reference data within a query (which is as good as having union subquery in FROM clause)
    eg
    SQL> with c as
      2  (
      3  select 1 id1, 2 id2 from dual union all
      4  select 2,4 from dual union all
      5  select 3,5 from dual)
      6  select * from c
      7  /
           ID1        ID2
             1          2
             2          4
             3          5
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2  from
      3  (
      4  select 1 id1, 2 id2 from dual union all
      5  select 2,4 from dual union all
      6* select 3,5 from dual)
      7  /
           ID1        ID2
             1          2
             2          4
             3          5But GTT serves its purpose very well in case of session specific transaction and the scnearion with multiple users working on same data.

  • WITH CLAUSES - need advice

    Recently we found that the server converts all the request to 'with clauses' format in the physical query even if the request does not contain any subquery. I am bit concerned on this as some article suggest that there is a limitation in using with clauses and it can return unexpected results. Could this change in behavior cause some problem?

    Hi all,
    We are currently using ORACLE 10g.
    For ex the original query for a specific report would look like
    select distinct D1.c1 as c1,
    D1.c2 as c2
    from
    (select distinct T41994.NAME as c1,
    T41994.LOC as c2
    from
    (SELECT
    A.*,
    ORA62102.F_UTC2LOCAL(A.CREATED_TS,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS CREATED_LCL,
    ORA62102.F_UTC2LOCAL(A.LAST_UPD,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS LAST_UPD_LCL,
    ORA62102.F_UTC2LOCAL(A.REFERENCE_START_DT,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS REFERENCE_START_DT_LCL,
    ORA62102.F_UTC2LOCAL(A.INDEXED_DATE_0,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS INDEXED_DATE_0_LCL
    FROM ORA62102.S_ORG_EXT A) T41994
    where ( T41994.BU_ID = '1-D3DGK' and T41994.DELETED_STATE = 'N' )
    ) D1
    Now the query is changed to the following format
    WITH
    SAWITH0 AS (select distinct T41994.NAME as c1,
    T41994.LOC as c2
    from
    (SELECT
    A.*,
    ORA62105.F_UTC2LOCAL(A.CREATED_TS,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS CREATED_LCL,
    ORA62105.F_UTC2LOCAL(A.LAST_UPD,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS LAST_UPD_LCL,
    ORA62105.F_UTC2LOCAL(A.REFERENCE_START_DT,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS REFERENCE_START_DT_LCL,
    ORA62105.F_UTC2LOCAL(A.INDEXED_DATE_0,'(GMT-08:00) Pacific Time (US & Canada); Tijuana') AS INDEXED_DATE_0_LCL
    FROM ORA62105.S_ORG_EXT A) T41994
    where ( T41994.BU_ID = '1-D3DGK' and T41994.DELETED_STATE = 'N' ) )
    select distinct SAWITH0.c1 as c1,
    SAWITH0.c2 as c2
    from
    SAWITH0
    Even if I select 2 columns from a table , the select clause in the physical query in OBI server contains 'with clause'.
    -Uma

Maybe you are looking for