Reputation: 2133
I have following request
URI: /IP/{Version}/Account/Payment
HTTP Method: POST
Custom Headers:
X-account-number
X- account-type
X-user-initials,
X-dda-number
X-dda-account-type
X-number-of-days-gap
X-send-ch-letter-flag
X-payment-date
X-payment-option
Now what I have to do is I have to get the Payment date from the request and then I have to check the following conditions
if the payment date is not null and is a future date and is within 180 days from today. If so then first do a lookup to make sure there is no future payment scheduled for this date
If no payments for the date scheduled then insert the payment to table
Finally do the first select query again and retrieve the value
I am trying to do it using XSLT and datapower
but I am not getting the logic correct.
Here is what I have tried
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpconfig="http://www.datapower.com/param/config"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="dp date"
exclude-result-prefixes="dp dpconfig"
version="1.0" >
<xsl:template match="/">
<AccountNumber><xsl:value-of select="dp:http-request-header('X-account-number')"/></AccountNumber>
<PaymentDate><xsl:value-of select="dp:http-request-header('X-payment-date')"/></PaymentDate>
<PaymentOption><xsl:value-of select="dp:http-request-header('X-payment-option')"/></PaymentOption>
<Amount><xsl:value-of select="dp:http-request-header('X-amount')"/></Amount>
<AccountType><xsl:value-of select="dp:http-request-header('X-dda-account-type')"/></AccountType>
<xsl:variable name="timestamp" select="date:date-time()"/>
<xsl:variable name="dateDifference" select="date:difference($timestamp,$PaymentDate)"/>
<xsl:if "$dateDifference" < '180' AND "$PaymentDate" != NULL>
<xsl:variable name="LookUp" Select PAYMENT_STATUS_CODE FROM TABLE WHERE WHERE ACCT_NBR ='$ACCOUNTNUMBER' AND AND PMT_DATE = '$PaymentDate'/>
<xsl:variable name ="RunQuery1">
<dp:sql-execute
source="'XXXXX'"
statement="$Lookup">
</dp:sql-execute>
<xsl:variable name="test" copy-of select ="$RunQuery1"/>
<xsl:if test = NULL>
<xsl:variable name="InsertQuery" Insert into TABLE(CREATED_DATE,ACCT_NBR,PMT_AMT_OPTION_CODE,AMOUNT,PMT_DATE,ACCOUNT_TYPE_CODE,PAYMENT_STATUS_CODE)
VALUES('$timestamp','$ACCOUNTNUMBER','$PaymentOption','$Amount','$PaymentDate','$AccountType','P'/>
<xsl:variable name="RunQuery2">
<dp:sql-execute
source="'XXXXX'"
statement="$InsertQuery">
</dp:sql-execute>
</xsl:variable>
</xsl:if>
<xsl:variable name="RetrieveQuery" SELECT PAYMENT_STATUS_CODE from TABLE/>
<xsl:variable name="RunQuery3">
<dp:sql-execute
source="'XXXXX'"
statement="$RetrieveQuery">
</dp:sql-execute>
</xsl:variable>
<xsl:copy-of select="$RunQuery3"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
What I am doing incorrect?
Upvotes: 1
Views: 2482
Reputation: 22279
Well, not sure about the entire script, but since the if statement is not correct, here is something that should be a starting point:
<xsl:if test="fn:days-from-duration($dateDifference) < 180 and $PaymentDate != null">
the conversion function used is this.
The SQL variables are not correct. Please check the syntax on both how to define the queries and how to test the result of the SQL operation. There are many good examples on the Datapower info center.
Upvotes: 1
Reputation: 117003
"$dateDifference" < '180'
Two Three things jump out:
You cannot use <
as a comparison operator; you need to use <
instead.
The result of date:difference() is not a number.
The syntax of the <xsl:if>
statement is entirely wrong.
Upvotes: 0