In DFC one can execute SQL directly (bypassing DQL) using the IDfSession.apiExec()
method. The problem is that the method is marked as deprecated in the current (6.x, 7.x) versions of the DFC API.
Here's some example code using the deprecated method:
IDfSession session;
(...)
String sql = "UPDATE dm_sysobject_s SET r_modifier = 'hacker' WHERE r_object_id = '<some_id>'";
session.apiExec("execsql", sql);
This works fine, but as already mentioned apiExec
is deprecated.
I've also tried an alternative approach:
(...)
IDfQuery query = new DfQuery(sql);
query.execute(session, IDfQuery.DF_EXEC_QUERY);
To my knowledge this ought to work, but I keep getting the following message:
[DM_QUERY_E_REG_TABLE_PERMIT_IN]error: "You have insufficient privilege to UPDATE the dbo.dm_sysobject_s table."
I get the same error message when using IDfQuery.DF_QUERY
, but anyway DF_EXEC_QUERY is the one that should be working -- or? I am of course trying this out with a super user account, so I wouldn't know which privileges I'm missing.
Is there a good, non-deprecated way to execute raw SQL statements from within DFC?
I would also like to add that I am very aware that raw SQL is strongly discouraged because it bypasses Documentum's security model. I am also aware that I can use @SuppressWarnings("deprecation")
in my Java code, but that doesn't make the method any less deprecated.