PowerBuilder:确定数据窗口主键
我正在 PowerBuilder 中的基本对象(类)中创建一些事件,并且该基本数据窗口的后代需要知道该表(或行)的主键是什么。您如何确定代码中的主键?
I'm creating some events in a base object (class) in PowerBuilder, and the descendent's of this base datawindow need to know what the primary key of that table (or row) is. How would you determine the primary key in code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以迭代数据窗口的列列表,并使用描述或点符号检查键属性:
这可以让您知道该列是否包含在数据窗口画家在菜单项“行”->“更新属性”下看到的突出显示列表中-> 唯一关键列:
以下是有关该属性的文档:
http://infocenter.sybase.com/help/topic/com.sybase.dc37783_1150/html/dwref/CAIBHFGF.htm
You can iterate through the Column list of the datawindow and check the Key property using describe or dot notation:
This lets you know whether the column is included in the highlighted list you see in the datawindow painter under the menu item Rows->Update Properties->Unique Key Columns(s):
Here are the docs on that property:
http://infocenter.sybase.com/help/topic/com.sybase.dc37783_1150/html/dwref/CAIBHFGF.htm
似乎没有一个属性可以通过点符号或隔离主键的描述函数来获取,至少我没有看到一个。我在这里可能是完全错误的,并且有更好的方法来做到这一点。
但我认为如果您尝试在 Powerscript 中执行此操作,则必须扫描数据窗口中的列并检查“columnname.key”属性以确定键中的列。
我希望这也取决于您在数据窗口更新属性中定义了主键列;通常,这些不是由开发人员为只读数据窗口定义的。
如果有人有更好的方法,请留言。
There doesn't appear to be a single property that you can grab via dot notation or the describe function that isolates the primary key, at least I didn't see one. I could be totally wrong here and there's a better way to do it.
But I think if you're trying to do this in Powerscript, you'll have to scan the columns in the datawindow and check the "columnname.key" property to determine the columns in the key.
I expect this is also dependent on you having defined the primary key columns in the datawindow update properties; typically these aren't defined by the developer for read-only datawindows.
If someone has a better way, please post.
您的对象或代码中有什么需要您知道表的主键是什么?我从 2.0 版本开始就一直使用 Powerbuilder,但我不记得有什么情况需要我知道。
What is there about your objects or code which would require you to know what a table's primary key is?? I have been using Powerbuilder since version 2.0 and I can't ever recall a situation where I would need to know.