aspose file tools*
The moose likes JDBC and the fly likes Executing nested query in jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Executing nested query in jdbc" Watch "Executing nested query in jdbc" New topic
Author

Executing nested query in jdbc

Ashwani Singh
Greenhorn

Joined: May 10, 2013
Posts: 25
I have the following sqlstatement:

SELECT x.fieldname AS FIELD_NAME, y.hop AS HOP_NO, x.src_tbl AS SRC_TBL, x.src_field AS SRC_FIELD, y.src_tbl AS TGT_TBL, y.src_field AS TGT_FIELD
FROM (SELECT switch(a.col_name = 'LN_ID','LN_ID',
a.col_name = 'FNM_LN_ID','LN_ID',
a.col_name = 'CURR_UPB_AMT','UPB',
a.col_name = 'LN_REVW_CURR_UPB_AMT','UPB')
as fieldname,
a.COL_NAME as src_field ,
b.TAB_NAME as src_tbl ,
Switch(
b.Sch_name ='QAS_DB', '0',
b.Sch_name ='CDR_DB', '1',
b.Sch_name ='STG_DM','2',
b.Sch_name ='NUCDM', '3')
as Hop
from SYS_COLUMNS a,
SYS_TABLE b
where a.TAB_ID = b.TAB_ID
) AS x, (SELECT switch(a.col_name = 'LN_ID','LN_ID',
a.col_name = 'FNM_LN_ID','LN_ID',
a.col_name = 'CURR_UPB_AMT','UPB',
a.col_name = 'LN_REVW_CURR_UPB_AMT','UPB')
as fieldname,
a.COL_NAME as src_field ,
b.TAB_NAME as src_tbl ,
Switch(
b.Sch_name ='QAS_DB', '0',
b.Sch_name ='CDR_DB', '1',
b.Sch_name ='STG_DM','2',
b.Sch_name ='NUCDM', '3')
as Hop
from SYS_COLUMNS a,
SYS_TABLE b
where a.TAB_ID = b.TAB_ID
) AS y
WHERE x.hop=(y.hop-1)
and x.fieldname=y.fieldname;


i want to execute this statement in jdbc.This query will return a resultset which i need to use.Which class i should opt for?Statement,PreparedStatement or Callablestatement? I used Statement but it was throwing exception as:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.


Please help.
Bernhard Goetz
Ranch Hand

Joined: Jan 07, 2013
Posts: 33

Hello Ashwani,
try to post your question in the JDBC forum.

Sincerely,
Bernhard
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Already moved.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing nested query in jdbc
 
Similar Threads
Assertion ?
need help to optimize this query
Bug in JDBC ? Simple Select statement not returning a resultSet
Bean that throws exceptions are not handled in JSP[solved]
convert Double to BigInteger and retrieving byte array