2011-05-17 49 views
0

我需要檢查我正在執行的select操作是否返回任何行。
有人可以幫助我這個。用於檢查選擇操作是否返回行的SQL查詢

我正在使用shell腳本,因此我無法將其保存在變量中並進行檢查。我需要在飛行中檢查。我知道我可以使用計數開關。但有人可以幫我的語法?

例如,我需要檢查:

--Now this query should return some data 
select * from error_repository_BKP partition(part_maxval); 

回答

1
select count(*) from error_repository_BKP partition(part_maxval); 

0
If exists (Select 1 from error_repository_BKP partition(part_maxval)) 
    Begin 
     print 'returns Row' 
    End 
Else 
    Begin 
     Print 'No Rows' 
    End 

?? ??