We typically display a series of data in the metric rapid development platform by creating a business table and then displaying it on the grid part of the form. We do it all the way we do everyday.
If there is more complex business display data, for example, according to different conditions, to query out the data in different tables, and then combined into a whole block of data to be displayed on the grid parts.
That is, how can we do this if we cannot write the business table directly to implement the complex query business.
For this kind of business, the measurement of rapid development platform in general there are two ways to achieve.
1, through the platform script to achieve dynamic SQL, and through the grid to refresh the DataTable implementation
Example:
In the Load event of the form:
Dimsql= ""
ifDrop -down option 1. Value= "department" Then
sql= "Select Dept_id,dept_name from Sa_dept_dict"
else ifDrop -down option 1. Value= "Personnel" Then
sql= "Select Id,user_name from Sa_staff_info"
Else
sql= "Select Id,user_name from" + other tables. Value
End If
Grid Part 1. Datatable=executeselect (SQL)
Grid Part 1. Refreshdatabydatatable ()
2, through the database stored procedure returns the cursor way realizes
The following shows an SQL statement that writes complex code in an Oracle stored procedure, and then queries out the result set to display in the grid part.
Create or replace procedure Get_retcursor_pro
(In_tablename in VARCHAR2,
ret_cursor out Sys_refcursor) 
as
p_sql VARCHAR2 (4000);
BEGIN &NBSP
p_sql:= ' select * from ' | | In_tablename;
open ret_cursor for P_sql;
End Get_retcursor_pro;
in the Load event:
Dim sp=createprocedure ("Default", "Get_retcursor_pro")
' Addinputparam ("parameter name", parameter enumeration, parameter value) Add stored procedure input parameter
' parameter enumeration: Number (13), date (6), character (s)
sp. Addinputparam ("in_tablename ", "sa_dept_dict")
' Addoutputparam (parameter name, parameter enumeration, content length) add stored procedure output parameters
' Parameter enumeration: Number (13), date (6), character (22), cursor (5)
SP. Addoutputparam ("Ret_cursor", 5,0)
' Execute the stored procedure, the incoming parameter indicates whether the transaction is committed (true means commit transaction,)
Sp. Execute (false)
' Getoutpraramvalue Gets the value of the stored procedure output parameter
dim dt=sp. Getoutpraramvalue ("Ret_cursor")
Grid Part 1. DataTable = DT
Mesh Part 1. Refreshdatabydatatable ()
SQL Server stored procedures as a business table usage method:
Read-only business table alternative notation (business table data is stored procedure)
Original address: http://bbs.delit.cn/thread-876-1-1.html
Reprint please specify the source:
Author: metric Technology www. Delit. cn
The idea of creating business data and displaying ideas through complex code cursor stored procedures