Highlighted

Additional SQL functions min maxArgs does not work

MarcelSzimonisz

MVP

11-11-2019

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?

Replies

Highlighted

MarcelSzimonisz

MVP

11-11-2019

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..

Highlighted

yassinen4240628

11-11-2019

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.

Highlighted

MarcelSzimonisz

MVP

12-11-2019

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