powerbuilder中数据窗口中的列表

时间:2017-03-04 00:44:16

标签: powerbuilder datawindow

  1. 如何在powerbuilder中的数据窗口中访问该列的列名和基础表名。我可以通过拥有一个实例变量来获取列名,并在itemfocuschanged事件中为此实例变量分配dwo.name。但是如何获取此列的表名。

  2. 如果我在窗口中有多个数据窗口控件,那么如何获取所选数据窗口控件的名称。

2 个答案:

答案 0 :(得分:1)

首先使用下面的代码获取DW的SQL语句...

ls_sql = this.dw_report.Object.DataWindow.Table.SQLSelect

OR

ls_sql = dw_report.Describe("DataWindow.Table.Select")

然后我使用这个自定义函数返回表名...

ls_table = f_get_table_name(ls_sql)

“f_get_table_name()”函数的代码......

//Obtains the main Table name from the passed SQL string

long ll_pos1
long ll_pos2
string ls_table = ""

ll_pos1 = PosA(Upper(as_sql), "FROM")
ll_pos1 = PosA(as_sql, '"', ll_pos1 + 1)
ll_pos2 = PosA(as_sql, '~~', ll_pos1 + 1)
ls_table = MidA(as_sql, ll_pos1 + 1, ll_pos2 - ll_pos1 - 1)

if (ls_table = "" OR isNull(ls_table)) then
    ll_pos1 = PosA(Upper(as_sql), "SELECT")
    ll_pos1 = PosA(as_sql, ' ', ll_pos1 + 1)
    ll_pos2 = PosA(as_sql, '.', ll_pos1 + 1)
    ls_table = MidA(as_sql, ll_pos1 + 1, ll_pos2 - ll_pos1 - 1)
end if

if (ls_table = "" OR isNull(ls_table)) then
    ll_pos1 = PosA(Upper(as_sql), "WHERE")
    ll_pos1 = PosA(as_sql, ' ', ll_pos1 + 1)
    ll_pos2 = PosA(as_sql, '.', ll_pos1 + 1)
    ls_table = MidA(as_sql, ll_pos1 + 1, ll_pos2 - ll_pos1 - 1)
end if

if (ls_table = "" OR isNull(ls_table)) then
    ll_pos1 = PosA(Upper(as_sql), "FROM")
    ll_pos1 = PosA(as_sql, ' ', ll_pos1 + 1)
    ll_pos2 = PosA(as_sql, ' ', ll_pos1 + 1)
    ls_table = MidA(as_sql, ll_pos1 + 1, ll_pos2 - ll_pos1 - 1)
end if

return Trim(ls_table)

答案 1 :(得分:0)

问题1: 使用dw_a.Describe("<yourcolumn>.dbName") 这将以tablename.columnname的形式为您提供列的数据库名称。然后你可以解析它。

问题1: 不明白你的意思。如果你想知道哪个数据窗口最后得到了焦点,你可以定义一个窗口实例变量(类型数据窗口)并使用各种数据窗口的GetFocus事件:

idw_datawindowfocue = this

我想知道为什么你需要这个。你能解释一下这个理由吗?