Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.10.16;
Скачать: CL | DM;

Вниз

GETDATE() внутри User Defined Functions   Найти похожие ветки 

 
DrAndrey   (2005-09-02 07:19) [0]

Написал фунцию, в которой одной из локальных переменных должна быть текущая дата,
но при вызове GETDATE() - Error 443, интересно её вообще нельзя использовать
внутри User Defined Functions или есть какие-то нюансы.

PS: BOL читал, но не нашел.


 
MOA ©   (2005-09-02 10:05) [1]

CREATE VIEW dbo.V_GetCurrDate
AS
BEGIN
SELECT GETDATE() AS CurrDate
END

И в функции использоватьЮ например
....
SELECT CurrDate FROM dbo.V_GetCurrDate
Удачи!


 
Nikolay M. ©   (2005-09-02 10:25) [2]

Плохо искал. В [1] - правильный обход проблемы, в БОЛ описаны причины такого поведения.

Deterministic and Nondeterministic Functions
All functions are deterministic or nondeterministic:

Deterministic functions always return the same result any time they are called with a specific set of input values.

Nondeterministic functions may return different results each time they are called with a specific set of input values.
Whether a function is deterministic or nondeterministic is called the determinism of the function.

For example, the DATEADD built-in function is deterministic because it always returns the same result for any given set of argument values for its three parameters. GETDATE is not deterministic because it is always invoked with the same argument, yet the value it returns changes each time it is executed.


 
Anatoly Podgoretsky ©   (2005-09-02 10:41) [3]

Есть еще другой термин функция и функционал, GETDATE это функционал.



Страницы: 1 вся ветка

Текущий архив: 2005.10.16;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.026 c
14-1127555455
Goga
2005-09-24 13:50
2005.10.16
переведите на delphi Спасибо


10-1105775800
SMT
2005-01-15 10:56
2005.10.16
Программное определение наличия Excel


2-1125919778
lmz
2005-09-05 15:29
2005.10.16
Запрос на выборку


1-1127467175
MegaVolt
2005-09-23 13:19
2005.10.16
Как тестировать в DUnit классы которые куда то отдают результат?


2-1127396868
BFG9k
2005-09-22 17:47
2005.10.16
Справочная система из нескольких файлов