How To Read From Stored Procedure In Acumatica
Hello readers,
today I want to share hwo it is possible to read from stored procedure in Acumatica. Keep in mind, that reading from sp is against best practices of Acumatica, because if you read from sp, then you'll reading will not be cached and other side effects, but sometime you don't have a choice. So, for such cases you can try following approach:
create procedure uspWow
@invnbr nvarchar(6),
@money decimal(19,4) OUTPUT
AS
SELECT @money = ARInvoice.CuryLineTotal
FROM ARInvoice
WHERE ARInvoice.RefNbr = @invnbr;
RETURN
GO
var invNbr = new PXSPInParameter("invnbr", "000595");
var money = new PXSPOutParameter("money", PXDbType.Decimal, 19, 4, null);
var results = PXDatabase.Execute("uspWow", new PXSPParameter[] { invNbr, money});
var sb = new System.Text.StringBuilder("PROC RESULT:\n");
foreach(var r in results)
{
sb.AppendLine(r.ToString());
}
throw new PXException(sb.ToString());