Please check and correct me. While passing the * in the the variable , it is select all the files in the folder.
<<<
cat /home/spanda20/p2020/m23/query/p2020_m23_ora_sqoop_unld_query.dat
loc_query|”select * from SCPOMGR.LOC where \$CONDITIONS”
export SQOOP_QUERY_FILE='/home/spanda20/p2020/m23/query/p2020_m23_ora_sqoop_unld_query.dat'
export TBL_NM='loc'
TBL_QUERY=`grep ${TBL_NM}_query ${SQOOP_QUERY_FILE} | awk -F "|" '{print $2}'`
sqoop import --connect xxxx --username yyyy --password zzzzz --query "$TBL_QUERY" >>>
Output I am getting:
++ grep loc_query /home/spanda20/p2020/m23/query/p2020_m23_ora_sqoop_unld_query.dat
++ awk -F '|' '{print $2}'
+ export 'TBL_QUERY="select * from SCPOMGR.LOC where \$CONDITIONS"'
+ TBL_QUERY='"select * from SCPOMGR.LOC where \$CONDITIONS"'
+ echo TBL_QUERY : '"select * from SCPOMGR.LOC where \$CONDITIONS"'
TBL_QUERY : "select * from SCPOMGR.LOC where \$CONDITIONS"
sqoop import --connect jdbc:oracle --username MA7D --password W_123 --query '"select * from SCPOMGR.LOC where \$CONDITIONS"' --target-dir /user/spanda20/informatica_p2020/p2020/stg/m23/20150401 -m 1
If you see , the select statement is started with single quote and a double and also ending with same. I need only a double quote.
ex:
TBL_QUERY : "select * from SCPOMGR.LOC where \$CONDITIONS"