使用输入参数作为可选输入 [英] Using input parameter as an optional input

查看:29
本文介绍了使用输入参数作为可选输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 wso2、DSS 3.01 版,我试图获得一个可以是可选参数的输入参数.用户可以说,给我这个特定代码的所有信息,或者如果用户没有指定任何代码,我想给所有数据行.你能帮我吗?

Using wso2, DSS version 3.01, I am trying to have an input parameter that could be an optional parameter. A user can say, give me all the info for this specific code, or if a user does not specify any code, I want to give all the rows of data. Can you help?

推荐答案

除了为每个可选参数创建查询之外,您还可以执行以下操作:

Instead of creating a query for each optional parameter, you can also do the following:

<query id="selectEmployees" useConfig="default">
   <sql>select * from Employees where (:employeeNumber is null or employeeNumber = :employeeNumber)</sql>
   <result element="employees" rowName="employee">
      <element column="lastName" name="last-name" xsdType="string"/>
      <element column="firstName" name="first-name" xsdType="string"/>
      <element column="email" name="email" xsdType="string"/>
      <element column="salary" name="salary" xsdType="double"/>
   </result>
   <param defaultValue="#{NULL}" name="employeeNumber" ordinal="1" paramType="SCALAR" sqlType="INTEGER" type="IN"/>
</query>
<operation name="getEmployees">
   <call-query href="selectEmployees">
      <with-param name="employeeNumber" query-param="employeeNumber"/>
   </call-query>
</operation>

现在您可以使用employeeNumber"调用getEmployees"并获取特定员工,
或者您可以在没有employeeNumber"的情况下调用getEmployees"并获取所有员工.
(不带 'employeeNumber' 的呼叫是通过省略 'employeeNumber' 标签,或使用 'xsi:nil="true"'.)
显然,您不能以这种方式查询值 'null'.

Now you can call 'getEmployees' with 'employeeNumber' and get specific employee,
or you can call 'getEmployees' without 'employeeNumber' and get all employees.
(Calling without 'employeeNumber' is by omitting the 'employeeNumber' tag, or using 'xsi:nil="true"'.)
Obviously, you cannot query for the value 'null' this way.

这篇关于使用输入参数作为可选输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆