Sitemap

Amicuk Programming Answers

Getting real sql code

-0001-11-30   Views:1

Advertisement

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)"

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

The replay answer
Advertisement
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.

Go to See the other 5 answers

Got the following reply from db-kernel: SQL-Code :-903

Category:DefaultRelease time:2015-10-11Views:130

Dear Experts, I am having a problem running MaxDB Data backup on Netbackup.... Please se log below and suggest. 2011-04-11 13:30:38 Using environment variable 'TEMP' with value 'C:\Windows\TEMP' as directory for temporary files and pipes. Using conne[More]

PL/SQL code written in db or in application...????

Category:DefaultRelease time:2015-10-11Views:130

Hi , Which is the best...at performance , maintability... e.t.c.??? To write PL/SQL as validation process of data values going to be inserted in db: 1) as db trigger (before insert or update row-level trigger) 2) in application level - in Forms10g...[More]

REPORT WITH PL/SQL  CODE

Category:DefaultRelease time:2015-10-11Views:130

DECLARE SQ VARCHAR2(100); BEGIN SQ := 'SELECT * FROM EMP WHERE EMPNO=7788'; RETURN SQ; END THE ABOVE PL/SQL CODE WORKING FINE BUT I NEED CONDITION BASED ON ENAME SQ:='SELECT * FROM EMP WHERE ENAME=''SCOTT''; IT IS GIVEING ERROR WHAT TO DO?Hi, You're[More]

How to 100% Protect PL/SQL Code By Wrapped in Oracle Database 10g R2

Category:DefaultRelease time:2015-10-11Views:130

Hello, Is Possible to 100% Protect PL/SQL Code By Wrapped in Oracle 10g R2 ? If it is not possible by wrap in oracle 10g R2, Please, let me suggest, how i will be able to 100% protect PL/SQL code in Oracle Database 10g R2. Because, I have lot of func[More]

How to reference LEVEL in a TREE's SQL code

Category:DefaultRelease time:2015-10-11Views:130

Is it possible to somehow reference LEVEL in a tree's sql code so that you can use a decode statement to selectively create links on specific levels only i.e. NOT on the root level? e.g. select "CHILD_ID" id, "PARENT_ID" pid, "NAM[More]

PL/SQL Code not working without debug statements

Category:DefaultRelease time:2015-10-11Views:130

Hi Guys, I have a pl/sql code in a procedure, logic iterates through almost 40K records, conditional delete and update. When I execute this code, I dont see the deletes and updates happening, though procedure executes for 8 minutes and exits wihtout[More]

Can I have a PL/SQL code for LOV

Category:DefaultRelease time:2015-10-11Views:130

Hi, I apologize for this dumb question. I have been so out of touch with dev (almost 8 years). Plus new to pl/sql. I am creating a status report application. On the dashboard, I currently have some metrics (horizontal charts). I wanted to expose thes[More]

Multiple SQL queries in additional PL/SQL code in Report

Category:DefaultRelease time:2015-10-11Views:130

Hello gurus, I have a form in my portal populated some searching parameters and these parameters inserted into some temporary tables such as name_temp, addr_temp. And then I have a report that run based on these parameters, I have added additional PL[More]

How to change the profile value in the pl/sql code without making change in the database

Category:DefaultRelease time:2015-10-11Views:130

How to change the profile value in the pl/sql code without making change in the database.I have program ,where if the profiles 'printer and nunber of copies ' are set at the user level, by default when the report completes the O/p will be sent to the[More]

How can one  read a Excel File and Upload into Table using Pl/SQL Code.

Category:DefaultRelease time:2015-10-11Views:130

How can one read a Excel File and Upload into Table using Pl/SQL Code. 1. Excel File is on My PC. 2. And I want to write a Stored Procedure or Package to do that. 3. DataBase is on Other Server. Client-Server Environment. 4. I am Using Toad or PlSql[More]

Query SQL code gets deleted after export to Excel. "Query must have at least one destination field"

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I'm getting really frustrated by this Access error. It happens when I export the result of a query through an Access macro to Excel, the first time it runs well but the next time, there is a chance that the query won't run and the error "Quer[More]

Hot
Hi I got two questions on JNDI/DNS service provider: 1) How to resolve a host name when i got an IP I understand How I do it inverse. Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory") [More]
Hey, I'm hoping someone can help me out. I'm pretty new at this. I just submitted my first podcast to itunes and the listing won't display me episode descriptions. Would someone be so kind as to check my RSS file? The URL of the RSS file is www.indig [More]
hello anybody can help- unable to view PDF files from the webBack up all data. Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C): /Library/Internet Plug-ins In the Finder, select Go ▹ Go to Fold [More]
Hello, I am trying to configure an external content server for attachment storage on a SRM 4.0 system. I had a look on both sap Help, SDN forum and config guides, but I didn't find the customizing steps description. Can anyone help me. Regards. Vadim [More]
So i got a 4S about 2 weeks ago and I guess from day one it has not shown my recent calls.....Help! Anyone else have this issue?Hey Jarris. I have noticed that your past has been in here for some hours without an answer. I would like to point out tha [More]
I am trying to think of how to authenticate a client to a weblogic web service using a client certificate. The wrinkle is that a Web Server (iis or whatever) will be handling the ssl part and forwarding non-secure to weblogic. The cert will still be [More]
I have translated some c code that we use to encrypt files. I have a problem when I try to move the code to another machine. I wrote the code on a sun under solaris 8, using java 1.4.0-b92. The other machine I am trying is also solair 8, with the sam [More]
I have a requirement to establish Database connection from Agent through Plug-in. Ex: My plug-in metadata will have a perl script which gets executed in each individual agents and it should connect to the OEM Repository database to execute a package. [More]
I am trying to install Oracle 9iAS on Linux (RH7.2), but the installation stops with the error "You must have at least 256 MB RAM installed on this machine to install Oracle9iAS Unified messaging" I don't understand, "this machine" has [More]
I got a new iBook G4 12in a week ago. Love everything about it apart from the screen. As soon as I booted it for the first time I noticed the screen wasn't particularly bright and that the colours were washed out. It's usable but not of a level I'd e [More]