判断可变数组和嵌套表的指定元素是否存在。 EXISTS(n):如果第n个元素存在,存在返回TRUE,否则FALSE。如果n超出了索引范 围,返回false。对于被Delete(n)删除的元素,返回false。 CREATE OR REPLACE PROCEDURE P_5_18 AS TYPE NumList IS TABLE OF INTEGER; n NumList := NumList(1,3,5,7); BEGIN
GBase 8s PL/SQL手册 南大通用数据技术股份有限公司 - 75 -
n.DELETE(2); -- Delete second element FOR i IN 1..6 LOOP IF n.EXISTS(i) THEN DBMS_OUTPUT.PUT_LINE('n(' || i || ') = ' || n(i)); ELSE DBMS_OUTPUT.PUT_LINE('n(' || i || ') does not exist'); END IF; END LOOP; END;
--Result: --n(1) = 1 --n(2) does not exist --n(3) = 5 --n(4) = 7 --n(5) does not exist --n(6) does not exist
The following program converts two longs to INT8 types and displays the results. */
GBase 8s ESQL/C 编程指南 南大通用数据技术股份有限公司 - 737 -
#include
EXEC SQL include "int8.h";
char result[41];
main() { mint x; ifx_int8_t num; int4 n;
printf("IFX_INT8CVLONG Sample ESQL Program running.\n\n");
printf("Long Integer 1 = 129449233\n"); if (x = ifx_int8cvlong(129449233L, #)) { printf("Error %d in converting long to INT8\n", x); exit(1); } if (x = ifx_int8toasc(#, result, sizeof(result))) { printf("Error %d in converting INT8 to string\n", x); exit(1); } result[40] = '\0'; printf(" String for INT8 type value = %s\n", result);
n = 2147483646; /* set n */ printf("Long Integer 2 = %d\n", n); if (x = ifx_int8cvlong(n, #)) { printf("Error %d in converting long to INT8\n", x);
GBase 8s ESQL/C 编程指南 南大通用数据技术股份有限公司 - 738 -
exit(1); } if (x = ifx_int8toasc(#, result, sizeof(result))) { printf("Error %d in converting INT8 to string\n", x); exit(1); } result[40] = '\0'; printf(" String for INT8 type value = %s\n", result);
printf("\nIFX_INT8CVLONG Sample Program over.\n\n"); exit(0); } 输出 IFX_INT8CVLONG Sample ESQL Program running.
Long Integer 1 = 129449233 String for INT8 type value = 129449233 Long Integer 2 = 2147483646 String for INT8 type value = 2147483646 IFX_INT8CVLONG Sample Program over.