|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Table column tied to a user defined function (UDF)[crProcAmount] from several rows in the child table. So, in Design Table, we set the formula property for Pcolumn to the user-defined function ([dbo].[udfBudgetAdjustment]([pkID])) where pkID is the primary key in the parent table. The UDF is CREATE FUNCTION udfBudgetAdjustment(@parent as int) RETURNS money AS BEGIN Declare @BudgetMIPRProcTotalAdjustment money SET @BudgetMIPRProcTotalAdjustment = (select Sum(tlBudgetMIPRAdjustments.crProcAmount) FROM tlBudgetMIPRAdjustments WHERE tlBudgetMIPRAdjustments.Parent = @parent) Return (@BudgetMIPRProcTotalAdjustment) When we open the table we get an error message: "Subquery returned more than one value". How can a Sum return more than one value? Or maybe it is because there are multiple rows being updated in the parent table? Or is the problem something else? Never mind, found the problem, which was actually a lot of separate issues
all tangled up... Show quote "Geoff Pennington" <Geoff.Pennington.***@whs.mil.no_spam> wrote in message news:uDWytOoLGHA.208@tk2msftngp13.phx.gbl... >A column (call it Pcolumn) in the parent table should equal the sum of >[crProcAmount] from several rows in the child table. So, in Design Table, >we set the formula property for Pcolumn to the user-defined function >([dbo].[udfBudgetAdjustment]([pkID])) where pkID is the primary key in the >parent table. > > The UDF is > CREATE FUNCTION udfBudgetAdjustment(@parent as int) > RETURNS money > AS > BEGIN > > Declare @BudgetMIPRProcTotalAdjustment money > > SET @BudgetMIPRProcTotalAdjustment = > (select Sum(tlBudgetMIPRAdjustments.crProcAmount) > FROM tlBudgetMIPRAdjustments > WHERE tlBudgetMIPRAdjustments.Parent = @parent) > > Return (@BudgetMIPRProcTotalAdjustment) > > When we open the table we get an error message: "Subquery returned more > than one value". > > How can a Sum return more than one value? Or maybe it is because there are > multiple rows being updated in the parent table? Or is the problem > something else? > > > > |
|||||||||||||||||||||||