Getting the sql code of an expression(by Anizio)

Hi to All
I want to know if is possible get the real string sql of an expression using some class of toplink?
For example:
I have an expression "Expression ex = new ExpressionBuilder().get("CadTitular").get("titId").equal(5)"
This is equals the following sql command "select * from CadTitular where tit_id = 5"
I need get the sql value to leave an expression toplink
Thank

Yes, really this functioned, but help me again
I tryed with other object "InsertObjectQuery", so, the result is "null"
see the code
public static void insertObjectQuery(DatabaseSession session){
InsertObjectQuery query = new InsertObjectQuery();
Address end = new Address();
Employee empregado = new Employee();
empregado.setEmpId(new Long(560));
end.setAddressId(new Long(102));
end.setCity("Manaus");
end.setCountry("Brasil");
end.setPCode("21547");
end.setProvince("CN");
end.setStreet("AV.");
end.addEmployee(empregado);
query.setObject(end);
query.dontCascadeParts();
DatabaseRow row = new DatabaseRow();
query.prepareCall(session, row);
String sql = query.getTranslatedSQLString(session, row);
System.out.println("VALOR DE STRING SQL: " + sql); //print null
session.executeQuery(query);
}

Similar Messages

  • Getting real sql code

    Hi to All
    I want to know if is possible get the real string sql of an operation using some class of toplink?
    For example:
    I have an expression "Expression ex = new ExpressionBuilder().get("CadTitular").get("titId").equal(5)"
    This is equals the following sql command "select * from CadTitular where tit_id = 5"
    I need get the sql value to leave an operation toplink for example:
    ExpressionBuilder emp = new ExpressionBuilder();
    Expression firstNameExpression = new ExpressionBuilder();
    firstNameExpression = emp.get("fName").like("%a%").and(new ExpressionBuilder().get("empId").greaterThan(10));
    ReadObjectQuery query = new ReadObjectQuery();
    query.setReferenceClass(Employee.class);
    query.setSelectionCriteria(firstNameExpression);
    //********************GETTING THE SQL CODE***********************
    DatabaseRow row = new DatabaseRow();
    query.prepareCall(session, row);
    String sql = query.getTranslatedSQLString(session, row);
    System.out.println("STRING VALUE: " + sql);
    Employee employee = (Employee)session.executeQuery(query);
    This code print "SELECT EMP_ID, F_NAME, GENDER, END_DATE, L_NAME, VERSION, START_DATE, END_TIME, START_TIME, ADDR_ID, MANAGER_ID FROM EMPLOYEE WHERE ((F_NAME LIKE '%a%') AND (EMP_ID > 10))"
    But when I use to the following objects : UpdateObjectQuery, InsertObjectQuery, ReadAllQuery, WriteObjectQuery, The code above it does not function. How I can do this?
    How I can do using the UnitOfWork?
    Thank

    If you want to copy your LOG output from toplink from these objects (UpdateObjectQuery, InsertObjectQuery, ReadAllQuery, WriteObjectQuery) and have it run perfectly in a SQL editor, you need to turn on NativeSQL. Otherwise, things like dates will need to be reformatted by hand. Also, you will need to turn binding off. Both of these options (NativeSQL, binding) can be turned on/off via sessions.xml and from JAVA.
    Zev.

  • How will get the source code of all the tables in a given schema using SQL?

    Hi All,
    How can we get the source code of all the tables in a given schema using SQL?
    Thanks in Adv.
    Junu

    Try something like...
    set heading off
    set pagesize 0
    col meta_data for a96 word_wrapped
    set long 100000
    SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner) ||';' AS meta_data
    FROM dba_objects
    WHERE owner = '<SCHEMA NAME>'
      AND object_type not in (<list of stuff you do not want>);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I get the return code of SQL*Plus under Win2000Pro

    How can I get the return code of SQL*Plus under Win2000Pro ?

    In a DOS batch script? Try ECHO %ERRORLEVEL%
    -- CJ

  • Where to get the source code of the owa_cookie.send procedure?

    I want to know where you get the source code of the owa_cookie.send procedure? I can only get the header of this package from ...\RDBMS\ADMIN\pubcook.sql. Could you paste the whole source code here and then I can modify it to set the 'httponly' attribute? I also have a problem that after changing the package, how to use the package I changed? Does it still a system package here? Or it has been changed to an user-defined package in database and I need to execute the package on the database for the web server?
    Thank you!

    Hi Arun,
    I am unable to see the pcui_gp components in the DTR ,I require this in order to get the source code of one of its component.
    Can you please tell me the step by step procedure getting those pcui_gp components from J2ee engine to the  dtr or  NWDI.
    If there are any documents on pcui_gp components exclusively please do forward to my mail id [email protected]
    Thansk and Regards,
    Anand.

  • How to get the SQL queries based on SQL_ID.

    Hi Experts,
    I want to get the SQL queries based on SQL_ID.
    I have tried the following query,but I am not getting full query.
    [code]SET linesize 132 pagesize 999
    column sql_fulltext format a60 word_wrap
    break on sql_text skip 1
    SELECT   REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
    FROM   dba_hist_sqltext s
    WHERE   s.sql_id = '7tvurftg8zryb';[/code]
    One of my friend said use grid to get full query text.
    Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
    Please help me.
    Thanks in advance.

    You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
    column sql_text format A10000
    set echo off
    set head off
    set feed off
    set verify off
    set termout off
    set lines 10000
    set long 1000000
    set trimspool on
    set pages 0
    Thanks!

  • How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"

    How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
    I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
    Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
    I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
    use msdb
    SELECT [JobName] = JOB.name,
    [Step] = HIST.step_id,
    [StepName] = HIST.step_name,
    [Message] = HIST.message,
    [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
    WHEN HIST.run_status = 1 THEN 'Succeeded'
    WHEN HIST.run_status = 2 THEN 'Retry'
    WHEN HIST.run_status = 3 THEN 'Canceled'
    END,
    [RunDate] = HIST.run_date,
    [RunTime] = HIST.run_time,
    [Duration] = HIST.run_duration,
    [Retries] = HIST.retries_attempted
    FROM sysjobs JOB
    INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
    -- CHANGE THIS
    -- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
    ORDER BY HIST.run_date, HIST.run_time

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • How to get the Sql inside Omni SQL portlet.

    Hi,
    We are trying to find a table/view which stores/holds the Sql and Pl/Sql code of Omni Pl/sql portlets.
    Thanks,
    Ram.

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • How can i get the tax code from Condition record number

    Hi all,
    i have the Condition record number from which i have to get the tax code as i looked inthe KNOP that Condition record number there but no tax code is maintained there.
    so is there any other way to find the tax code for particular Condition record number
    Regards
    suresh

    hi suresh,
    can u tell me the field name for condition record number and in which table it is stored.
    because i knew one condition number which is stored in table EKKO and the field name is
    KNUMV- Number of the document condition.
    from ekko take relevant details and look for  ekpo where u find the tax code
    filed name of the tax code id MWSKZ- Tax on sales/purchases code

  • How can i get the source code from java concurrent program in R12

    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    Zulqarnain

    user570667 wrote:
    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    ZulqarnainDid you see old threads for similar topic/discussion? -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Java+AND+Concurrent+AND+Source+AND+Code&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • I purchased and downloaded Adobe Photoshop Elements 13 from Amazon and when I try to open it, it's asking for a "Redemption Code".  Where do I get the that code?

    When I try to open the Adobe software, it asks from the Redemption Code when on an Adobe web site.  The instructions that came in the download say that this is a 24 digit code of numbers and letters.  The only thing I got from Amazon was an Order Key, which is also 24 digits, but only numbers and the software didn't like that code…  I walked through the steps on the Adobe web site to get my redemption code, but the final step before giving me my redemption code is to enter my redemption code…  I have to enter the code for them to give me the code…???  Am I missing something???  Do I get this "Redemption Code" from Amazon, or from Adobe?

    You would get the redemption code, or perhaps even the serial number, from whomever you purchased the software from, apparently Amazon, so talk to them.  This wouldn’t be the first time they’ve sold something that didn’t have all the numbers needed to license it.
    A redemption code is something that is usually on the inner disc packaging if you purchase the media in a box, and there is a barcode on the outside of the packaging that must be scanned at the checkout register to activate the hidden inner code so you can redeem it at home on that website.  This is what happens if you buy PSE from a brick-and-mortar store like Best Buy.  I don’t’ know what happens if you purchase the downloaded version as I have never done that.
    A redemption code is 24-digits of letters and numbers that you enter into a website to get a serial number, once and only once.  The serial number of only 24-digits, no letters, is what you enter into the software during the install or when you run it and it asks if you want to register or run in a trial mode—whatever the exact phrasing is.
    In any case it sounds like you don’t have either a redemption code or serial number—although perhaps something is listed on the purchase confirmation or your account online at Amazon or even in an e-mail from Amazon.

  • How to get the Response Code when a URL is launched from Web Dynpro

    Hello Experts,
    I have a Web Dynpro Application in which in one of its views i have an IFrame UI element in which i will show a resource stored somewhere ..
    But before showing it i want to check if the resource actually exists. For this i have to check the HTTP Response code from Web Dynpro Application without setting it in the Iframe..
    I am using the following code to get the Response Code:
    try{
    URL url = new URL("Some Url");
    HttpURLConnection.setFollowRedirects(false);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.connect();
    wdComponentAPI.getMessageManager().reportSuccess("Response code ="+connection.getResponseCode());
    }catch(Exception e){
    wdComponentAPI.getMessageManager().reportSuccess("Exception");
    Now the Problem is whatever response Code occurs 403 (for No Proper Authorization), 404 (for Resource not found) etc..
    i always get Response Code=  500 (which is for Internal Server Error) shown in the messgae i have printed.
    Please let me know the correct way of getting the Response Code from Web Dynpro.
    Also my resource is lying on a SAP Portal 6.4
    Best Regards
    Sundeep
    Edited by: Sundeep Sethi on Feb 18, 2008 9:07 AM
    Edited by: Sundeep Sethi on Feb 18, 2008 10:23 AM

    Hi,
      Check this code from /thread/5242768 [original link is broken] if it works.
    try{
    URL myurl = new URL("http://calendar.google.com");
    URLConnection connection = myurl.openConnection();
    if(connection instanceof HttpURLConnection) {
    HttpURLConnection httpConnection = (HttpURLConnection) connection;
    HttpURLConnection.setFollowRedirects(true);
    httpConnection.setRequestMethod("HEAD");
    httpConnection.connect();
    System.out.println("Response = "+httpConnection.getResponseCode());
    catch(Exception e) {
    // print exception
    Regards,
    Harini S

  • When I try to get the key code for office it tells me its already been used.  My mac had a new hard drive in its first year, could it be because of this?  How can I get the office I've paid for but never used?

    My mac had to have a new hard drive in its first year.  Now, when I try to get the key code for office it tells me its already been used.  How do i get the office I've paid for but never used?

    The product key is sent to you by email as part of the purchase confirmation.
    If you have lost it, log into your Microsoft account.

  • How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your repl

    How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your reply. Thanks!

    It's good to read Antoniad's post.  It reassures me that I can use my new iPad as an international communication device which is the reason I purchased the thing.  However, I called Verizon today (my provider of cellular data) who told me that I can't just pop in a SIM card as you suggested.  He also said that he was from the "Pre-Pay" division of Verizon and he was certain that I couldn't do what I planned to do.  I was extremely disappointed as I had called Apple prior to buying the iPad and I read the algorhythm on the website for choosing an iPad before purchasing.  Those sources were quite specific and the information seemed clear.  I would be able to use my iPad to communicate through cellular connections while traveling on the road, literally, abroad.  I was told that I could pop in a data card wherever I was, just as you indicated in your message above, and voila I was good to go.  The Verizon rep definitively rained on that parade, but said that I might be able to do this if I have a "Post-Pay" account, a different area of Verizon.  I haven't had the chance to talk to this division yet, so I looked to Apple's Support for answers.  Maybe I will find out that I can use my iPad as an international communication device while traveling on the road afterall, however, it appears I may need a different type of account (Post-Pay), something I was never warned about. Can I switch to this kind of account?  I don't know.  I have to find out.  If you have any information about this issue, it would be good to share since I strongly suspect there are others who bought the iPad for the same purpose that I have.

  • When updating iTunes on my MAC, I get the error code (-42408)

    When I try to open iTunes on my MAC it states I need to update. After updating, it closes and when I open again, I get the same updates. When I choose to not update, I get the error code (-42408). What can I do now?

    What is your iTunes version? The error message indicates missing ressources or software conflicts.
    Did you try to downgrade from iTunes version '11 to '10?

Maybe you are looking for