我正在尝试用变量创建SQL。
var PLid = '02101';
var connection = new Packages.SQLConnection("oracle");
connection.connect("server", port ,"SID", "test", "test");
var result = connection.getResults("select policy_no from policy where product_id = '"PLid"');
connection.disconnect();
我收到以下错误:
缺少)参数列表(Script = script_2; Line = 4)
之后
如果我重写我在互联网上找到的东西:
var result = connection.getResults("select policy_no from policy where product_id = '?'",1);
找不到方法SQLConnection.getResults(string,number)。 (脚本= script_2;行= 4)
我正在尝试在Neoload中实现此代码。
答案 0 :(得分:0)
要在JavaScript中连接字符串,您需要+
。将第四行更改为:
var result = connection.getResults("select policy_no from policy where product_id = '"+PLid+"')
如果PLid
可以设置为整数(var PLid = 2101;
),则可以跳过单引号,如下所示:
var result = connection.getResults("select policy_no from policy where product_id = "+PLid)