mysqlmysql-udf

MySQL UDF sys_exec


I am using MySQL UDF function sys_exec for calling Java program inside a trigger of MySQL. Can you please provide me the information about how I pass argument to sys_exec so that it will call Java program?


Solution

  • You can use this link to use sys_exec function. It says,

    sys_exec sys_exec takes one command string argument and executes it. Syntax

    sys_exec(arg1) Parameters and Return Values

    arg1 : A command string valid for the current operating system or execution environment. returns An (integer) exit code returned by the executed process. Installation

    Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement: CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so'; The function will be globally available in all databases. The deinstall the function, run the following statement: DROP FUNCTION sys_exec;

    For executing Java program you should fill arg1 as "java <absolute path to precompiled program to run>".

    Note: path to java should be configured before hand.

    Hope it helps...