简体   繁体   English

db2存储过程格式

[英]db2 stored procedure format

I'm using db2 and SQuirreL SQL 我正在使用db2和SQuirreL SQL

I'm trying to create a stored procedure with a simple select statement inside of it. 我正在尝试使用一个简单的select语句创建一个存储过程。 When I omit the select statement in the following below and run the code, the procedure is created. 当我在下面的下面省略select语句并运行代码时,将创建该过程。 Also this procedure can be dropped and called. 也可以删除并调用此过程。

    CREATE PROCEDURE test_procedure
    LANGUAGE SQL
    BEGIN

    END

When I add in the select statement, I get Error: DB2 SQL Error: SQLCODE=-102, SQLSTATE=42601,... 当我添加选择语句时,出现错误:DB2 SQL错误:SQLCODE = -102,SQLSTATE = 42601,...

    CREATE PROCEDURE test_procedure
    LANGUAGE SQL
    BEGIN
        SELECT column_name FROM table_name
    END

If you go to IBM iseries information center is says: 如果您转到IBM iseries信息中心,则表示:

SQL0104 SQLCODE -104 SQLSTATE 42601 SQL0104 SQLCODE -104 SQLSTATE 42601

Explanation: Token &1 was not valid. 说明:令牌&1无效。 Valid tokens: &2. 有效令牌:&2。

It appears that I wasn't given the right permissions to execute the stored procedure. 似乎我没有获得执行存储过程的正确权限。 SQL0551N This link explains more about the issue. SQL0551N此链接详细说明了此问题。

The statement terminator in SQuirreL is called "Statement separator" and it can be defined in: SQuirreL中的语句终止符称为“语句分隔符”,可以在以下位置定义:

Menu Session > Session Properties... > tab SQL > at the end of the SQL square, the option Statement Separator. 菜单会话>会话属性...>选项卡SQL>在SQL方块的末尾,选择Statement Separator。

在此处输入图片说明

This is valid in version 3.5.3 这在版本3.5.3中有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM