Results 1 to 2 of 2

Thread: Mysql Script

  1. #1
    Join Date
    May 2004
    Posts
    86

    Unanswered: Mysql Script

    Hers is my full bin bash script. I only want to run the this script if their is data in my table? if not do nothing?

    thanks

    #!/bin/bash
    date=`date +%Y%m%d%H%M%S`
    file="ReferralAuth$date.txt"
    cat /usr/etc/extractreferral.sql | sed -e "s/file/$file/g" |/usr/bin/mysql -u root XXXXX


    extractreferral.sql
    SELECT * INTO OUTFILE '/tmp/file'
    FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' FROM Referral_Authorization
    Last edited by petenyce105; 11-22-05 at 15:31.

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Depending on your version of MySQL you'll most likely have to write a stored procedure in MySQL to do the data check, or write another .sql file to call a COUNT(*) on your table and have the bash script contain the "if" logic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •