m7484@hotpop.com (markus) wrote in message
news:<b226eb71.0407010038.35683663@posting.google. com>...[color=blue]
>
> What I want is my function to evaluate each field and put the new
> value in the field.[/color]
A user-defined function (UDF) is a way to extend MySQL with
a new function that works like native (built in) MySQL function
such as ABS() and CONCAT().
...
For instructions on writing user-defined functions, see section
23.2 Adding New Functions to MySQL. For the UDF mechanism to work,
functions must be written in C or C++, your operating system must
support dynamic loading and you must have compiled mysqld
dynamically (not statically).
http://dev.mysql.com/doc/mysql/en/CREATE_FUNCTION.html
In other words, if you want write user-defined functions in SQL,
consider switching to PostgreSQL or a commercial SQL engine.
[color=blue]
> For example, this works:
> $sql= "UPDATE mytable SET myfield=myfield+3";
>
> Stores myfield+3 in each myfield, but with a function it does not
> work.
>
> Obviously, multiple queries in a loop do work but what I need is a
> single call.[/color]
Consider writing a query that will work along the lines of
UPDATE mytable SET myfield=myfield+3
Cheers,
NC