Question

Paramerising Function-Alias Causing Error

Hey,

I am trying to build a function-alias rule to take in paramertised inputs into an interval calculation to improve run time over the current Difference In Day/Min/Hour Function currently provided.

<%
String parameter2 = tools.getStepPage().getString(".pyParameters(2).pyParametersParamValue").replaceAll("\"","").replaceAll("'","");
%>
<p:choose>
<p:when java="<%= parameter2.equals("days") %>">
<p:choose>
now()::date - interval '{1} days'
</p:choose>
</p:when>
<p:otherwise>
ERROR : Unknown Interval Type
</p:otherwise>
</p:choose>

On Execution I am getting the error:

Error:

An error occured on executing the query for the report definition - There was a problem getting a list: code: 0 SQLState: 22023 Message: The column index is out of range: 1, number of columns: 0. DatabaseException caused by prior exception: org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0. | SQL Code: 0 | SQL State: 22023

However hardcoding the value allows it to work sucessfully.

Any ideas how I can pass a parameter into a '' encapsulated string?

I have attached screenshots for reference.

Many Thanks In Advance

Correct Answer
November 15, 2019 - 10:46am

Solved:

Created the relevant String using embedded java. and referenced property in source.

<%
String parameter2 = tools.getStepPage().getString(".pyParameters(2).pyParametersParamValue").replaceAll("\"","").replaceAll("'","");
String parameter1 = tools.getStepPage().getString(".pyParameters(1).pyParametersParamValue").replaceAll("\"","").replaceAll("'","");
String intervalPeriod = "'" + parameter1 + " " + parameter2 + "'";
%>

now()::date - interval <%= intervalPeriod %>

Comments

Keep up to date on this post and subscribe to comments

November 15, 2019 - 10:46am

Solved:

Created the relevant String using embedded java. and referenced property in source.

<%
String parameter2 = tools.getStepPage().getString(".pyParameters(2).pyParametersParamValue").replaceAll("\"","").replaceAll("'","");
String parameter1 = tools.getStepPage().getString(".pyParameters(1).pyParametersParamValue").replaceAll("\"","").replaceAll("'","");
String intervalPeriod = "'" + parameter1 + " " + parameter2 + "'";
%>

now()::date - interval <%= intervalPeriod %>

Mod
November 15, 2019 - 10:58am

Thank you! We have marked this post as Answered.

Lochana | Community Moderator | Pegasystems Inc.