我有两个游标如下:
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DISTINCT FIELD_1
FROM TABLE
WHERE FIELD_2 BETWEEN :MAX_DATE
AND '9999-12-31'
AND FIELD_3 = :VALUE
WITH UR
FOR FETCH ONLY
END-EXEC
EXEC SQL
DECLARE C2 CURSOR FOR
SELECT DISTINCT FIELD_1
FROM TABLE
WHERE FIELD_2 BETWEEN :MIN_DATE
AND '9999-12-31'
AND FIELD_3 = :VALUE
WITH UR
FOR FETCH ONLY
END-EXEC
两个游标都指向同一个表。我如何组合两个游标?请让我知道一种方法来组合这两个表。
答案 0 :(得分:0)
如果您只想组合两个游标的谓词,当然可以这样做。结合WHERE
条款:
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DISTINCT FIELD_1
FROM TABLE
WHERE FIELD_2 BETWEEN :MIN_DATE
AND :MAX_DATE
AND FIELD_3 = :VALUE
WITH UR
FOR FETCH ONLY
END-EXEC
问题中的示例包含9999-12-31
范围内的最小值和最大值,这对我没有意义。