ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernd Kappler <Bernd.Kapp...@genedata.com>
Subject Fetching ids from oracle and postgresql sequences
Date Thu, 23 Aug 2007 15:44:37 GMT
Hi,

we have an application that should work with oracle and postgresql as a
database backend. Unfortunately, the syntax for getting values from a
sequence is slightly different for both databases and we therefore
cannot use the same sql for both.

Has somebody solved this problem already? Where would be the best place
to do the switch? Would you recommend to create two different statements
and do the switching in the java code, i. e. something like

<select id="getNextFromSequence-Postgresql">
...
</select>
<select id="getNextFromSequence-Oracle">
...
</select>


and in java

		if (sqlMapClient.getCurrentConnection() instanceof OracleConnection) {
			sqlMapClient.queryForObject("getNextFromSequence-Oracle");
		} else {
			sqlMapClient.queryForObject("getNextFromSequence-Postgresql");
		}

or is there a clever way to do that with dynamic sql?

Best regards

Bernd







Mime
View raw message