I have the following FUNCTION and PROCEDURE. When I call the function on a normal SELECT statement (ie. "SELECT dbo.CLIENT_DELETE('100');") it returns the following error:
'Only functions and some extended stored procedures can be executed from within a function.'
Here is my FUNCTION and PROCEDURE codes:
I am not C/C++/PHP coder. But can't PHP call a stored procedure ?
You can write a stored procedure in SQL Server that perform what you want here.
Anyway your current CLIENT_DELETE_PROC is already doing it. Here i make some changes to remove the cursor loop which is not required at all
And in your PHP call the stored procedure CLIENT_DELETE_PROC to delete the record.
answered Jul 22, 2010 at 09:13 PM
A user defined function can't update the database, only variables. Check out
answered Jul 22, 2010 at 02:21 PM
Ignore this answer - it's wrong (apart from the 3rd attempt). However, there's some useful discussion in the comments area, which is why I haven't deleted it.
Can't be done. At least not like that.
Try replacing the cursor and its associated code with the following:
I'm sorry, I've been going about this the wrong way. The error message is the answer - "only some extended stored procedures and functions..."
2nd attempt at the answer:
Rip out the reference to the stored procedure, and put those three deletion statements into the function.
OK, so I'm wrong there too. You can't alter data within a function. Apologies for the run-around - I blame it on lack of sleep.