Programmable Voice

  1. Home
  2. Docs
  3. Programmable Voice
  4. Border Elements
  5. Border Elements – Rule Procedure – Example

Border Elements – Rule Procedure – Example

SQL Server Stored Procedure for use with Border Elements’ Carrier

(Note: If the result code returned from the stored procedure is 1, the call will be rejected)

<source lang="sql">USE [BorderElements]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[RejectCalls]
(
@DialedNumber AS nvarchar(50),
@CallerId AS nvarchar(50),
@AccountId As int,
@ANI2 As int
)
AS
BEGIN
SET NOCOUNT ON

-- Declare the return variable here
-- DECLARE @return_value int

DECLARE @Result bit
SET @Result = 0

-- Is the Dialed Number a Toll Free Number?
IF ([dbo].IsTollFreeNumber(@DialedNumber) = 1)
BEGIN
IF ([dbo].IsBlockedNPA(@CallerId) = 1)
BEGIN
SET @Result = 1 -- Failed
END
ELSE
BEGIN
DECLARE @AllowPayPhone bit
SET @AllowPayPhone = 0

SELECT TOP 1 @AllowPayPhone = AllowPayPhone FROM Account WHERE AccountId = @AccountId

IF (@AllowPayPhone IS NULL OR @AllowPayPhone = 0)
BEGIN

IF (@ANI2 IN (7, 25, 27, 29, 70))
BEGIN
SET @Result = 1
END
END
END
END

RETURN @Result

END</source>
Was this article helpful to you? Yes No

How can we help?