Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

Additional SQL functions min maxArgs does not work

Avatar

Community Advisor

Hello all,

the min maxArgs does not work for any of my additional functions I have added

e.g.

<function name="concat" type="text" args="(&lt;str1&gt;, &lt;str2&gt;, &gt;str3&gt;, &gt;str4&gt;, &lt;str5&gt;)" help="Concatenate all arguments. NULL arguments are ignored."

                  minArgs="2" maxArgs="5" display="Concatenate all arguments. $1, $2, $3, $4, $5">

          <providerPart provider="PostgreSQL" body="concat($1,$2,$3,$4,$5)"/>

        </function>

It throws error every time I add less than 5 args. Eventhough I set minArg to be lower than maxArgs should treat all other missing args as not required.

Am I missing something?

Thanks Marcel

wodnicki​ something you might smash?

5 Replies

Avatar

Community Advisor

Hello Marcel,

Could you please share the exact error that you see?

Thanks,

Manoj


     Manoj
     Find me on LinkedIn

Avatar

Community Advisor

Hello Manoj,

Thank you for try to help me

You can see below it is adding last 2 arguments as empty and it throws syntax error

11/11/2019 12:39:40 enrich PGS-220000 PostgrSQL error: ERROR:  syntax error at or near "," LINE 1: ...E'4'::text,E'test',E'i'), concat(E'1 ',E'2 ',E'3 ',,) FROM wk...                                                              ^

NOTE:

I did remove the $3,$4,$5 from the definition and it workded but..when add the missing arguments in the query expression builder it is as they are used at all as they not even considered..

Avatar

Level 3

Hello marcel.gent.86

  • @minArgs and maxArgs designates the number of parameters (minimum and maximum) for a parameter. For example, for a function with 2 parameters, minArgs and maxArgs will be 2 and 2. For 3 parameters, plus 1 optional, they will be 3 and 4 respectively.
  • Finally, the providerPart element provides the function implementation.
    • The provider attribute is mandatory, it specifies the database systems for which the implementation is provided. As shown in the example, when expression syntaxes or underlying functions differ, alternative implementations can be provided according to the database.
  • Example :

<function name="relativeMaturity" type="long" args="(<Âge>)" help="Returns the difference between a date and 18 years"

  minArgs="1" maxArgs="1" display="Relative maturity of the person born on the date $1">

  <providerPart provider="PostgreSQL" body="extract(year from age($1))-18"/>

  <providerPart provider="MSSQL,Sybase,Teradata" body="[Other implementation]"/>

  </function>

In the @help and @display attributes, the string "$1" represents the name that was given in the first function parameter (here, "Age"). $2, $3... would represent the following parameters. In the @body attribute detailed below, $1 designates the argument value passed to the function during the call.

Avatar

Community Advisor

Hello yassinen42406289

All those thing do not matter.. I set minArgs = 2 and maxArgs=5

But it will not work until I will provide all 5

@prasanna it is just display text it not doing anything but thanks

Avatar

Level 5

Marcel,

You have &gt; on both sides of 3rd and 4th parameter instead of &lt. Thanks!