Stored Procedures [dbo].[GetInternationalContainerTotalsForLetter]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inOrderIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/*
* Gets international container totals for the specified order.
* This is used for bookmarks in the Forms Designer.
*/


CREATE procedure [dbo].[GetInternationalContainerTotalsForLetter]
    @inOrderId int
as
set nocount on

select
    sum( isnull( Pieces, 0 ) ) as ContainersTotal,
    case
        -- Prevent division by zero.
        when sum( isnull( CubicFeet, 0 ) ) > 0
            then cast(
                cast( sum( isnull( NetWeight, 0 ) ) as numeric ) / cast( sum( CubicFeet ) as numeric )
                as decimal(10, 2) )
        else cast( 0 as decimal(10, 2) )
    end as ContainersDensity,
    sum( isnull( GrossWeight, 0 ) ) as ContainersGrossWeight,
    sum( isnull( TareWeight, 0 ) ) as ContainersTareWeight,
    sum( isnull( NetWeight, 0 ) ) as ContainersNetWeight,
    sum( isnull( CubicFeet, 0 ) ) as ContainersCubicFeet
from InternationalContainer
where OrdersFID = @inOrderID
group by OrdersFID
GO
GRANT EXECUTE ON  [dbo].[GetInternationalContainerTotalsForLetter] TO [MssExec]
GO
Uses