If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Mysql Script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-22-05, 11:12
petenyce105 petenyce105 is offline
Registered User
 
Join Date: May 2004
Posts: 86
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 14:31.
Reply With Quote
  #2 (permalink)  
Old 11-23-05, 22:19
jfulton jfulton is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On