Is it possible invert the situation (allow nulls by default)? Being the responsibility for the development of the SP, handling the nulls. We have more than 50 SP developed by the client that uses nulls as input and business rules.
The problem is that if the parameter is null, it does something, otherwise it does something else, and the parameter can be null.
Example if a @id is null it will return all values of any id in the table, if not it returns only that id.
They have other parameters like dates that can be null.
Keep in mind that your client made the SPs (53 to be precise) and 8 are for searching.
So this procedure does some kind of filtering? In one case it returns one record and in the other case returns collection of records? Can you describe how the generated code from Radzen limits this case?
Hi, If you think that we can not send to the parameter the null value, the stored procedure will never return all values.
An example :
CREATE PROCEDURE uspFindToNotify @DocumentType int
,@StartDate datetime2(7)
,@EndDate datetime2(7)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
if ((@StartDate is null) and (@EndDate is null))
Begin
select @StartDate= min(CreateDate) From LegalDocuments where (DocType = @DocumentType or @DocumentType is null) and DocStatus= 5 --'5' is closed
select @StartDate= Max(DateStatus) From LegalDocuments where (DocType = @DocumentType or @DocumentType is null) and DocStatus= 5 --'5' is closed
end
else if (not (@StartDate is null) and (@EndDate is null))
Begin
set @EndDate = EOMONTH ( @StartDate )
end
else if ((@StartDate is null) and not(@EndDate is null))
Begin
set @StartDate = DATEADD(yy, DATEDIFF(yy, 0, @EndDate), 0)
end
-- Insert statements for procedure here
SELECT * from Documents as D
inner join LegalDocuments as L on L.DocID = D.Id
where L.CreateDate between @StartDate and @EndDate and (L.DocType = @DocumentType or @DocumentType is null) and L.DocStatus= 5 and D.DocStatus in (1,2,5)
END
GO
as you can see they have rules on the dates and type of document
I see. At the moment the generated code will attempt to parse the date from the parameter and null is not allowed. We will do our best to enable such scenarios in our next release.
I've replied to your last email with private build. When inferring the data-source now, Radzen will read stored procedure parameters meta to check if the parameter is nullable or not. The execution can handle null as well.
Yep, is_nullable definitely is not part of the metadata. We will try to handle this in our code and if is_nullable does not exist we will mark the parameter as nullable. I'll reply to your mail with more info.