我想从数据库存储过程中调用一个值。程序IBAccountList)是:
SELECT ac.CUAccountID, ac.AccountNumber, ac.BalanceDate, p.Description, ac.ParentAccountID, p.ProductTypeID,
CASE p.ProductTypeID WHEN 1 THEN
dbo._Balance(ac.DRAmount, ac.CRAmount) * -1
ELSE
dbo._Balance(ac.DRAmount, ac.CRAmount)
END AS Balance,
CASE p.ProductTypeID WHEN 1 THEN
NULL
ELSE (
SELECT dbo._Balance(intr.DRAmount, intr.CRAmount)
FROM CUAccount intr
WHERE intr.ParentAccountID = ac.CUAccountID
)
END AS Interest
FROM CUAccount ac
INNER JOIN CUProduct p ON ac.ProductID = p.ProductID
WHERE CustomerID = @CustomerID AND
ac.Active = 1 AND
ac.ParentAccountID IS NULL
ORDER BY ac.AccountNumber
我希望从此存储过程中获取ProductTypeID。我将如何在红宝石中引用它。我目前正在尝试以下方法:
def fetch_account_type(number)
@accounttype = @db.call('IBAccountList', @id).map do |accounttype|
{accounttype: accounttype['ProductTypeID']}
end
end