|
|

楼主 |
发表于 2013/3/19 11:42:09
|
显示全部楼层
我是在主表中输入信息后,在子表中通过搜索主表中的编号(也就是子表中的外键),来自动的填值,也就是触发它,
public String fill (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
Integer HR_TRAINNEED_ID = (Integer)value;
if (HR_TRAINNEED_ID == null || HR_TRAINNEED_ID.intValue() == 0)
return "";
String sql = "select * FROM HR_TRAINNEED h, HR_LEDGER c "
+ "WHERE c.IsActive='Y' AND h.HR_TRAINNEED_ID=c.HR_TRAINNEED_ID(+)"
+ " AND h.HR_TRAINNEED_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, HR_TRAINNEED_ID.intValue());
rs = pstmt.executeQuery();
if (rs.next())
{
Integer ii = new Integer(rs.getInt("HR_TRAINNEED_ID"));
//Integer ii = new Integer(rs.getInt("HR_TARGET"));
if (rs.wasNull())
mTab.setValue("HR_TARGET", null);
else
mTab.setValue("HR_TARGET", ii);
/* Contact
ii = new Integer(rs.getInt("AD_User_ID"));
if (rs.wasNull())
mTab.setValue("AD_User_ID", null);
else
mTab.setValue("AD_User_ID", ii);*/
}
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
}
return "";
}
这是我按照m_inout 来写的,但是我调试了下,到rs.next 后,就到finally了,所以这个错误的,。 |
|