Please tell me how to define MySQL User Defined Function with in PHP...
I'm using following code.but it is not working.
it throws error :
" (1313) RETURN is only allowed in a FUNCTION "
$mysqli = new mysqli( $DBHost, $DBUserName, $DBPassword, $DBName );
$Query =
"CREATE PROCEDURE FunGetRegistryValue(OUT Param_RegistryKey varchar(40))
BEGIN
DECLARE vResult varchar(90);
SELECT iFnull(Value,'') INTO vResult FROM Project_Registry Where RegistryKey=Param_RegistryKey;
RETURN(vResult);
END;";
if( !$mysqli->query( $Query ) ) {
echo "Stored procedure creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
When i use FUNCTION keyword instead of PROCEDURE then i get syntax error...
Please give me example code for "VALUE RETURNING FUNCTION"