26 lines
920 B
Plaintext
26 lines
920 B
Plaintext
Create Function Cistools/Percent_Changed (
|
|
From_Number Double Precision, To_Number Double Precision
|
|
)
|
|
Returns Decimal(7, 2)
|
|
Language Sql
|
|
Specific Sequel/Pctchg
|
|
Deterministic
|
|
Reads Sql Data
|
|
Returns Null On Null Input
|
|
No External Action
|
|
Not Fenced
|
|
Set Option Alwblk = *Allread, Alwcpydta = *Optimize, Commit = *None, Decresult = (31, 31, 00), Dlyprp = *No, Dyndftcol = *No,
|
|
Dynusrprf = *User, Srtseq = *Hex
|
|
Begin
|
|
Declare P_Intermed Float;
|
|
Declare P_Result Decimal(7, 2);
|
|
If From_Number <> 0 Then /*p_intermed remains null if op1=0 */
|
|
Set P_Intermed = (To_Number - From_Number) / From_Number * 100;
|
|
End If;
|
|
If Abs(P_Intermed) > 99999.99 Then
|
|
Set P_Result = 99999.99; /*Handle overflow*/
|
|
Else
|
|
Set P_Result = P_Intermed;
|
|
End If;
|
|
Return P_Result;
|
|
End; |