从SQL TYPE检索值到resultSet

时间:2014-05-05 07:06:10

标签: java sql oracle resultset

我正在使用TYPE关键字查询oracle sql中的表我正在区分结果。查询在下面

SELECT row_id,
  distribution_id,
  product_id,
  'CARD' TYPE
FROM product_distribution
WHERE status = 'Pending'
AND date_out < SYSDATE
UNION ALL
SELECT row_id,
  distribution_id,
  product_id,
  'CASH' TYPE
FROM prod_cash_distribution
WHERE status = 'Pending'
AND date_out < SYSDATE

在使用结果集检索时我得到的类型为null。但我需要根据执行的查询获得卡或现金?提前致谢

这是java Code

String sql=" SELECT row_id,distribution_id,product_id,'CARD' TYPE
    FROM product_distribution
    WHERE status = 'Pending'
    AND date_out < SYSDATE
    UNION ALL
    SELECT row_id,distribution_id,product_id,'CASH' TYPE
    FROM prod_cash_distribution
    WHERE status = 'Pending'
    AND date_out < SYSDATE";
PreparedStatement prest = prest = con.prepareStatement(sql);
ResultSet rs = prest.executeQuery();
             while(rs.next()){
                    prodDto.setId(rs.getInt(1));
                    prodDto.setDistributionID(rs.getInt(2));
                    prodDto.setprodId(rs.getString(3));
                    prodDto.setType(rs.getString(4)); //here i'm getting null
                  }

0 个答案:

没有答案