`
robinfung
  • 浏览: 55122 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

myShellScript

阅读更多

Pagination + Informix

INFORMIXDIR=/usr/informix
rowCount="your saved row count"
# safe the row count in a temp txt file
(
$INFORMIXDIR/bin/isql -s ??<<!EOF
set isolation to dirty read;
unload to '${rowCount}' 
select count(*) from ?? where dt between date('08/08/2008') and date('08/08/2008');
!EOF
)
COUNTER=0
#row count
for tmp in `awk '{print $1}' ${rowCount}`
do 
   COUNTER=`echo $tmp|cut -d "." -f1`
done

pageSize=100
offset=1
lastPageOffset=0

until [ offset -gt $COUNTER ]
do	
## start SQL
echo $offset
(
$INFORMIXDIR/bin/isql -s ??<<!EOF
set isolation to dirty read;       
unload to  '/${ENV}/??/lib/download/??/??.csv' DELIMITER ','   
select SKIP ${offset} FIRST ${pageSize} * from ??
where dt between date('08/08/2008') and date('08/08/2008')
;
!EOF
)
## end SQL
   	offset=`expr $offset + $pageSize`
   	if [ $offset -gt $COUNTER ] 
   	then
   		lastPageOffset=`expr $offset - $pageSize`
   		break
   	fi
done
## handle last page
if [ $lastPageOffset -gt 0 ]
then
	echo "this is last page"
	echo $lastPageOffset
## s
	(
$INFORMIXDIR/bin/isql -s ??<<!EOF
set isolation to dirty read;       
unload to  '/${ENV}/??/lib/download/??/??.csv' DELIMITER ','   
select SKIP ${offset} FIRST ${pageSize} * from ??
where dt between date('08/08/2008') and date('08/08/2008')
;
!EOF
)
fi
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics