db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriele Kahlout <gabri...@mysimpatico.com>
Subject Getting an attribute (the rid) of the affected tuples in an update
Date Mon, 15 Mar 2010 13:58:19 GMT
Hello,

In my code, I often need to add a tuple  to another relation, so that
I update another in another relation. Examine this code:

private static int rescheduleObject(final String[] expDef, int batch,
final Statement st, ResultSet rs) throws SQLException, Exception {
		final int objectId = rs.getInt(SqlWrapper.index); //assume rs has
already been nexted.
		try{
			rescheduleObject(st, batch, objectId);
		} catch(SQLException e){ //batch is full
			final int res = st.executeUpdate(SqlWrapper.insert(batTable));
			assert(res == 1);
			batch = getMaxBatch(st);
			rescheduleObject(st, batch, objectId);
		}
		return objectId;
	}

	private static void rescheduleObject(final Statement st, int batch,
final int objectId) throws SQLException {
		final int res = st.executeUpdate(SqlWrapper.update(objTable,
batColumn, batch, objTable.getIdColumn(), objectId));
		assert(res == 1);
	}

I'm not happy having to use batch = getMaxBatch(st), but would like to
get exactly the batch (primary key of batTable) inserted in the 2
lines above it. Are there ways to get it?

-- 
Regards,
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer
OR with " ACK" appended to this subject within 48 hours. Otherwise, I
might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x,
this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧
¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a
priori senders, or if the subject of this email ends with a code, eg.
-LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y.
In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).

Mime
View raw message