`

使用dfc运行DQL并取得相应sql的代码

 
阅读更多

query.setDQL("SELECT r_object_id, object_name, title FROM dm_cabinet");
IDfCollection queryRsult
= query.execute(session,DfQuery.READ_QUERY);

while (queryRsult.next())
{
// Spin through the attributes
for (int i = 0; i < queryRsult.getAttrCount(); i++)
{
IDfTypedObject typedObj
= queryRsult.getTypedObject();
IDfAttr attr
= queryRsult.getAttr(i);
System.out.println(
"Attribute Name: " + attr.getName()
+ "Attribute Value: " + typedObj.getString(attr.getName()));
}
}

queryRsult.close();

//get sql
IDfCollection coll;
String sqlResult
= "";
coll
= session.apply(null, "GET_LAST_SQL", null, null, null);
if(coll.next())
{
sqlResult
= coll.getString("result");
}

coll.close();

System.out.println(sqlResult);

if (session != null)
{
sessionMgr.release(session);
}
}
catch (DfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics