PB动态创建数据窗口,即在窗体里面放了一个datawindow控件,但没有给其指定数据源,数据源在实际开发中动态指定。
1、使用sql语句动态创建数据窗口
String ls_sql,ls_syntax,ls_error
ls_sql = 'select * from lswlzd'
ls_syntax = sqlca.SyntaxFromSQL(ls_sql,'style(type=grid)',ls_error)
If Len(ls_error) > 0 Then
MessageBox('Error','SyntaxFromSQL Error:~r'+ls_error)
Else
dw_1.Create(ls_syntax,ls_error)
If Len(ls_error) > 0 Then
MessageBox("Error", "Create have these errors: ~r" + ls_error)
Else
dw_1.X = 5
dw_1.Y = 5
// dw_1.Width = 1500
// dw_1.Height = 650
// dw_1.Visible = True
dw_1.Enabled = True
dw_1.HScrollBar = True
dw_1.VScrollBar = True
dw_1.SetTransObject(sqlca)
dw_1.Retrieve()
End If
End If
2、从存储过程中动态创建数据窗口
PB代码:
string ERRORS, sql_syntax,ls_arg
string presentation_str, dwsyntax_str
ls_arg = "20"//参数
sql_syntax = 'execute LC0029999.SP_SYS_TEST_LSPASS;0 AS_USER = '+ls_arg+''
presentation_str = "style(type=grid)"
dwsyntax_str = SQLCA.SyntaxFromSQL(sql_syntax, presentation_str, ERRORS)
IF Len(ERRORS) > 0 THEN
MessageBox("Caution", &
"SyntaxFromSQL caused these errors: " + ERRORS)
RETURN
END IF
dw_1.Create( dwsyntax_str, ERRORS)
IF Len(ERRORS) > 0 THEN
MessageBox("Caution", &
"Create cause these errors: " + ERRORS)
RETURN
END IF
dw_1.settransobject(sqlca)
dw_1.retrieve()
CREATE OR REPLACE PROCEDURE SP_sys_test_lspass (AS_user IN VARCHAR2,
CUR_LIST OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN CUR_LIST FOR
select f_zgbh,f_name,f_day,f_time,f_group,f_bz from lspass where f_zgbh like AS_user||'%';
END;