I. Version
· Add or delete a version
The following code creates a new sub-version based on the default version:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Seversion v_1 = new seversion (Conn, seversion. se_qualified_default_version_name );
V_1.setname ("v_1 ");
V_1.create (true, v_1 );
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}
It is easier to delete a version:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Seversion v_1 = new seversion (Conn, "v_1 ");
V_1.delete ();
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}
· Edit a version
The key to version editing is to manage the version status. The following code shows how to delete a record from a version Dataset:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Seversion version = new seversion (Conn, "V1 ");
Seobjectid oldstateid = version. getstateid ();
Sestate oldstate = new sestate (Conn, oldstateid );
If (oldstate. isopen ()){
Try {
Oldstate. Close ();
} Catch (exception e ){
E. printstacktrace ();
}
}
Sestate newstate = new sestate (conn );
Newstate. Create (oldstateid );
Version. changestate (newstate. GETID ());
Sedelete delete = new sedelete (conn );
Delete. setstate (newstate. GETID (),
New seobjectid (sestate. se_null_state_id ),
Sestate. se_state_diff_nocheck );
Delete. fromtable ("test", "objectid = 3 ");
Delete. Close ();
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}