А в чем проблема-то? Для начала получается ли вызывать эту процедуру "как есть"? Без модификаций.
Вот тестовый пример, который нормально отрабатывает. Реализован как метод run() некоего тестового класса, который запускается на стороне сервера. Напомню, что Job запускается на клиенте, поэтому для целей тестирования - не годится (ну, или нужно делать пункт меню, запускающий Job, чтобы у этого пункта меню RunOn = server)
X++:
void run()
{
Connection con = new Connection();
Statement stmt = con.createStatement();
ResultSet r;
str sql;
SqlStatementExecutePermission perm;
;
sql = 'set nocount on;' +
' if object_id(\'tempdb..#test\') is not null drop table #test;' +
' create table #test (f1 int, f2 varchar(10));' +
' insert into #test values (1,\'test1\');' +
' insert into #test values (2,\'test2\');' +
' update #test set f2 = \'test11\' where f1=1;' +
' select * from #test;' +
' if object_id(\'tempdb..#test\') is not null drop table #test;' +
'';
// Set code access permission to help protect the use of
// Statement.executeUpdate.
perm = new SqlStatementExecutePermission(sql);
perm.assert();
try
{
r = stmt.executeQuery(sql);
while (r.next())
{
print r.getString(2);
}
}
catch (exception::Error)
{
print "An error occured in the query.";
}
pause;
// Code access permission scope ends here.
CodeAccessPermission::revertAssert();
}
Как видно, в этом примере есть и модификации до собственно выборки и удаление таблицы после выборки. И нечего. Вполне себе нормально работает...