提问人:W0lfw00ds 提问时间:6/20/2023 最后编辑:Mike FechnerW0lfw00ds 更新时间:6/21/2023 访问量:76
UNDO 语句释放类实例中的可用缓冲区
UNDO statement releases available buffer within class instance
问:
我在下面添加了测试代码。
TestClass
本身内部有变量,在执行其后可用。
一切正常,直到代码执行任何或()。在此之后,类实例在其他方面保持不变,只是变量现在是 。BUFFER
CONSTRUCTOR
UNDO
UNDO, THROW...
BUFFER
NOT AVAILABLE
有什么方法可以防止这样做吗?Progress
RELEASE
在下面的测试代码中,第二个将抛出错误,因为 是 .iValue = oTestClass:Value.
BUFFER
UNAVAILABLE
我正在使用 Progress 11.7.5。
测试.p:
DEF VAR oTestClass AS CLASS TestClass NO-UNDO.
DEF VAR iValue AS INT NO-UNDO.
DO TRANSACTION:
oTestClass = TestService:Singleton:Find().
iValue= oTestClass:Value.
UNDO.
END.
DO TRANSACTION:
oTestClass = TestService:Singleton:Find().
iValue = oTestClass:Value.
UNDO.
END.
TestClassService.cls:
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS TestService:
DEF PUBLIC STATIC PROPERTY Singleton AS CLASS TestService NO-UNDO
GET:
IF TestService:Singleton = ? THEN TestService:Singleton = NEW TestService().
RETURN TestService:Singleton.
END.
PROTECTED SET.
DEF PRIVATE VAR oTestClass AS CLASS TestClass NO-UNDO.
CONSTRUCTOR PROTECTED TestService(): END.
METHOD PUBLIC CLASS TestClass Find():
IF oTestClass = ? THEN DO:
oTestClass = NEW TestClass(TO-ROWID("0x000000000017c201")).
END.
RETURN oTestClass.
END.
END.
TestClass.cls:
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS TestClass:
DEF PRIVATE BUFFER MyTable_This FOR MyTable.
DEF PUBLIC PROPERTY Value AS INT NO-UNDO
GET:
RETURN MyTable_This.Value.
END.
CONSTRUCTOR PUBLIC TestClass(i_rROWID AS ROWID):
FIND FIRST MyTable_This WHERE ROWID(MyTable_This) = i_rROWID NO-LOCK.
END.
END.
答:
3赞
Stefan Drissen
6/21/2023
#1
您可以在 ABL Dojo 上执行您的示例。
由于数据库表不是 ,任何语句都将撤消对它所做的任何事情,包括将 带入作用域的语句。no-undo
undo
find
buffer
临时表上的缓冲区没有这个“问题”。no-undo
评论
0赞
W0lfw00ds
6/21/2023
我接受了这个答案。我最终为每个属性添加了代码,它检查是否不是,并在需要时再次查询它。我不知道dynamic s是否可以解决这个问题?BUFFER
AVAILABLE
buffer
0赞
Stefan Drissen
6/21/2023
不,请参阅 abldojo.services.progress.com/?shareId=6492ed8cd172aa40d044e1ed
评论