code

Using LOAD DATA INFILE with Stored Procedure Workaround-MySQL

Okay! So here we will use Load Data syntax to load file into MySQL Server in a Stored procedure. Yep! It’s a workaround. Download MySQL UDF: [root@localhost kedar]# wget http://www.mysqludf.org/lib_mysqludf_sys/lib_mysqludf_sys_0.0.3.tar.gz [refer: http://www.mysqludf.org/] Extract and Install: [root@localhost kedar]# tar -xzvf lib_mysqludf_sys_0.0.3.tar.gz install.sh lib_mysqludf_sys.c lib_mysqludf_sys.html lib_mysqludf_sys.so lib_mysqludf_sys.sql Makefile [root@localhost kedar]# sh install.sh Compiling the MySQL UDF gcc -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so MySQL UDF compiled successfully Please provide your MySQL root password Enter password: MySQL UDF installed successfully Create function sys_exec as follows: CREATE FUNCTION sys_exec RETURNS INT SONAME ‘lib_mysqludf_sys.so’; sys_exec – executes an arbitrary command, and returns it’s exit...

MySQL Function to Convert Date To Words

Recently I saw a MySQL Stored Function requirement on Experts-Exchange for converting date into some specific words format. You may find MySQL function for date to words conversion online; even udfs might be ready, but I decided to write my own. I wrote this simple function mainly based on SELECT CASE to convert dates in to words as follows: mysql>SELECT date_to_words(‘2010-05-08’); Eighth Day of May Two Thousand Ten Download sql file below the code. DELIMITER $$ DROP FUNCTION IF EXISTS `date_to_words` $$ CREATE FUNCTION `date_to_words` (mydate DATE) RETURNS VARCHAR(100) DETERMINISTIC BEGIN /* Converts date into words */ DECLARE yr INT;...

My worst mathematical program in perl

I have a Mathe-crap-matical friend. Who keeps digging into graves of dead formulas and equations and all possible Math related stuffs. Since I started understanding Mathematics (that it’s not my cup of tea), I tried to stay away from it. Now, that enthu creature mailed me his requirement. He says he “eat mathematics”, I prefer to stay away from such guys. But as a good friend I read his mails. His requirement was to create a program. His requirements are: N is a natural number falling in range [1 – 999999] X is a number given by user with range...

Java termwork connect Access Database and operations

Prologue: Long back there were golden days of post graduation in the “great” DDIT (Now Dharamsinh Desai University), Nadiad. Assignments, termwork and journals or everything similar was in demand – I attempted a java code as my termwork on Monday, October 03, 2005. [That’s created date of .java file, I don’t remember anything.] A “variable check” became very famous, notorious actually, for some unmentionable reasons. It was recently mentioned by Utkarsh AKA Bapu. Later I decided to scan each bit of my harddisk and get that 8582 code. So here is that java code and it was working 5 years...

MySQL Stored procedure to Generate-Extract Insert Statement

A lot of places I saw people asking for ways to generate Insert statements. We do have GUI Tools which can extract insert statements for us readily. of the time I choose the MySQLDump way to generate insert statements. mysqldump -uroot -ppassword –complete-insert –no-create-info DATABASE TABLENAME > TABLENAME.sql But mind is very unstable and hungry, we don’t stop at one solution. So to remove my mind’s starvation for the Stored Procedure way to extract Insert statement I created following routine. As you can see this is really a simple procedure revolves around Information_schema mainly to get details of any table...