> 
> Sequoia doesn't support postgres-specific features like "select
> nextval('sequence')". This would be interpreted as simple select
> statement (?), which will be executed on only one single backend and
> therefore only on one backend the sequence value will be increased.
> 
> It is necessary to map all postgres sequence queries to the following
> stored procedure syntax:
> 
> {call nextval(sequenceName)}
> 
> See Section 6.7 in the sequoia user guide.
> 
> The stored procedure call will be broadcasted to all backends, so that
> the sequences on all backends will be increased.
> 

Sebastion

Our developers have changed the calls from this:

else if (t_database_type.equals("POSTGRESQL"))
{
Statement t_seq = conn.createStatement();
ResultSet rs = t_seq.executeQuery("select nextval('" + sequence + "')");
if (rs.next())
t_uid = rs.getString(1);
t_seq.close();
}

to the following:

else if (t_database_type.equals("POSTGRESQL"))
{
CallableStatement cs = conn.prepareCall("{? = call nextval('" +
sequence + "')}");
cs.registerOutParameter(1, Types.BIGINT);
cs.execute();
t_uid = String.valueOf(cs.getLong(1));
cs.close();
}

The above code appears to follow the guidelines, but we're still having
problems with sequences being out of sync on each database backend.
It's not the case that one of the sequences on one backend is being
updated and the other isn't, they ARE both being updated, but have
different values in each.

Any help is appreciated.

Regards

John

-- 
John Gardner - Tagish Ltd.
Infrastructure Manager
T: 01665 833 322
F: 01665 830 695
D: 01665 833 310
_______________________________________________
Sequoia mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/sequoia

Reply via email to