Hello,

I used to write an importer in Empire-db that has a CLOB (LONGTEXT) column. I wanted to update existing and insert new items, so I did:

cmd.set(DB.col1.to(col1));
cmd.set(DB.col2.to(col2));
// ...
cmd.set(DB.clob_col.to(string));

// try update
int updateCount = this.db.executeUpdate(cmd, this.conn);

if (updateCount < 1) {
        // not found, insert
        cmd.set(DB.id.to(id));
        this.db.executeInsert(cmd, this.conn);
}

which is, afaik, the way to do it.

Turns out: on the first run clob_col is always empty. I debugged and everything looked fine. The same code is used for INSERT and UPDATE, only the generated statement is different.

Now I tracked it down to DBClobData, which uses a java.io.Reader internally. That reader is consumed on the first try (UPDATE) so its empty on the second try (UPDATE).

AFAIK the DBCommand is designed to be used that way. So I think this is a bug. What do you think?

- jan

Reply via email to