/*
 *   FreeAdhocUDF - copyright (c) 2004/2006 adhoc dataservice GmbH
 *   Christoph Theuring / Peter Mandrella / Georg Horn
 *   (bug-)reports only to udf@adhoc-data.de
 *
 *   !!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!
 *   This is a NECESSARY update-script for your FreeAdhocUDf-date/time-functions
 *   if you want to use the version adhoc200612xx (or further versions)
 *   AND you have DECLAIRED your UDFs with an older version then adhoc200612xx
 *   OR with a compatible version of this UDFs like FreeUDFLib, FreeUDFLibC, GrUDF ...
 *   EVEN you don't want to use the NULL-Return in FireBird 2.0 or you use InterBase.  
 *   You can run the COMPLETE script even you have NOT all UDFs declaired.
 *
 *   AFTER running this update-script you must REconnect to your database before you test 
 *
 *   Software distributed under the License is distributed on an
 *   "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
 *   or implied. See the License for the specific language governing
 *   rights and limitations under the License.
 *
 */

/* all FreeAdhocUDFs using entrypoint 'ageindays' f.e. F_AGEINDAYS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageindays');

/* all FreeAdhocUDFs using entrypoint 'ageindaysthreshold' f.e. F_AGEINDAYSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageindaysthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinhours' f.e. F_AGEINHOURS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinhours');

/* all FreeAdhocUDFs using entrypoint 'ageinhoursthreshold' f.e. F_AGEINHOURSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinhoursthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinminutes' f.e. F_AGEINMINUTES */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinminutes');

/* all FreeAdhocUDFs using entrypoint 'ageinminutesthreshold' f.e. F_AGEINMINUTESTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinminutesthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinmonths' f.e. F_AGEINMONTHS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinmonths');

/* all FreeAdhocUDFs using entrypoint 'ageinmonthsthreshold' f.e. F_AGEINMONTHSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinmonthsthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinseconds' f.e. F_AGEINSECONDS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinseconds');

/* all FreeAdhocUDFs using entrypoint 'ageinsecondsthreshold' f.e. F_AGEINSECONDSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinsecondsthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinweeks' f.e. F_AGEINWEEKS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinweeks');

/* all FreeAdhocUDFs using entrypoint 'ageinweeksthreshold' f.e. F_AGEINWEEKSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinweeksthreshold');

/* all FreeAdhocUDFs using entrypoint 'ageinyears' f.e. F_AGEINYEARS */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinyears');

/* all FreeAdhocUDFs using entrypoint 'ageinyearsthreshold' f.e. F_AGEINYEARSTHRESHOLD */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'ageinyearsthreshold');

/* all FreeAdhocUDFs using entrypoint 'daysbetween' f.e. F_DAYSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'daysbetween');

/* all FreeAdhocUDFs using entrypoint 'hoursbetween' f.e. F_HOURSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'hoursbetween');

/* all FreeAdhocUDFs using entrypoint 'minutesbetween' f.e. F_MINUTESBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'minutesbetween');

/* all FreeAdhocUDFs using entrypoint 'monthsbetween' f.e. F_MONTHSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'monthsbetween');

/* all FreeAdhocUDFs using entrypoint 'secondsbetween' f.e. F_SECONDSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'secondsbetween');

/* all FreeAdhocUDFs using entrypoint 'weeksbetween' f.e. F_WEEKSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'weeksbetween');

/* all FreeAdhocUDFs using entrypoint 'yearsbetween' f.e. F_YEARSBETWEEN */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'yearsbetween');

/* all FreeAdhocUDFs using entrypoint 'dayofmonth' f.e. F_DAYOFMONTH */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'dayofmonth');

/* all FreeAdhocUDFs using entrypoint 'dayofweek' f.e. F_DAYOFWEEK */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'dayofweek');

/* all FreeAdhocUDFs using entrypoint 'dayofyear' f.e. F_DAYOFYEAR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'dayofyear');

/* all FreeAdhocUDFs using entrypoint 'year' f.e. F_YEAR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'year');

/* all FreeAdhocUDFs using entrypoint 'month' f.e. F_MONTH */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'month');

/* all FreeAdhocUDFs using entrypoint 'quarter' f.e. F_QUATER */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'quater');

/* all FreeAdhocUDFs using entrypoint 'week' f.e. F_WEEK */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'week');

/* all FreeAdhocUDFs using entrypoint 'hour' f.e. F_HOUR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'hour');

/* all FreeAdhocUDFs using entrypoint 'minute' f.e. F_MINUTE */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'minute');

/* all FreeAdhocUDFs using entrypoint 'second' f.e. F_SECOND */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'second');

/* all FreeAdhocUDFs using entrypoint 'isleapyear' f.e. F_ISLEAPYEAR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'isleapyear');

/* all FreeAdhocUDFs using entrypoint 'lastday' f.e. F_LASTDAY */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'lastday');

/* all FreeAdhocUDFs using entrypoint 'weekofyear' f.e. F_WEEKOFYEAR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'weekofyear');

/* all FreeAdhocUDFs using entrypoint 'yearofyear' f.e. F_YEAROFYEAR */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'yearofyear');

/* all FreeAdhocUDFs using entrypoint 'zeitdifferenz' f.e. F_ZEITDIFFERENZ */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'zeitdifferenz');

/* all FreeAdhocUDFs using entrypoint 'dtime' f.e. F_DTIME */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'dtime');

/* all FreeAdhocUDFs using entrypoint 'daysofmonth' f.e. F_DAYSOFMONTH */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'daysofmonth');

/* all FreeAdhocUDFs using entrypoint 'equaldate' f.e. F_EQUALDATE */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'equaldate');

/* all FreeAdhocUDFs using entrypoint 'equaldatetime' f.e. F_EQUALDATETIME */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'equaldatetime');

/* all FreeAdhocUDFs using entrypoint 'lastday' f.e. F_LASTDAY */ 
UPDATE RDB$FUNCTION_ARGUMENTS FA SET FA.RDB$MECHANISM = -1 
WHERE FA.RDB$ARGUMENT_POSITION = 0 AND FA.RDB$MECHANISM = 0
AND EXISTS (SELECT 1 FROM RDB$FUNCTIONS F WHERE FA.RDB$FUNCTION_NAME = F.RDB$FUNCTION_NAME 
AND F.RDB$MODULE_NAME CONTAINING 'FreeAdhocUDF' AND F.RDB$ENTRYPOINT = 'lastday');

/* adhoc 2006-11-30 */
