I have a script to get the information from database, however, it's look like the loop is not work, can someone help?
echo Input file list to check:
read filelist
for file in 'cat $filelist.txt'
do
echo "select FILENAME from FILE_TABLE where filename like '${file}'%;" >> output_file.txt
done
echo Completed Check!!
The filelist is:
list1
A1-67630403
A2-04985959
B3-04857858
B6-058744748
C10-59584583
What does not work? Do you see an errormessage or do you get wrong results? What shell, OS and database-system are you using?
About the SQL-syntax: its either filename = \'${file}\' looking for exact matches or filename like \'${file}%\' looking for values that start with those strings.
I am just tried to use my original script and based on your comment,
echo Input file list to check:
read filelist
for file in `cat $filelist.txt`
do
echo "select FILENAME from FILE_TABLE where filename like '${file}'%;" >> output_file.txt
done
echo Completed Check!!
The filelist is:
list1
A1-67630403
A2-04985959
B3-04857858
B6-058744748
C10-59584583
Your select-statment only fetches the column FILENAME, not ORIGMODIFYDATE...
To answer your question we need to know what database system, and maybe what tool (SQL-client) you use to retrive the data. Your script creates some statments but does not issue them against the db.