all groups > sql server programming > november 2005 >
You're in the

sql server programming

group:

Update records in CLR-UDF


Update records in CLR-UDF K.k
11/14/2005 10:50:06 PM
sql server programming:
Hi,
I want to update some records with CLR-Function. But I got error that
indicate I can't edit records with CLR-Function.

"Error Message: A .NET Framework error occurred during execution of user
defined routine or aggregate fn_myFunction:
System.Data.SqlClient.SqlException: Invalid use of side -effecting or time
-dependent operator in ‘UPDATE’ within a function."

As a alternative way I create T-SQL function which update my records and
call this function in that CLR-UDF. But ther error stills.
Some one told me use IsMutrator parameters, but I think this is for UDT only.

Re: Update records in CLR-UDF Ole Kristian Bangås
11/15/2005 12:16:57 AM
=?Utf-8?B?Sy5r?= <K.k@discussions.microsoft.com> wrote in
news:5E04FAE4-CFCC-4437-A46F-86C6E670F704@microsoft.com:

[quoted text, click to view]

This is by design: "User-defined functions cannot be used to perform
actions that modify the database state.". In other words (as I read this)
DML and similar methods in .NET is not allowed within a function, you
should use a stored procedure instead. Yeah, I know. This is really
frustrating.

--
Ole Kristian Bangås
Re: Update records in CLR-UDF Jens
11/15/2005 12:45:03 AM

Mutators are onyl for the expression within the function, as values
that have already been calculated could change, the DML is not allowed
in a function. Thats one of the limitation which already existed in
SQL2k.

HTH, Jens Suessmeyer.
Re: Update records in CLR-UDF Curtis
8/3/2006 3:07:02 PM
I am trying to insert records. Is it possible to execute a stored procedure a
CLR function to insert the records?

[quoted text, click to view]
AddThis Social Bookmark Button