【问题标题】:What is the best/most correct way to iterate through the characters of a string in ESQL?在 ESQL 中迭代字符串字符的最佳/最正确方法是什么?
【发布时间】:2020-02-13 10:00:15
【问题描述】:

在 ESQL 中迭代字符串字符的最佳/最正确方法是什么?

在 Java 中我会这样做,但我如何在 esql 中做到这一点?

String s = "...stuff...";

for (int i = 0; i < s.length(); i++){
    char c = s.charAt(i);        
    //Process char }

【问题讨论】:

  • 你到底想对角色做什么?

标签: ibm-integration-bus extended-sql


【解决方案1】:
DECLARE text CHAR 'asdf';
DECLARE TOTAL INT;
DECLARE count INT 1;
SET TOTAL = LENGTH(text);

WHILE count <= TOTAL DO
    DECLARE c CHAR;
    SET c = SUBSTRING(text FROM count FOR 1);

    SET count = count + 1;
END WHILE;

【讨论】:

    猜你喜欢
    • 2013-02-26
    • 2010-09-16
    • 1970-01-01
    • 2011-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    相关资源
    最近更新 更多