Table Valued Function eklendi

This commit is contained in:
Sedat ÖZTÜRK 2025-12-05 16:48:32 +03:00
parent b9331e66b4
commit cb2e007302
2 changed files with 35 additions and 5 deletions

View file

@ -212,8 +212,8 @@ WHERE
t1.IsActive = 1; t1.IsActive = 1;
GO`, GO`,
'create-function': `-- Create Scalar Function 'create-scalar-function': `-- Create Scalar Function
CREATE FUNCTION [dbo].[FunctionName] CREATE FUNCTION [dbo].[ScalarFunctionName]
( (
@Parameter1 INT, @Parameter1 INT,
@Parameter2 NVARCHAR(100) @Parameter2 NVARCHAR(100)
@ -230,6 +230,30 @@ BEGIN
RETURN @Result; RETURN @Result;
END END
GO`,
'create-table-function': `-- Create Table-Valued Function
CREATE FUNCTION [dbo].[TableFunctionName]
(
@Parameter1 INT,
@Parameter2 NVARCHAR(100)
)
RETURNS TABLE
AS
RETURN
(
SELECT
t.Column1,
t.Column2,
t.Column3,
t.Column4
FROM
TableName t
WHERE
t.Id = @Parameter1
AND t.Column2 LIKE '%' + @Parameter2 + '%'
AND t.IsActive = 1
)
GO` GO`
} }

View file

@ -155,10 +155,16 @@ const SqlObjectExplorer = ({
data: { templateType: 'create-view' } as any, data: { templateType: 'create-view' } as any,
}, },
{ {
id: 'template-function', id: 'template-scalar-function',
label: 'Function', label: 'Scalar Function',
type: 'object' as const, type: 'object' as const,
data: { templateType: 'create-function' } as any, data: { templateType: 'create-scalar-function' } as any,
},
{
id: 'template-table-function',
label: 'Table-Valued Function',
type: 'object' as const,
data: { templateType: 'create-table-function' } as any,
}, },
], ],
}, },