如何在 IBM System i Access for Windows GUI Tool 中调用存储过程

发布于 2024-08-19 12:59:13 字数 234 浏览 3 评论 0原文

我想测试在 AS400 系统上运行的 DB2 存储过程。

我安装了 IBM System i Access for Windows,并且可以针对 DB2 数据库运行 SQL 命令。

我的问题是:执行接受参数并返回结果作为输出参数并将值打印到屏幕的存储过程的语法是什么?

只是为了澄清:我不是问如何在代码中调用过程。我想执行过程并在gui工具(类似于SQL Enterprise Manager)中查看结果。

I would like to test a DB2 stored procedure running on an AS400 system.

I have the IBM System i Access for Windows installed and can run SQL commands against the DB2 database.

My question is: What is the syntax to execute a stored procedure that takes in a parameter and returns a result as an output parameter and print the value to the screen?

Just to clarify: I am not asking how to call the proc in code. I want to execute the proc and see the results in the gui tool (which is similar to SQL Enterprise Manager).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

东北女汉子 2024-08-26 12:59:13

使用关键字call并传入参数。

call myStoredProc(parm1, parm2, ?);

有关更多详细信息,请参阅此处 http://www.ibm.com/developerworks /data/library/techarticle/dm-0503melnyk/。有趣的部分是图 5. 使用命令编辑器调用 SQL 过程

use the keyword call and pass in the parameters.

call myStoredProc(parm1, parm2, ?);

for more details see here http://www.ibm.com/developerworks/data/library/techarticle/dm-0503melnyk/. The interesting part is Figure 5. Using the Command Editor to call an SQL procedure

星星的軌跡 2024-08-26 12:59:13

你想要的都是可能的。我自己已经做过很多次了。不幸的是,我现在不在办公室,所以这一定是我的想法。

  1. 启动 System i Access
  2. 转到您的 iSeries 图标并登录到存储过程所在的图标
  3. 转到数据库图标并连接到正确的图标(您有一个本地图标,可能还有一个或多个远程图标)
  4. 只有这样,您才会看到屏幕底部的“运行 SQL 脚本”选项
  5. 启动该选项,您将看到一个 SQL 编辑器(编辑器在顶部,查看器/消息在底部)
  6. 请记住,您已经连接到正确的 iSeries,但您的 JDBC 请求将获取您连接的用户配置文件的 *LIBL。因此,您必须知道存储过程的架构(iseries 库)
  7. 输入“call YOURSCHEMA.YOURSTOREDPROCEDURE(?,?);”并使用菜单或快捷方式运行该语句。请注意,根据您的 JDBC 设置(请参阅菜单),正确的语法可能是“/”而不是“.”。另请注意,您可以将第一个问号替换为值。

另请注意,

  • 在 iAccess 中,在每个架构下,您都会看到表、视图等的图标。还提供了存储过程的图标。你会在那里看到你的 SP。使用选项查看定义等。此信息包括有关参数的详细信息。
  • 如果您想在 iSeries 上检查该参数,请使用系统目录(这也可以从 SQL 编辑器完成)以及“select * from qsys2.sysprocedures where procedure_name”(抱歉,不确定现在该列的名称) = 'YOURSTOREDPROCEDURE';"

非常重要:我从未能够在 iSeries 本身上使用 SQL 编辑器 (STRSQL) 测试 SP。只有 iAccess SQL 编辑器可以正常工作。

What you want is possible. I have done it myself many times. Unfortunaly, I'm not at the office right now so it must be from the top of my head.

  1. Start System i Access
  2. Go to your iSeries icons and log on to the one where your stored procedure lives
  3. Go to the databases icons and connect to the correct one (you've one local and probably one or more remotes)
  4. Only then, you will see the option "run SQL script" at the bottom of your screen
  5. Start that option and you will see a SQL editor (editor on top, viewer/messages at the bottom)
  6. Remember that you are already connected to the correct iSeries but your JDBC request will get the *LIBL of the userprofile of your connection. Therefore you must know the schema (iseries library) of your stored procedure
  7. Enter "call YOURSCHEMA.YOURSTOREDPROCEDURE(?,?);" and use the menu or shortcut to run that statement. Notice that - depending on your JDBC settings (see menu) - the correct syntax may be "/" instead of ".". Also, notice that you can replace the first question mark with a value.

On an additional note,

  • In iAccess, under every schema you will see icons for the tables, views and so on. Also an icon for stored procedures is available. You will see your SP there. Use the options to see the definition and so. This information includes detailed information about the parameters
  • If you want to check that on your iSeries, use the system catalog (this can be done from the SQL editor too) with "select * from qsys2.sysprocedures where procedure_name (sorry, not sure about the name of this column right now) = 'YOURSTOREDPROCEDURE';"

VERY IMPORTANT: I was never able to test the SP with the SQL editor (STRSQL) on the iSeries itself. Only the iAccess SQL editor did work correctly.

绾颜 2024-08-26 12:59:13

你应该能够像这样运行你的SP:

DECLARE  
 usr_in  YOUR_TABLE.YOUR_COLM%TYPE; --Gets the correct type by looking at column type
 app_in  YOUR_TABLE.YOUR_OTHER_COLM%TYPE;

BEGIN
 usr_in:='some value';
 app_in:='another_value';

 YOUR_SP_NAME(usr_in, app_in);  
END;  

或者你可以使用EXECUTE,但它不能动态准备(不在Java中运行),我认为还有一些其他缺点。

EXECUTE myStoredProc(parm1, parm2, ?);

You should be able to run your SP like this:

DECLARE  
 usr_in  YOUR_TABLE.YOUR_COLM%TYPE; --Gets the correct type by looking at column type
 app_in  YOUR_TABLE.YOUR_OTHER_COLM%TYPE;

BEGIN
 usr_in:='some value';
 app_in:='another_value';

 YOUR_SP_NAME(usr_in, app_in);  
END;  

Or you can use EXECUTE, but it can't be dynamically prepared (not run in Java) and I think there's some other disadvantages.

EXECUTE myStoredProc(parm1, parm2, ?);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文