EXISTS 함수는 목록에 하나 이상의 요소가 있는지 여부(즉, 목록이 존재하는지 여부)를 나타내는 BOOLEAN 값을 리턴합니다.
ListExpression에 의해 지정된 목록에 하나 이상의 요소가 포함되는 경우 EXISTS는 TRUE를 리턴합니다. 목록에 요소가 없는 경우 EXISTS는 FALSE를 리턴합니다.
목록에 요소가 포함되어 있는지 여부만 알려는 경우 EXISTS는 CARDINALITY 함수(예: CARDINALITY(ListExpression ) <> 0)를 포함하는 표현식보다 빠르게 실행합니다.
이 함수의 일반적인 사용은 필드가 존재하는지 여부를 판별하는 것입니다.
-- Determine whether the F1 array exists in the message. Note that the [ ] -- are required DECLARE Field1Exists BOOLEAN EXISTS(OutputRoot.XML.Data.Source.F1[]);
-- Determine whether the F1 array contains an element with the value 'F12'. -- Again note that the [ ] are required DECLARE Field1F12Exists BOOLEAN EXISTS(SELECT F.* FROM OutputRoot.XML.Data.Source.F1[] AS F where F = 'F12');