Query refuses to execute

Hey guys,
Im having a problem with a query im trying to port from SQL to HQL. This HQL query is for a nested set (as per this article: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html ), however it fails on the sub-query in the from clause:
SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth
FROM Content AS node,
         Content AS parent,
          Content AS sub_parent,
                ( SELECT node.name, (COUNT(parent.name) - 1) AS depth
            FROM Content AS node,
            Content AS parent
            WHERE node.lft BETWEEN parent.lft AND parent.rft
            AND node.name = :leaf
            GROUP BY node.name
            ORDER BY node.lft
            ) AS sub_tree
WHERE node.lft BETWEEN parent.lft AND parent.rft
AND node.lft BETWEEN sub_parent.lft AND sub_parent.rft
AND sub_parent.name = sub_tree.name
GROUP BY node.name
HAVING depth <= 1
ORDER BY node.lft Im not that familiar with HQL, and the documentation didn't clear up weather or not this is possible.
Any help would be most welcome
Thanks
Tim

Are you asking about migrating to JPA's QL (JPQL) or migrating to Hibernate's QL (HQL)?
Doug

Similar Messages

  • How to optimize the select query that is executed in a cursor for loop?

    Hi Friends,
    I have executed the code below and clocked the times for every line of the code using DBMS_PROFILER.
    CREATE OR REPLACE PROCEDURE TEST
    AS
       p_file_id              NUMBER                                   := 151;
       v_shipper_ind          ah_item.shipper_ind%TYPE;
       v_sales_reserve_ind    ah_item.special_sales_reserve_ind%TYPE;
       v_location_indicator   ah_item.exe_location_ind%TYPE;
       CURSOR activity_c
       IS
          SELECT *
            FROM ah_activity_internal
           WHERE status_id = 30
             AND file_id = p_file_id;
    BEGIN
       DBMS_PROFILER.start_profiler ('TEST');
       FOR rec IN activity_c
       LOOP
          SELECT DISTINCT shipper_ind, special_sales_reserve_ind, exe_location_ind
                     INTO v_shipper_ind, v_sales_reserve_ind, v_location_indicator
                     FROM ah_item --464000 rows in this table
                    WHERE item_id_edw IN (
                             SELECT item_id_edw
                               FROM ah_item_xref --700000 rows in this table
                              WHERE item_code_cust = rec.item_code_cust
                                AND facility_num IN (
                                       SELECT facility_code
                                         FROM ah_chain_div_facility --17 rows in this table
                                        WHERE chain_id = ah_internal_data_pkg.get_chain_id (p_file_id)
                                          AND div_id = (SELECT div_id
                                                          FROM ah_div --8 rows in this table
                                                         WHERE division = rec.division)));
       END LOOP;
       DBMS_PROFILER.stop_profiler;
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
          NULL;
       WHEN TOO_MANY_ROWS
       THEN
          NULL;
    END TEST;The SELECT query inside the cursor FOR LOOP took 773 seconds.
    I have tried using BULK COLLECT instead of cursor for loop but it did not help.
    When I took out the select query separately and executed with a sample value then it gave the results in a flash of second.
    All the tables have primary key indexes.
    Any ideas what can be done to make this code perform better?
    Thanks,
    Raj.

    As suggested I'd try merging the queries into a single SQL. You could also rewrite your IN clauses as JOINs and see if that helps, e.g.
    SELECT DISTINCT ai.shipper_ind, ai.special_sales_reserve_ind, ai.exe_location_ind
               INTO v_shipper_ind, v_sales_reserve_ind, v_location_indicator
               FROM ah_item ai, ah_item_xref aix, ah_chain_div_facility acdf, ah_div ad
              WHERE ai.item_id_edw = aix.item_id_edw
                AND aix.item_code_cust = rec.item_code_cust
                AND aix.facility_num = acdf.facility_code
                AND acdf.chain_id = ah_internal_data_pkg.get_chain_id (p_file_id)
                AND acdf.div_id = ad.div_id
                AND ad.division = rec.division;ALSO: You are calling ah_internal_data_pkg.get_chain_id (p_file_id) every time. Why not do it outside the loop and just use a variable in the inner query? That will prevent context switching and improve speed.
    Edited by: Dave Hemming on Dec 3, 2008 9:34 AM

  • Finding query access frequency or how many times a query has been executed?

    Dear Experts
    I need to find the total number of access frequency of individual queries that are requested by the users say at a particular time.
    Say there are 20 distinct queries requested in the time difference of 3 hours. All of the 20 queries or some of the queries may be requested for more than 2/3 times at that time by other users. By the way say query Q1 is requested 5 times at that so its query access frequency or how many times this query is executed is 5.
    From where and how can I can find this counting of query access frequency or how many times a query has been executed at particular time or a session?
    Normally we know the there SQL history dynamic performance views or if it can be possible to query the Shared pool library cache for SQL area it may be possible to find the total number of execution time for a query. But how to find that if anyone knows, please help me about this.
    Regards-
    Engr. A.N.M. Bazlur Rashid
    OCP DBA

    That's one of the stats reported by statspack - assuming that your query does sufficient work to meet the thresholds for the standard report. Executions is of course one of the columns of v$sql so you might just wish to sample that yourself. Finally if you are on 11g and the sql you are interested is relatively low resource intensive and you are licensed for AWR then you can use the slightly madly named "colored sql" feature that ensures that a specific statement will always be sampled for AWR.
    Niall Litchfield
    http://www.orawin.info/

  • VO  query not getting executed

    Hi,
    I am facing a problem in executing the query of my extended VO. I have extended a VO and modified the query in the extended VO to fetch two more columns from the database.
    Now I am trying to execute the query of my extended VO. But I do not get any results. I think the query execution is not happening. Please go through the code mentioned below :
    1. OAViewObject oaviewobject1 = (OAViewObject)
    2. oaapplicationmodule.findViewObject("XXAIBidHeadersSPVO1");
    3. oaviewobject1.reset();
    4. oaviewobject1.setWhereClauseParams(null);
    5. oaviewobject1.setWhereClauseParam(0, negotiationvorowimpl.getAuctionHeaderId());
    6. oaviewobject1.executeQuery();
    7. XXAIBidHeadersSPVORowImpl rowImpl = (XXAIBidHeadersSPVORowImpl) oaviewobject1.first();
    8. System.out.println("Value of rowImpl = " + rowImpl);
    9. System.out.println("Value of SSI flag = " + rowImpl.getSsi());
    10. System.out.println("Value of PSU flag = " + rowImpl.getPsu());
    The execution stops after line 8. I am not able to get the values of the two new columns included in the where clause. Please advise as to what might be going wrong. This is very urgent.
    Thanks and Regards,
    Sandhya

    If vo.first returns you an object, means your query is executed and there is a row in the ViewObject, if 9 and 10 are displaying null, this means there is a row where these columns are without values.
    Try doing this
    Run the page in debug mode, you will see plenty of data in the log window, the query that is executed and the bind values will also be there, take this query and run it in sqlplus, check if the results are consistent.
    Thanks
    Tapash

  • Error:  Due to a lock, query cannot be executed at the moment

    Hi,
    I am getting the following error when executing my query:
    Error:  Due to a lock, query cannot be executed at the moment
    Abort System error in program SAPLRSDRC and form /BIC/ZABC_01
    The query has been running fine for the past few months.
    Can anyone explain why this error occured and what can I do to avoid this?
    Thanks in Advance!!
    Regards,
    Swapna

    Hi Swapna,
    make sure that the BW system (e.g. another user, process, ...) does not have currently access to the data e.g. like maintain data. In this case the BW sets a lock so that the current user gets exclusively access to the table.
    Check the table if there are any locks on it. Call transaction SU53 and check your table for any locks.
    Check this thread, perhaps you will find some more information there:
    https://forums.sdn.sap.com/click.jspa?searchID=3180428&messageID=1088573
    Hope this helps.
    Regards,
    Marco

  • My query is not executing properly after applying patches(bi.7

    iam working bi.7 support package 13
    after applying patches
    my query is not executing properly in production my problem with FI queries
    the query is executing properly but ihav created newformula using formulavariable that fields are not getting data in report if i click on currency conversion iam getting popup but currency translation coversion list is not coming and currency type(target currency also not dispalying)
    but if i execute same query in development its working properly newformula fields are getting data and currency conversion also working in development
    can u please help me in this issure
    i hope as soon i will get solutions from bw gurus

    That currency conversion problem is solved
    i checked TCODE:RSCUR IN PRD its not showing any details
    again i checked in dev and moved all currency types dev to production
    now its wokring
    i hope check with this it will work

  • SQL query can be executed through TOAD but not through Discoverer

    Hallo, everybody:
    Got another problem. A SQL query can be executed through TOAD, but when I want to execute it by a worksheet of Discoverer Plus, it always shows there is no data.
    PS: I copied this query from Discoverer Plus to TOAD, which means, this query is generated through the Discoverer. Does anybody know about how could it be?
    Thank you.
    Geng

    Hi,
    If you are able to get data in TOAD with the same user credential as that of Discoverer Plus then it will implies an issue with Discoverer.
    Else it is privilege issue , your TOAD user has select privilege to the base objects (tables/views etc) where as your Disoverer used does not.
    Compare the privileges granted to these 2 users and you can narrow done to the issue .
    Thanks,
    Sutirtha

  • 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

  • Multi Provider Changes - The Query cannot be executed

    Hello,
    I added a new characteristic to an existing multiprovider on which queries already exist.
    I changed one of the existing queries adding that newly added characteristic.
    Now the query cannot be executed. Please see the log...
    I could successfully execute the query in RSRT....
    Diagnosis
    Characteristic 0BILL_TYPE is used in the Query Designer, but was deleted from the InfoProvider.
    System response
    The query cannot be executed.
    Procedure
    Characteristic 0BILL_TYPE is used in the query to be executed even though it was deleted from the InfoProvider. The problem can be solved by changing the query in the Query Designer. Here, you get a repair proposal, which removes the missing InfoObject from the query. Afterwards, check whether or not the query was defined correctly.
    You can also delete the query.
    Additional technical information:
    IOBJNM = 0BILL_TYPE
    ELTUID = Sell-In Qty
    ELTTP = SEL
      Notification Number BRAIN 407 
    Close 
    Any siggestions of how to adjust the multiprovider.
    Thanks,
    Vish

    The check in query designer says that query is correct.
    Only when I try to execute using the web it says that Char doesn't exist in infocube.
    The query works fine in Analyzer & RSRT....I guess something got to do with the Browser or web..
    Thanks,
    Vish

  • Error while query is been executed?

    Hi all,
    I am getting the following error? while executing a query based upon the Multi provider.
    Warning Following error for the partial infocube = zclmbl in rsdrc_cube_data_get_rf
    abort internal error in program CL_RSDD_VCUBE and method COLLECT_CHA_SID-10-
    Abort System error : RSDRC/FUNCTION RSDRC_CUBE_DATA_GET_RFC ERROR WHEN CALLING
    thanxs
    haritha

    Hi,
      Try this..
    Go to RSRT - give your query name and there will be button called 'generate report'  and then try to execute the query in BEx..
    Regards,
    Siva.

  • BI Publisher: Issue while scheduling the report/query to be executed daily

    Hi,
    We are using Oracle Business Intelligence 11.1.1.6.3 and while we schedule a report(RTF Template) we are facing issue.We use bursting query and when we select option to execute immediately it runs fine and sends notifications,it also executes when we schedule it to run Once but fails when i schedule the report to be executed DAILY .

    hii
    The query does not includes any RKF, CKF any complex calculations. as I said before also query is based on MP which is designed on a single Cube. There are no such navigational Attributes used for selection, Number of records are not more than 300 on that particular selection parameter
    there is only one info object which is creating issue & it is a master info object. If i am restricting this info object in the query & then executes the query , it gives the error msg also i put a variable for input parameter, & there I restrict the value, then also query executes with an error msg
    But if query is not restricted with  any value for that info object then query executes with in a second.
    Thanks
    neha

  • Connection refused--while executing (HttpConnection) Connector.open(url);

    Hi,
    i'm using netbeans mobility 5.0
    as i was new to this mobile programming i'm getting the output as "Connection Refused"
    plz plz plz plz....... help me out from this problem
    here is my code..
    code:_
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class FileViewer extends MIDlet implements CommandListener
    private Display display; // Reference to Display object
    private TextBox tbViewer; // View file contents in a textbox
    private Command cmView; // Command to view file
    private Command cmExit; // Command to exit
    private String url = "http://www.corej2me.com/midpbook_v1e1/scratch/fileViewer.hlp";
    public FileViewer()
    display = Display.getDisplay(this);
    // Define commands
    cmView = new Command("View", Command.SCREEN, 2);
    cmExit = new Command("Exit", Command.EXIT, 1);
    tbViewer = new TextBox("Viewer", "", 250, TextField.ANY);
    tbViewer.addCommand(cmView);
    tbViewer.addCommand(cmExit);
    tbViewer.setCommandListener(this);
    public void startApp()
    display.setCurrent(tbViewer);
    private void viewFile() throws IOException
    HttpConnection http = null;
    InputStream iStrm = null;
    try
    http = (HttpConnection) Connector.open(url);
    // Client Request
    // 1) Send request method
    http.setRequestMethod(HttpConnection.GET);
    // 2) Send header information (this header is optional)
    http.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    // 3) Send body/data - No data for this request
    // Server Response
    // 1) Get status Line
    System.out.println("Msg: " + http.getResponseMessage());
    System.out.println("Code: " + http.getResponseCode());
    // 2) Get header information
    if (http.getResponseCode() == HttpConnection.HTTP_OK)
    // 3) Get data (show the file contents)
    iStrm = http.openInputStream();
    int length = (int) http.getLength();
    if (length > 0)
    byte serverData[] = new byte[length];
    iStrm.read(serverData);
    tbViewer.setString(new String(serverData));
    finally
    if (iStrm != null)
    iStrm.close();
    if (http != null)
    http.close();
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command c, Displayable s)
    if (c == cmView)
    try
    viewFile();
    catch (Exception e)
    System.out.println(e.toString());
    else if (c == cmExit)
    destroyApp(false);
    notifyDestroyed();
    output*
    build.xml(debug)*
    some....
    Application descriptor does not declare any MIDlet. Direct execution is not allowed.
    Generated "C:\Documents and Settings\Lakshmi Narayan J\jlnexample\dist\jlnexample.jar" is 2655 bytes.
    post-jar:
    debug:
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\src\.timestamp
    Starting emulator in debug server mode on port 1469
    com.sun.kvem.midletsuite.InvalidJadException: Reason = 22
    The manifest or the application descriptor MUST contain the attribute: MIDlet-1
    nbdebug:
    KdpDebugTask connecting to debugger 1 ..
    KdpDebugTask connecting to debugger 2 ..
    KdpDebugTask connecting to debugger 3 ..
    KdpDebugTask connecting to debugger 4 ..
    KdpDebugTask connecting to debugger 5 ..
    Connecting JPDA Debugger to emulator timed out after 5 attempts and 31 seconds.
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\nbproject\build-impl.xml:306: The following error occurred while executing this line:
    C:\Documents and Settings\Lakshmi Narayan J\jlnexample\nbproject\build-impl.xml:311: Connecting JPDA Debugger to emulator timed out after 5 attempts and 31 seconds.
    BUILD FAILED (total time: 43 seconds)
    Debugger console:
    Attaching to localhost:1469
    Connection refused.
    Edited by: LAKSHMI_NARAYAN_J on Jun 23, 2008 9:54 AM

    It's called potential deadlock. The emulator blocks your app 'cause any connection and commandAction needs its own thread. So I suggest use a new thread with this http connection then your program will be run successful.

  • SAP QUERY does not execute in other client

    Hi,
    I am working on SAP QUERY on the Quality Assurance and Cust & Dev Client and i am facing a strange thing when i tried to execute the Query from SQ01 ,there i found itis not able to get executed but when i generated the report ,after that it get s executed.
    I want to know what are the reasons behind it,please provide me guidelines for solving it.

    See, SQ01 can not alone be used.
    It is linked with the SQ02 - Funectional Area, where the joins handeled and codes implemented.
    Also SQ03 - User Groups.
    User Group you can ignore, but Functional Area is must to run a query through SQ01.
    When you generate the Functional Area using SQ02, it activates all the objects associated with the Query.
    So even if you need same query to some other client sayu in quality or production, you need to import export Functional area first before query or simultaneously.
    Regds,
    ANil

  • Urgent query related to execute immediate in a  procedure.

    hi,
    I want to create a table in the production database,within a procedure so I write query like:
    CREATE OR REPLACE PROCEDURE TEST
    IS
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE PE.BUD_VS_REV AS SELECT * FROM WH.WH_BUD_VS_REVNM1';
    END;
    but this is not working within the procedure it gives the
    ORA-01031: insufficient privileges.
    I already have asked to DBA he said that this user has all previlidges.
    one more thing if I write this query in an annonymous block like:
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE PE.BUD_VS_REV AS SELECT * FROM WH.WH_BUD_VS_REVNM1';
    END;
    its working well.
    can any buddy tellme what can be the reason,actually.
    Thanx
    Ritesh!

    Look this example:
    DBA >> CREATE USER LEO IDENTIFIED BY LEO
    2 /
    User created.
    DBA >> GRANT CREATE SESSION TO LEO
    2 /
    Grant succeeded.
    LEO >> CREATE OR REPLACE PROCEDURE TEST
    2 IS
    3 BEGIN
    4 EXECUTE IMMEDIATE 'CREATE TABLE PE.BUD_VS_REV AS SELECT * FROM WH.WH_BUD_VS
    _REVNM1';
    5 END;
    6 /
    CREATE OR REPLACE PROCEDURE TEST
    ERROR at line 1:
    ORA-01031: insufficient privileges
    DBA >> GRANT CREATE ANY PROCEDURE TO LEO
    2 /
    Grant succeeded.
    LEO >> CREATE OR REPLACE PROCEDURE TEST
    2 IS
    3 BEGIN
    4 EXECUTE IMMEDIATE 'CREATE TABLE PE.BUD_VS_REV AS SELECT * FROM WH.WH_BUD_VS
    _REVNM1';
    5 END;
    6 /
    Procedure created.

  • The SQL query is not executing

    Hi
    I have the following situation: In a project we designed our reports calling a stored procedure the exits in a MS SQL Server 200 database. The Stored Procedures works fine and when they are used in the report everything works perfectly.
    The reports are being made with CR DEsigner 11, when the designer ends them, ha pass them to me and we put them in our java web application. I open them and even preview them since the Crystal Reprots Perspective of Eclipse and I can see the data, so everything to this point is OK.
    The problem comes when I change of connection, I'm trying to connect every report to the same host and database, and when the reprot is displayed in the browser there is no data. I profile the SQL commands that are executed when the report is requested and I found that the reprot is not executing the stored procedure.
    I guess because i'm connectring the report to the same database and host that was used when the report is created and i'm also passing exactly the same parameters of the stored procedure, then report thinks that it doesn't have executing again becuase it will be the same information.
    SO, i wonder if there is a way to request to the report to execute the sql query every time i have to display it.
    thanks for any help.

    What happens when you try to view the report using a simple viewer.jsp?without changing the connection?
    2009-05-25 14:06:09,250 ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter -  detected an exception: Error de conexión: [SQLServer 2000 Driver for JDBC]Error establishing socket.
    But the database server is ok, so i think the rpt needs more information to be connect to the database.
    Also what happens if you dont use the data bean and give everything there only?
    The same, the rpt is not executing the stored procedure.
    Did anything change on the RDBMS side? Additional packages, changes to the schema, ownership, etc?
    No, the server is ok and the database is ok.
    If you configure Log4J logging to DEBUG, you should see the database invokes from the Crystal Java engine, specifically the queries sent and the number of rowsets returned. Do you notice any errors?
    I have a problem here with log4j. In my project i'm using spring and with the help of spring i configure log4j, basically with spring is easier to configure log4j.
    I'm telling you this because i have log4j working but when my application reaches the code to change the connection to the rerport, log4j dies and stop sending any message to the stdout or to a log file. I haven't since this behavior in any other app o library. So i want to guess i have something wrong with my log4j or maybe with log4j+spring.
    So, i remove all the code of spring referring to log4j, but the problem with log4j wasn't solved.
    What i will try now is to remove spring from the project.
    This is my log4j.properties:
    log4j.rootLogger=DEBUG, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

Maybe you are looking for