• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing nested query in jdbc

 
Ashwani Singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
1
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ashwani,
try to post your question in the JDBC forum.

Sincerely,
Bernhard
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Already moved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic