CARDINALITY 함수

CARDINALITY 함수는 목록에서 요소의 수를 리턴합니다.

구문

CARDINALITY는 ListExpression에 의해 지정된 목록에서 요소의 수를 제공하는 정수 값을 리턴합니다.

ListExpression은 목록을 리턴하는 표현식입니다. 예를 들어, 다음 모두는 목록을 리턴합니다.
  • LIST 구성자
  • [] 배열 표시기가 있는 필드 참조
  • 일부 SELECT 표현식(모두 목록을 리턴하지는 않음)

이 함수의 일반적인 사용은 반복하기 전에 목록에서 필드의 수를 판별하는 것입니다.

-- Determine the number of F1 fields in the message.
-- Note that the [ ] are required   
DECLARE CountF1 INT CARDINALITY(OutputRoot.XML.Data.Source.F1[]);
-- Determine the number of fields called F1 with the value 'F12' in the message.
-- Again note that the [ ] are required
DECLARE CountF1F12 INT     
  CARDINALITY(SELECT F.* FROM OutputRoot.XML.Data.Source.F1[] AS F where F = 'F12');
-- Use the value returned by CARDINALITY to refer to a specific element in a list or array:  
-- Array indices start at 1, so this example refers to the third-from-last instance of the Item field
Body.Invoice.Item[CARDINALITY(Body.Invoice.Item[]) - 2].Quantity
관련 개념
ESQL 개요
관련 작업
ESQL 개발
주의사항 | 등록상표 | 다운로드 | 라이브러리 | 지원 | 피드백
Copyright IBM Corporation 1999, 2005 마지막 갱신 날짜: 11/08/2005
ak05530_