1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bash MySQL and quotes for SQL queries.

Discussion in 'HTML, Graphics & Programming' started by RimBlock, 26 Apr 2010.

  1. RimBlock

    Wise Guy

    Joined: 10 Nov 2004

    Posts: 2,237

    Location: Expat in Singapore

    Hi,

    I am having very little sucess in trying to get a stored proc run from a Bash script via MySql with the MySql command and the SQL being held in variables.

    e.g.

    The echo statement returns;
    which is correct.

    The statement to fire against the MySQL database transposes the command to;
    which is wrong (note the single quotes seperating the 'call' and the 'sp_name' sections).

    So the question is how to be able to get the vale of the variable SQL in one set of single quotes including spaces.

    Thanks
    RB
     
  2. RimBlock

    Wise Guy

    Joined: 10 Nov 2004

    Posts: 2,237

    Location: Expat in Singapore

    After a lot more searching I have come across using subshells (am used to ksh and not bash). From that I have found that just putting double quotes around the SQL variable quotes it correctly.

    so;
    becomes;
    returns;
    So obvious really, when you know ;).

    RB