下面的 SQL 查询不会将列提取到 v_columns 中。当我打印 v_columns 时它总是 NULL
SET v_sql = 'SELECT LISTAGG(COLNAME , '','') WITHIN GROUP (ORDER BY COLNO) INTO :v_columns ' || 'FROM SYSCAT.COLUMNS ' || 'WHERE TABNAME = ''' || v_tableName || ''' AND COLNAME <> ''TOWID''';
区分大小写。
尝试:
SET v_sql = 'SELECT LISTAGG(COLNAME , '','') WITHIN GROUP (ORDER BY COLNO) INTO :v_columns ' || 'FROM SYSCAT.COLUMNS ' || 'WHERE UPPER(TABNAME) = UPPER(''' || v_tableName || ''') AND COLNAME <> ''TOWID''';