-3

I created this scalar function, without any problems.
But I can't execute it from another function (inline table-valued).

USE [test]
GO

/****** Object:  UserDefinedFunction [dbo].[NameFromEnumerationID]    Script Date: 10/9/2018 6:46:22 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[NameFromEnumerationID]
(
    @EnumerationIDParam INT NOT NULL
)
RETURNS NVARCHAR ( 48 )
WITH    NATIVE_COMPILATION ,
        SCHEMABINDING
AS BEGIN ATOMIC WITH (  TRANSACTION ISOLATION LEVEL = SNAPSHOT      ,
                        LANGUAGE                    = N'English'    )
    RETURN CHOOSE ( @EnumerationIDParam                         ,
                    CAST ( N'ExampleName1' AS NVARCHAR ( 48 ) ) ,
                    CAST ( N'ExampleName2' AS NVARCHAR ( 48 ) ) ,
                    CAST ( N'ExampleName3' AS NVARCHAR ( 48 ) ) ,
                    CAST ( N'ExampleName4' AS NVARCHAR ( 48 ) ) ,
                    CAST ( N'ExampleName5' AS NVARCHAR ( 48 ) ) ,
                    CAST ( N'ExampleName6' AS NVARCHAR ( 48 ) ) ) ;
END
GO

When I try to create another function that executes the above function, I receive the error:
'NameFromEnumerationID' is not a recognized built-in function name.

CREATE FUNCTION [dbo].[NamesFromEnumerationIDs]
(
    @EnumerationIDListParam [IntList] NOT NULL READONLY
)
RETURNS TABLE AS RETURN
(
    SELECT  [Value]                                 AS [ID]                     ,
/* ERROR */ NameFromEnumerationID   ( [Value] )     AS [EnumerationName]        ,
    UPPER ( [NameFromEnumerationID] ( [Value] ) )   AS [EnumerationNameUpper]   ,
            [IsEnumerationIDValid]  ( [Value] )     AS [IsValid]
        FROM @EnumerationIDListParam
)
GO

For the parameter to the second function, the IntList type is very simple:

USE [test]
GO

/****** Object:  UserDefinedTableType [dbo].[IntList]    Script Date: 10/9/2018 6:55:56 AM ******/
CREATE TYPE [dbo].[IntList] AS TABLE(
    [Value] [int] NOT NULL
)
GO

How do I execute the first function as part of the query in the second function?

4

1 Answer 1

2

Add the schema name: dbo.NameFromEnumerationID( [Value] )

dba.stackexchange.com: Why is the schema prefix (dbo) mandatory when we call a function?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.