#1 2010-12-11 17:36:59

nikk
Guest

context in SQL query

Hi,

I am passing a context variable "context.code" in a sql query like this in toracleinput

Query-----------------

"select id from Bak where
c_id =(select c_id from cpy where c_name like 'HMM') and
l_id = (select l_id from lpy where ct_name like UPPER('+context.code+') )"

-------------------------

This query runs fine without any error but does not return a single row.I have verified the schema of all tables & data also.I could not figure out the solution.Please reply asap as i m stuck.

Thanks
Nikk

#2 2010-12-13 03:33:30

alevy
Member
Registered: 2009-11-20
Posts: 1486

Re: context in SQL query

Because you're confusing SQL string delimiters and Java string delimiters.  Your syntax should be:

Code:

"select id from Bak where 
c_id = (select c_id from cpy where c_name like 'HMM') and 
l_id = (select l_id from lpy where ct_name like UPPER('"+context.code+"') )"

Offline

#3 2010-12-13 07:52:14

nikk
Guest

Re: context in SQL query

Hi Alevy,

I have even tried this before but the issue still remains unresolved.No rows are being returned.Please help!!!

Regards,
Nikk

#4 2010-12-13 08:02:29

alevy
Member
Registered: 2009-11-20
Posts: 1486

Re: context in SQL query

If you're not getting an error, are you sure the query returns results if run directly in Oracle?

Connect tOracleInput to tJava with OnComponentOK and run with the following to check the SQL statement actually used:

Code:

System.out.println((String)globalMap.get("tOracleInput_1_QUERY"));

Offline

Board footer

Powered by FluxBB