I suspect that what was going wrong here was that you were attempting to present
SQL commands to
Bash, which of course had no idea what you were talking about.
But, yes, stored procedures are ... well ...
stored! They're compiled by the SQL engine and then stored in a system database ready to be executed via an SQL command.
Also: remember that you can use
any programming language to "write a shell script," thanks to the
#!command_processor "shebang" syntax. Bash looks for that line and, if it finds it, invokes the specified command-processor to do the work. So, don't waste time and effort trying to make
Bash do stuff that it was never designed to do, given that you have literally dozens of alternatives which
do support SQL interaction (without resorting to external commands to do it). Perl, PHP, Ruby, Java. Etcetera. One of the greatest strengths of the Unix/Linux environment is just
how many ways there are to "do it."