The reason I needed to do this was I have a static method MyCode::SendEmail(...) that would send an email and drop a log-record into a table to let me know that the email was sent. So if it was called by some code in a transaction, and then for whatever reason, that transaction had to be rolled back, I still wanted a record of that email being sent...because it was actually sent.
So to do this, you just create a new UserConnection(), do userConnection.ttsBegin(), and then assign your table to that connection via table.setConnection(userConnection), and then a userConnection.ttsCommit() at the end. See my attached sample job.
static void HowToCreateSeperateTransaction(Args _args) { Table1 table1; boolean doAbort = true; UserConnection userConnection = new UserConnection(); ; delete_from table1; ttsbegin; // This row "1" will only appear when the trans is not aborted table1.Field1 = '1'; table1.insert(); // This row "2" should always appear no matter what userConnection.ttsbegin(); table1.clear(); table1.setConnection(userConnection); table1.Field1 = '2'; table1.insert(); userConnection.ttscommit(); if (doAbort) ttsabort; else ttscommit; new SysTableBrowser().run(tableNum(Table1)); }
Hi Alex,
ReplyDeleteHow du you get back to the original connection when you have used the user connection, like;
table1.SetConnection(userConnection);
// do somthing
table1.insert();
//now work with table1 again in the original tts scope
table1.dosomthing();
table1.update(); // this one should roll back if error
Best regards
Joergen Dam
I believe you just do table1 = null; outside of the transaction.
DeleteYou need to finalize the userConnection at the end
ReplyDeleteMost organizations are doing these transactions online with the assistance of modern programming. This transaction handling programming records each progression of the transaction for future reference.소액결제현금화
ReplyDeleteAlso, with this, you can transfer your credit card funds and limit your spending so as to avoid falling into debt with your credit card company.소액결제현금화
ReplyDeleteChociaż w Internecie można znaleźć całkiem sporo kasyn, to trzeba przyznać, że jest ich niewiele, które na pewno będą Wam odpowiadać, ale generalnie postanowiłem zobaczyć, co ludzie w Internecie mogą na ten temat powiedzieć i dopiero wtedy zdałem sobie sprawę, że tutaj http://www.indoorkarting.pl/ ice casino aplikacja najbardziej opłacalne oferty. Nie wchodzę teraz w szczegóły, a po co, bo każdy sam mógłby tu przyjechać i upewnić się o wszystko, więc wątpliwości na bok i zarejestruj się już teraz tutaj. Na pewno będziesz zadowolony z tego wyniku.
ReplyDelete