[pb] 如何动态生成数据源为存储过程的数据窗口?整理

来源:互联网 发布:淘宝网大童牛仔裤 编辑:程序博客网 时间:2024/05/21 19:21

oracle 嵌套进参数


string ls_arg 
ls_arg = "100" //测试参数
sqlselect = 'execute EOS.HHQUERY;0 AI_A ='+ls_Arg+'" arguments=(("AI_A", number))'
ls_Syn = sqlca.SyntaxFromSQL ( sqlselect, "", err )

 

--测试 1

oracle 测试成功:
1、一个参数
string num = "20"
sqlselect = 'execute SP_TEST;0 NUM = ' + num + '" arguments=(("NUM", number))' 

2、多个参数
string num = "20", sname = "'受理'"
sqlselect = 'execute SP_TEST;0 NUM = ' + num + ',SNAME = ' + SNAME + '" arguments=(("NUM", number),("SNAME", string))'

 

 

在MSSQL中的方法:

string num="20",sname="受理"
sqlselect = 'execute SP_TEST;1 @num = ' + num + ',@sname = ' + SNAME

--测试 2
CREATE PROCEDURE dbo.get_shortmsg
@mobile char(11),@msg varchar(140)
AS
begin
set nocount on
set rowcount  20
   
if (substring(@mobile,1,3)>='134' and substring(@mobile,1,3)<='139')
        
select *  from   shortmessage_bak
   
else if  (substring(@mobile,1,3)>='130' and substring(@mobile,1,3)<='133')
       
select * from free_mobile
  
set rowcount 0
set nocount off
end

建一个窗口W_MAIN,窗口上只有一个空的DW,一个按钮,一个SLE用于输入第一个参数。
按钮内代码:


string ERRORS, sql_syntax
string presentation_str, dwsyntax_str

sql_syntax
= "execute get_shortmsg '"+sle_1.text+"','第二个参数'"
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()


 

 

原创粉丝点击