在System i V7R1中创建函数时出错SQL0104 [英] Error SQL0104 when creating a function in System i V7R1

查看:405
本文介绍了在System i V7R1中创建函数时出错SQL0104的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在System i V7R1上创建了一个SQL函数:
$ b $ pre $ CREATE FUNCTION MYSCHEMA.GROUPDIBAS(v_code VARCHAR(50) )
RETURNS VARCHAR(2048)
LANGUAGE SQL
BEGIN
DECLARE str VARCHAR(2048);
SET str ='';
对于行AS(
SELECT
FIELD2
FROM MYSCHEMA.DIBAS
WHERE FIELD1 = v_code

DO
SET str ='布比'; - 我删除了很多语句来说明问题不是来自它们
END FOR;
RETURN str;
END
;

我使用运行SQL脚本工具(它是iSeries Navigator V7R1的一部分)执行它。
它可以在另一个V7R1服务器(使用iSeries Navigator V5R4)上工作,但不能在我现在工作的那个服务器上工作。它失败,这个消息:

$ pre $ code $ SQL状态:42601
厂商代码:-104
消息: SQL0104]令牌< END-OF-STATEMENT>是无效的。有效令牌:;。
原因。 。 。 。 。 :在标记< END-OF-STATEMENT>处检测到语法错误。
令牌< END-OF-STATEMENT>不是一个有效的标记。有效令牌的部分列表是;
此列表假定该声明在标记之前是正确的。
错误可能在语句中更早,但语句的语法似乎在此之前是有效的。
恢复。 。 。 :执行以下一项或多项操作,然后再次尝试请求:
- 验证标记< END-OF-STATEMENT>区域中的SQL语句。改正陈述。
错误可能是一个缺少的逗号或引号,可能是一个拼错的单词,或者它可能与子句的顺序有关。
- 如果错误标记为< END-OF-STATEMENT>,请更正SQL语句,因为它不以有效子句结束。

如果我删除 FOR 块,工程。

此外,如果我用5250模拟器命令STRSQL执行语句,它的工作原理。因此,它在<运行SQL脚本>客户端中看起来像一个bug 。



任何提示将不胜感激!
鉴于@JamesA和我所做的测试,我担心这个问题可能出现在 Program Temporary Fix (PTF)程序中服务器没有和其他人有。特别是,运行 WRKPTFGRP 命令,我猜可能会错过这个PTF组:

  PTF组级文本
SF99701 5 DB2 for IBM I

不幸的是,现在尝试安装它:(。


I'm creating a SQL function on System i V7R1:

CREATE FUNCTION MYSCHEMA.GROUPDIBAS(v_code VARCHAR(50))
RETURNS VARCHAR(2048)
LANGUAGE SQL
BEGIN
    DECLARE str VARCHAR(2048);
    SET str = '';
    FOR row AS (
        SELECT 
            FIELD2
        FROM MYSCHEMA.DIBAS
        WHERE FIELD1 = v_code
    )
    DO
        SET str = 'Bubi'; --I removed many statements to make clear the problem doesn't come from them
    END FOR;
    RETURN str;
END
;

I execute it with "Run SQL script" tool, which is part of the iSeries Navigator V7R1. It works on another V7R1 server (using iSeries Navigator V5R4), but not in that one where I'm working now. It fails with this message:

SQL State: 42601
Vendor Code: -104
Message: [SQL0104] Token <END-OF-STATEMENT> was not valid. Valid tokens: ;.
  Cause . . . . . :   A syntax error was detected at token <END-OF-STATEMENT>.
  Token <END-OF-STATEMENT> is not a valid token.  A partial list of valid tokens is ;.
  This list assumes that the statement is correct up to the token.
  The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point.
  Recovery  . . . :   Do one or more of the following and try the request again:
  -- Verify the SQL statement in the area of the token <END-OF-STATEMENT>. Correct the statement.
     The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses.
  -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.

If I remove the FOR block, it works.

Moreover if I execute the statement with 5250 Emulator, command STRSQL, it works. So it seems like a bug in "Run SQL script" client.

Any hint will be appreciated!

解决方案

Given the tests made by @JamesA and me, I fear the problem can be in the Program Temporary Fix (PTF) that this server hasn't and the other ones have. Specifically, running WRKPTFGRP command, I can guess it probably misses this PTF group:

PTF group  Level  Text
SF99701        5  DB2 FOR IBM I

Unfortunately I can't try installing it now :(.

这篇关于在System i V7R1中创建函数时出错SQL0104的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆