Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.034 c
1-1127887687
tytus
2005-09-28 10:08
2005.10.16
Как в StringGrid-e рисовать перевернутый текст на 90 градусов?


3-1125987508
Shopot
2005-09-06 10:18
2005.10.16
Главная и подчиненная таблицы.


11-1089063773
murtix
2004-07-06 01:42
2005.10.16
KolSplitter


14-1127833083
Gorger
2005-09-27 18:58
2005.10.16
Что бы это могло означать,помогите тупому.


1-1127703560
Laymer
2005-09-26 06:59
2005.10.16
Запрет закрытие программы.




   Наверх