Return the file size by using the LOAD_FILE function : Buildin Functions « Procedure Function « MySQL Tutorial






mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE filesize(in_file_name VARCHAR(128))
    ->
    -> BEGIN
    ->   DECLARE mytext TEXT;
    ->   SET mytext=LOAD_FILE(in_file_name);
    ->   SELECT in_file_name||' contains '||length(mytext)||' bytes'
    ->       AS output;
    -> END$$
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> delimiter ;
mysql> call filesize("a.txt");
+--------+
| output |
+--------+
|   NULL |
+--------+
1 row in set (0.00 sec)

Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> drop procedure filesize;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>








11.32.Buildin Functions
11.32.1.Check MySQL version
11.32.2.Call buildin math function in your procedure
11.32.3.Use Build-in SUM function in a procedure
11.32.4.Using String functions in a user-defined function
11.32.5.Return the file size by using the LOAD_FILE function