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()