Table Valued Functions support

Posts   
 
    
morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 25-Sep-2013 16:32:27   

I wanted to try out the Table Valued Functions support feature of v4 pro. Mapping one of my I get the error message below.

I'm unsure how to fix the problem.

Message type: Error Message text: The Table Valued Function 'System.Udf_Dt_DaySequenceTab' doesn't have a return element defined Source: System.Udf_Dt_DaySequenceTab Created on: 25. september 2013 16:12 Corrections/suggestions Choice 1: Open 'System.Udf_Dt_DaySequenceTab' in its editor and manually correct the problem.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 25-Sep-2013 18:49:18   

Could you please share a repro projet, or open a helpdesk (private) thread to share your project file?

Mind you, which Designer version (release date are you using)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 26-Sep-2013 11:42:38   

When you retrieved the relational schema data from the database, what did the application output pane say in the designer: did it report an issue?

Also without the function there's little we can do. The project alone won't help, the function's SQL isn't in the project. Also make sure the function does indeed return a resultset.

A reminder: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7717

Frans Bouma | Lead developer LLBLGen Pro
morten71
User
Posts: 80
Joined: 13-Jan-2009
# Posted on: 26-Sep-2013 14:07:24   

Thanks for replying. A little more info about my setup:

I'm using version 4.0 Final September 2nd, 2013.

The error messages below are displayed in the Errors & Warnings window when the model is validated (the udf is added to the "Table Valued Functions" under the schema in the Relational Model Data treeview:

Error message 1: Message type: Error Message text: The Table Valued Function 'System.GetDaySequence' doesn't have a return element defined Source: System.GetDaySequence Created on: 26. september 2013 13:57 Corrections/suggestions Choice 1: Open 'System.GetDaySequence' in its editor and manually correct the problem.

Error message 2: Message type: Error Message text: For the database with driver 'SQL Server 2000/2005/2008/2008R2/2012/Express Driver (SqlClient)', the table valued function call 'System.GetDaySequence' has no mapping defined for the return element. Source: System.GetDaySequence mapping Created on: 26. september 2013 13:57 Corrections/suggestions Choice 1: Open 'System.GetDaySequence' in its editor and manually correct the problem.

Sql database version: Microsoft SQL Server 2005 - 9.00.5057.00 (Intel X86) Mar 25 2011 13:50:04 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 6.1 (Build 7601: Service Pack 1)

The udf:

CREATE FUNCTION [dbo].[GetDaySequence] ( @from DATETIME, @to DATETIME ) RETURNS @days TABLE ( [Date] DATETIME, [DayCounter] INT ) WITH SCHEMABINDING -- test: SELECT * FROM dbo.GetDaySequence('2013-01-01', '2013-01-31') AS BEGIN

DECLARE @work SMALLDATETIME;
DECLARE @counter INT;

SET @work =  DATEADD(dd, DATEPART(dy, @from) -1, CONVERT(DATETIME, CONVERT(CHAR(4), DATEPART(yyyy,@from)) + '-01-01'));
SET @counter = 1;
WHILE @work <= @to 
BEGIN

    INSERT INTO @days ([Date], [DayCounter]) VALUES (@work, @counter);
    SET @work = DATEADD (dd, 1, @work);
    SET @counter = @counter +1;

END

RETURN

END

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Sep-2013 02:27:31   

I couldn't reproduce it.

I used your exact Function, and it when refreshing the catalog it appeared in the catalog explorer with the appropriate Resultset (fields: Date, DayCounter). Then Validated the model and generated the code without a single error or warning.

What could we have done differently?