Return the file size by using the LOAD_FILE function : Buildin Functions : Procedure Function SQL / MySQL


SQL / MySQL » Procedure Function » Buildin Functions »

 

Return the file size by using the LOAD_FILE function


 
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, rows affected (0.00 sec)

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

Query OK, rows affected, warnings (0.00 sec)

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

mysql>
mysql>

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

SQL / MySQL

 Navioo Procedure Function
» Buildin Functions