Calling MYSQL Stored Procedure?

Hi,

Can anyone help me with the correct syntax to call a MYSQL stored procedure from a shell script.

I have tried the following, (no input params):
/usr/bin/mysql -uadmin -ppassword call TL_CLENSEDATA();

resulting in error:
/home/hosting/data/scripts/dbclense.sh: line 12: syntax error near unexpected token `('
/home/hosting/data/scripts/dbclense.sh: line 12: `/usr/bin/mysql -uadmin -ppassword call TL_CLENSEDATA();'

Thanks.

tried using the 'Search' function of these forums? Any luck there?

Didn't come accross anything for MYSQL, only Oracle and DB2

Hi there,

I work quite a bit with MySQL in Unix so I might be able to help you. Without knowing exactly what you are trying to accomplish I can't be 100% sure what I say will be your solution but it might be a starting block.

Just to state the obvious (maybe) you can execute a mysql command from a shell script by using the -e flag.... example

mysql -uadmin -ppassword db_name_here -e "SELECT * FROM WHATEVER....";

Now you could call your stored procedure from a .sql file in which case I believe the following would work for you

mysql -uadmin -ppassword db_name_here < call_file.sql > result_of_action.txt

the redirection could be replaced with something else or whatever you want to do with your output.

If this doesn't work then just let me know more what you're trying to achieve and I can try and help you better. :slight_smile: