SQL query from toplink expression

Hi,
I have a oracle.toplink.expressions.Expression object with me which has been created using oracle.toplink.expressions.ExpressionBuilder. I want to find its equivalent SQL query(say select emp.empname,emp.empId from employee emp) which will be fired in order to fetch data i.e. find its equivalent Statement/PreparedStatement or anything which will help me obtain the raw SQL statement about to be fired.
Please let me know if there is any soln.
Thanks,
Adithya.

You can create ReadAllQuery with the expression and get the query's SQL using query.prepareCall() and then query.getSQLString().
James : http://www.eclipselink.org

Similar Messages

  • See sql query from crystal report without crystal report

    see sql query from crystal report without crystal report 

    Hi,
    Depends on datasource type but you could have a look at ODBC trace or if you have access to the SQL Server you could use profiler to monitor the session.
    Regards,
    Craig
    And this will only be of use if you know which Server/Insstance/Database the Report is connecting to...
    Please click "Mark As Answer" if my post helped. Tony C.

  • Help with translating SQL query from SQL Server syntax to Oracle syntax

    Hi,
    is it someone that can help me translate following SQL query from SQL Server syntax to Oracle syntax.
    SELECT ID,
    [LMT(MTR)] = MAX(case when TYPE = 'LMT' then VALUE end),
    [AAD(KGM)] = MAX(case when TYPE = 'AAD' then VALUE end),
    [VOL(MTQ)] = MAX(case when TYPE = 'VOL' then VALUE end)
    FROM yourtable
    GROUP BY ID
    Your help is highly appreciated, thanks in advance.

    Like this,
    SELECT ID,
    MAX(case when TYPE = 'LMT' then VALUE end) LMT_MTR,
    MAX(case when TYPE = 'AAD' then VALUE end) AAD_KGM ,
    MAX(case when TYPE = 'VOL' then VALUE end) VOL_MTQ
    FROM yourtable
    GROUP BY ID-Arun

  • How to transport SQL Query from SQVI Tcode?

    Dear Friends,
    Can any one tell me how to transport SQL Query from <b>SQVI</b> Tcode.
    Full Points will be rewarded.
    Thanks & Reagrds
    Ravi

    go to sqvi tool .....
    select u r query name ......in the menubar ....quickview....> additianal functions.......>generate program
    after doing generate program ....go to again same menu path as i have mentioned above [quickview....> additianal functions.......>display report name it will give the report name of the select query ..........copy the report name and give it abap editor[se38] u will get u r query program......with all authority checks.....
    in start of selection event of u r program u will find u r select query.
    reward points if helpful

  • Retrieve SQL Query from report without RAS.

    We have a fat client application which uses Crystal Reports.  We upgraded from the RDC/ActiveX viewer to the .Net SDK/.Net Viewer.  One feature that we miss is that we used to read the SQL Query that a report used and wrote it to our log file.  This helped with debugging and with troubleshooting problems in the field.
    Since we only deploy the freely distributable Crystal Reports model and I don't think that RAS falls into this category is there a way which we can read the SQL Query from a report?  If not, could you add this to a list of requested features for future versions.
    I understand why you removed the ability to set the SQL query, but simply reading it does add value.  Maybe it is difficult for you to return this before the report is run in which case giving us the ability to read the value after the report has been run would also be fine.
    Alternatively some sort of event that is fired each time a query is executed would also be helpful as this would allow Crystal Reports clients to monitor SQL from sub-reports.  You could even build a robust logging mechanism which could report additional information (i.e. number of rows returned, formula evaluations, or anything related to report execution).  All of this would make troubleshooting report issues easier for those of us who use Crystal Reports.

    Need to know what version of CR you are using?
    You can use InProc RAS, it comes with CR and is distributed with the runtime files.
    If you are using CR Basic or the version that comes with Visual Studio .NET then no this will not be added to that product line. It is basic functionality only. You will need to upgrade to a Developer version of Crystal reports to take advantage of the the RCAPI features as well as more general API's.
    There is logging for our DB drivers but the log files get very large. If you use ODBC then you have the option to turn on tracing also. Using RAS you don't need to turn on logging as you can get the SQL. This won't be added either.
    Thank you
    Don

  • How do I call pl/sql function from Toplink

    I can easily call a stored procedure from Toplink
    ====================================================
    public Collection executeSelectingStoredProcedure(StoredProcedureCall storedProcedureCall) throws DAOException
    Collection returnValue = null;
    Session session = null;
    session = this.getSession();
    returnValue = session.executeSelectingCall(storedProcedureCall);
    session.release();
    return returnValue;
    ====================================================
    The same does not work for pl/sql functions. Doesnt Toplink treat function calls as a callable statement as in JDBC?
    "select <function_name>(<arguments>) from dual" seems to be a work around. If this or using expressions is the only solution can someone please tell me the reasoning behind this shift.
    Regards
    Aamir Dehlavi

    I have the same problem.
    I have a PL/SQL function that returns a number. This function receives 2 parameters. I use StoredProcedureCall plus ValueReadQuery.
    Session aSession = SessionManager.getManager().getDefaultSession();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("CIO_UTILS.COUNT_USER_ROLES_IN_MODULE");
    call.addNamedArgument("p_persid");
    call.addNamedArgument("p_module");
    call.addUnamedOutputArgument("rolesnum", Integer.class);
    ValueReadQuery query = new ValueReadQuery();
    //query.bindAllParameters();
    query.setCall(call);
    query.addArgument("p_persid");
    query.addArgument("p_module");
    Vector parameters = new Vector();
    parameters.addElement(persid);
    parameters.addElement(theModule);
    Integer rolesnum = (Integer) aSession.executeQuery(query,parameters);
    aSession.release();
    if(rolesnum.intValue()<=0)return false; else return true;
    However, I receive the following error:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 96:
    PLS-00312: a positional parameter association may not follow a named association
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    Call:BEGIN CIO_UTILS.COUNT_USER_ROLES_IN_MODULE(p_persid=>'SANCRA2791', p_module=>'PSL_MONITORING', ?); END;
         bind => [=> rolesnum]
    If comment the line
    "call.addUnamedOutputArgument("rolesnum", Integer.class);"
    Toplink is trating it as a procedure, and I also receive an error from PL/SQL.
    There should have to be a way of make it to receive the resoult somehow, but I do not know what.
    Thanks in advance.

  • Help in Forming sql query in Toplink...

    Hi,
    I've the following query in SQL which I need to formulate the same using Toplink expression builder.
    SELECT AVG(HPE),AVG(DK), AVG(HDS), AVG(NAS), AVG(EMC), AVG(EBR), AVG(ARC), AVG(CEL)
    FROM V_SRTS_AGGREGATE WHERE DATACENTER_ID = 2 AND (UPPER(DATA_FLAG_365) = 'YES') and input_date between sysdate -365 and SYSDATE;
    And I've the following in my DAO for Toplink.
    UnitOfWork unitOfWork = getUnitOfWork();      
         ExpressionBuilder aSrtsAggregateView = new ExpressionBuilder();     
         ReportQuery query = new ReportQuery(aSrtsAggregateView);      
         query.setReferenceClass( SrtsAggregateView.class );     
         query.addAverage("EVA", aSrtsAggregateView.get("hpe"));      
         query.addAverage("DK", aSrtsAggregateView.get("dk"));      
         query.addAverage("HDS", aSrtsAggregateView.get("hds"));      
         query.addAverage("NAS", aSrtsAggregateView.get("nas"));
         query.addAverage("EMC", aSrtsAggregateView.get("emc"));      
         query.addAverage("EBR", aSrtsAggregateView.get("ebr"));      
         query.addAverage("ARC", aSrtsAggregateView.get("arc"));      
         query.addAverage("CEL", aSrtsAggregateView.get("cel"));      
              String fromdateLink = "SYSDATE-365";     
              String todateLink = "SYSDATE";
              locToLink = aSrtsAggregateView.get("datacenterid").equal(id);      
              Expression dateToLink = aSrtsAggregateView.get("inputDate").between(fromdateLink, todateLink);
              Expression flagToLink = aSrtsAggregateView.get("data_flag_365").equalsIgnoreCase("yes");
              query.setSelectionCriteria(locToLink.and(flagToLink).and(dateToLink));      
    I'm getting following error
    'Exception [TOPLINK-3005] (OracleAS TopLink - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.ConversionException
    Exception Description: Incorrect timestamp format: [SYSDATE-365] (expected [YYYY-MM-DD HH:MM:SS.NNNNNNNNN])
    Please advise if any one has suggestions..
    Thanks,
    Anil

    The TopLink expression method currentDate() should return the SYSDATE. You could also use ExpressionMath to subtract 365 from this. There is also an expression method literal() that is sometimes useful for advanced SQL.
    <p>
    i.e.
    <code source="java">
    Expression dateToLink = aSrtsAggregateView.get("inputDate").between(ExpressionMath.subtract(aSrtsAggregateView.currentDate(), new Integer(365)), aSrtsAggregateView.currentDate());
    <code>
    <p>---
    <br>James Sutherland
    <br>Oracle TopLink, EclipseLink
    <br>Wiki: Java Persistence, EclipseLink

  • How to SQL intersect using Toplink expressions

    I try to do this SQL intersect
    SELECT part_k FROM ATTR_VALUE
    where commodity_n ='dab badge' and attribute_n='Badge Width' and attribute_value_x='10'
    INTERSECT
    SELECT part_k FROM ATTR_VALUE
    where commodity_n='dab badge' and attribute_n='Brand Logo' and attribute_value_x='Jaguar'
    using the following Toplink expressions:
    Expression e1 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Badge Width"))
    .and(builder.get("value").equal("10"));
    Expression e2 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Brand Logo"))
         .and(builder.get("value").equal("Jagua"));
    Expression myExpression = e1.and(e2);
    However, this would not give me the correct result.
    Any suggestions would be greatly appreicated.

    Right, TopLink doesn't have an Intersect operator. If it did, you might still get the same problem unless you are using a report query to return only the "part_k" value instead of an object since attribute_n cannot have a value of both 'Badge Width' and 'Brand Logo' at the same time.
    You can get the part_k values or the objects from the ATTR_VALUE
    table by using a report query for the second expression as a subquery to the IN clause. Something like
      ReportQuery subquery = new ReportQuery(yourclass.class);
      ExpressionBuilder subBuilder = subquery.getBuilder();
      Expression e2 = subBuilder.get("commodity").equal("dab badge").and(subBuilder.get("attribute").equal("Brand Logo")).and(subBuilder.get("value").equal("Jagua"));
      subquery.setSelectionCriteria(e2);
      subquery.addAttribute("partk");
      Expression myExpression = e1.and( builder.get("partk").in(subquery) );Regards,
    Chris

  • How to run a sql query from a button in apex 3.0

    Hi,
    I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
    Please provide guidance,
    Thank you,
    Tom

    Hi Tom,
    Sounds like a report region will satisfy your requirements.
    Create a new report region on one of your pages.
    Choose SQL Report and give the region a title.
    When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
    SELECT name, license_number
    FROM   <insert_your_table_name_here>
    WHERE  dob = :P<n>_dob
    AND    login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
    Don't try to run the page yet - it will give 'No data found'
    Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
    Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
    Now you can run the page, put some values into the fields and click go.
    If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
    Hope this helps,
    Bryan.

  • API to retrieve SQL query from a Webi Document

    Hi,
    Which API can be used to retrieve the Oracle SQL query for a webi report using BO XI web services SDK? The report is connected to a Oracle database in the backend.
    A sample code is greatly appreciated.
    Thanks a lot!
    Liz

    Hi Liz,
    The libraries for the Enterprise and Report Engine SDKs are included with your Enterprise installation and the location will vary with each version:
    XI Release 1 and Release 2
    XI Release 1 (assuming it's installed on C:\):
    - Windows: C:\Program Files\Common\3.0\java\lib
    - Linux/UNIX: (INSTALL_DIR)/java/lib
    XI Release 2:
    - Windows: (INSTALL_DIR)\Business Objects\Common\3.5\java\lib
    - Linux/UNIX: (INSTALL_DIR)/java/lib
    There are quite a few JAR files in this location, but you should only need the following set for Enterprise & REBean with XI Release 1 or XI Release 2:
    From the java\lib directory
    - boconfig.jar
    - cecore.jar
    - celib.jar
    - ceplugins.jar
    - cereports.jar
    - cesession.jar
    - ceutils.jar
    - cexsd.jar
    - corbaidl.jar
    - ebus405.jar
    - jtools.jar
    - keycodeDecoder.jar
    - rebean.common.jar
    - rebean.fc.jar
    - rebean.jar
    - rebean.wi.jar
    - rpoifs.jar
    - Serialization.jar
    - URIUtil.jar
    - wilog.jar     
    From the java\lib\external directory:
    - Concurrent.jar
    - freessl201.jar
    - icu4j.jar
    - jaxrpc.jar
    - jsafe.jar
    - log4j.jar
    - pullparser.jar
    - saaj.jar
    - sslj.jar
    - xbean.jar
    - xercesImpl.jar
    - xml-apis.jar
    BusinessObjects Enterprise XI 3.0
    - Windows: (INSTALL_DIR)\Business Objects\Common\4.0\java\lib
    - Linux/UNIX: (INSTALL_DIR)/java/lib
    You can find a list of required JAR files in the [XI 3.0 Enterprise SDK Developer Guide|https://boc.sdn.sap.com/node/7298].
    Cheers,
    Parin
    Edited by: Parin Patel on Jun 25, 2008 11:03 AM

  • Oracle SQL Query from EXCEL 2007 with prompt

    Hello,
    I have many excel reports where I am pulling information from our Oracle 9 db through Excel using the following method:
    http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
    http://blog.mclaughlinsoftware.com/2009/11/30/sql-query-in-excel-2007/
    However, I am having trouble when I try the following query due to the prompt:
    SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '&ITEM';
    Does any one know how I can connect a prompt to an excel cell and then pass the query on to Oracle, or have a PL SQL prompt work from Excel?
    Thanks,
    Ben

    The 'prompt' as you call it is a sqlplus feature, so does not belong to the SQL language
    You would need to write a stored procedure returning a resultset.
    create or replace procedure foo(rc in out sys_refcursor, p_item) as
    begin
    open rc for
    'SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '||p_item;
    end;
    and call that using ODBC or asp.net
    Obviously this is profusely documented.
    Sybrand Bakker
    Senior Oracle DBA

  • Export SQL query from link or button

    I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
    How can I best do this?
    I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.
    Thanks in advance,
    Rich
    Edit:
    Found 'Report Query' functionality in Apex v3.2.1: However I am unable to get this to work; tells me my printer is not set up. I don't want to print the detail, I want it to be downloaded into excel... I don't have a printer configured - & don't want to. The URL provided for download as attachment is:
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=reportname
    I also have no page 0.
    Help?
    Edited by: rdarlin2 on Sep 16, 2011 11:14 AM

    rdarlin2 wrote:
    I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
    How can I best do this?
    I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.10,000ft overview of one way to do this:
    <li>Create a package with private functions that return the SQL for each "canned query", and a public switch function that returns a query function based on an input parameter:
    create or replace package qry
    is
      function selector (p_req_qry in varchar2) return varchar2;
    end qry;
    create or replace package body qry
    is
      function emp_qry return varchar2
      is
      begin
        return 'select * from emp';
      end emp_qry;
      function dept_qry return varchar2
      is
      begin
        return 'select * from dept';
      end dept_qry;
      function selector (p_req_qry in varchar2) return varchar2
      is
      begin
        return
          case p_req_qry
            when 'EMP' then emp_qry()
            when 'DEPT' then dept_qry()
          end;
      end selector;
    end qry;
    /<li>Create 2 pages
    <li>On page 2 create a standard SQL report region of type SQL Query (PL/SQL function body returning SQL query):
    Region Source
    return qry.selector(:request);*(o) Use Generic Column Names (parse query at runtime only)*
    Maximum number of generic report columns
    number of columns in your biggest query
    Report Template
    export: CSV
    <li>On page 1 create an HTML region (or use an APEX list) with a link for each query, where the REQUEST component of the URL is the parameter used to select a query in the <tt>qry.selector</tt> function:
    <ul>
      <li>&lt;a href="f?p=&APP_ID.:2:&SESSION.:EMP"&gt;Emp</a></li>
      <li>&lt;a href="f?p=&APP_ID.:2:&SESSION.:DEPT"&gt;Dept</a></li>
    </ul>However this begs the question: Why bother? What's Excel got that APEX hasn't?

  • Sql query from Oracle/Hyperion

    Hi, guys. my problem is:
    My work environment is windows 2003 server sp2 on both servers, to have a Hyperion System 9.2 and the other Hyperion System 9.3.1. I have an Oracle ODBC server to fetch data.
    When you load data from an Oracle database (version 9.2.0.5) to an Essbase cube through a rule file sql Hyperion System with version 9.2 everything works fine, I am all the necessary information. But when I try to do the same (in another server, version 9.3.1 Hyperion System) with the sql query does not do well. What is the problem. the bag is a bad version or set the ODBC
    please help me
    Thank you very much.
    Alberto.

    without knowing more information, I'm going to guess the probem is with the ODBC driver. Try using the SQL in a tool like toad to use the ODBC to query the data. That will tell you if it is an ODBC issue or not.

  • It is possible to execute a SQL query from OMBPlus?

    We have some simple SQL scripts we'd like to be able to incorporate into our existing TCL scripts, instead of having to run them outside of OMBPlus in sqlplus. Is is possible to run a SQL SELECT query from OMBPlus and/or TCL? And get a result set back to iterate through?
    Thanks,
    Jim C.

    You can execute SQLPlus from OMB or just get down and use JDBC to execute the SQL, see others posts on forum such as below;
    How to run SQL from OMB+
    Cheers
    David

  • Passing variables to SQL query from checkboxes

    Hello,
    I have a cursor which gets different ids from an id table. The cursor is something like this:
    CURSOR id IS
             SELECT distinct id_ FROM I
                      order by id_;I then iterated through the cursor to made checkboxes to choose multiple ids:
    FOR i IN id
           LOOP
            htp.p('<tr>
           <DIV align="left"><td><input type="checkbox" name="option" value=ID '||i.id_||'> </td></tr>');
             htp.p('<font size="'||3||'">'
             ID'||i.id_||'</a></font>'
             ||'</a>' );
           htp.br;                       
           END LOOP;The values of the checkboxes were extracted by:
    var ids ="";
    for (var j = 0;j < document.form.option.length; j++)
                 if (document.form.option[j].checked)
                     ids = ids + document.lf.option1[j].value + "\n";
            }I have the following SQL query:
    Select * from Persons where Identification = ...; I would like to use to pass the values of the checkboxes (i.e. the variable ids ) to my SQL query. I want the user to select multiple values for the checkboxes. For example, they can select 4 and 3. I want to pass the difference to my SQL query....that is, I want the id to be 1. So, I want this:
    Select * from Persons where Identification = 1; Any ideas how to do this? Also my code above is in different procedures within a single package.

    Your requirement is not very clear. What happens when you select 3 checkboxes? What will be the difference between them? How do you pass that information to the oracle report?

Maybe you are looking for

  • "invitation emails couldn't be sent."

    I have a 50m Keynote '09 file and I'm trying to share it on iWork.com. Here are the steps to repeat: 1) Edit the keynote file. 2) From the menu bar, click Share > Share via iWork.com... 3) Since this is an update - not a new file, choose the existing

  • PrE 8 and PrE9 in the same time

    I have in my computer installed PrE8 and PrE9. Is there any disadvantage of having both these programs (such as some kind of interference)? Shall I delete PrE8?

  • How can I delete and reinstall iPhoto?

    There is an issue with the new operating system and iPhoto when creating a book, how do I delete and reinstall iPhoto?

  • Install Adobe Edge preview 4

    I installed Adobe Edge Preview 3 in 2011. I deleted Preview 3 today in order to install Adobe Edge preview 4, which came out Jan 18, 2012. However, my installation encountered errors. The popup window says that "A conflicting or prerelease version of

  • Workspace Question on Packages

    I have crated a couple of classes and packaged them. However the workspace in JDeveloper doesn't separate them by packages. What should I do? Thanks.