Execute
mysql procedure from command line
To call mysql
stored proceudres from command line,first login into mysql using this command
mysql
–u[username] –p[password] database_name then,
Suppose your
procedure name is countNoOfRows(),use this command
call countNoOfRows();
To call
parameterized stored procedure,
call countNoOfRows(1,’myRow’);
To execute stored
procedure and prints its output in txt file,open command line and use this command,
suppose your procedure name is “calculate_raw_data()”
mysql
-uroot -prootDB nos -e "call calculate_raw_data('2,3','23') " >/exports/satish/output.txt
It will print the output in ouput.txt file which gets created
in location >/exports/satish/.
This can be used when you are trying to debug your mysql stored
procedure. You can print output at each line and monitor afterwards what’s
exactly happening in your stored procedure.
As in many Linux distributions mysql gui application doesn’t work,
above command can be useful for debugging purpose.
No comments:
Post a Comment