+dev@wso2.org

Hi Laslo,

There are certain validators you can define for input parameter as listed
in [1]. There is no null validator as such, but you can write a custom
validator. This just validate the input parameter before executing the
query, but there is no way to change the result set.

For your usecase I would suggest to configure the query with a QUERY_STRING
parameter [2], where it allows you to pass a part of the query in the
runtime. For an example, the query would be,

<query id="aQuery" useConfig="id">
      <sql>select * from Inventory :filterQuery</sql>
      <result element="Entries" rowName="Entry">
         <element column="column_name" name="aparam" xsdType="string"/>
         ......
      </result>
      <param name="filterQuery" sqlType="QUERY_STRING"/>
   </query>

 Then at the run time you can pass either the were clause or 'LIMIT 5' to
filter out the top 5. If you pass an empty parameter it will retrieve all
the entries.

[1]
https://docs.wso2.com/display/DSS310/Adding+Input+Mappings#AddingInputMappings-Validators
[2] https://docs.wso2.com/display/DSS310/Defining+a+Dynamic+SQL+Query

On Sat, Apr 7, 2018 at 12:43 AM, Laslo Pastor <la...@wso2.com> wrote:

> Hi
>
> I have some question about optional parameters in DSS.
> I saw according to documentation[1] that we can set default value to
> parameter but I wandering is there any way to check null value for given
> parameter aka Null validator?
>
> use case scenario :
> Select top 5 * from Inventory where code = @param OR @param IsNULL
>
> so if Im passing the @param it will return one row if @param is null it
> will return top 5 rows
>
>
> [1] https://docs.wso2.com/display/DSS310/Adding+Input+Mappings
>
> --
>
>
> *Laslo Pastor*Associate Director,
> Solution Architecture, WSO2 Inc.
>
> M: US: +1 281 542 3173 <2815423173>
> LinkedIn: https://www.linkedin.com/in/pastorlaslo/
> Skype: lpastor74
>



-- 
Best Regards..

Chanika Geeganage
+94773522586
WSO2, Inc.; http://wso2.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to