Running SQL PL on DB2 z/OS directly without stored procedures.

huangapple go评论52阅读模式
英文:

Running SQL PL on DB2 z/OS directly without stored procedures

问题

我正在尝试在IBM Cloud Wazi /虚拟服务器实例(s390x)上使用IBM DB2 on z/OS(使用DBeaver和IBM Data Studio)运行一些查询。我想直接从SQL脚本中执行一个简单的SQL PL脚本,就像我在我的DB2 LUW和其他数据库上所做的那样。

在直接执行它后,会返回各种错误。如下所示:

[Code: -104,SQL State: 42601] 非法符号"SQLCODE"。一些可能合法的符号是:SECTION。 SQLCODE=-104,SQLSTATE=42601,DRIVER=4.28.11]

我是否正确地认为我不能直接从SQL窗口/客户端工具向数据库发送SQL PL代码?我已经通过创建存储过程并使用CALL功能使其工作,但我宁愿不创建各种存储过程。

或者我可以配置数据库以便我可以直接从SQL脚本中使用SQL PL吗?

英文:

I'm experimenting with a IBM DB2 on z/OS (using the IBM Cloud Wazi / Virtual server instances (s390x) and running some queries directly using DBeaver and IBM Data Studio.

I want to execute a simple SQL PL script directly from a SQL Script, like I do on my DB2 LUW and other database.

BEGIN
DECLARE SQLCODE INTEGER;

SELECT COUNT(*) INTO SQLCODE FROM SYSIBM.SYSTABLES WHERE TYPE = 'T' AND TRIM(CREATOR) = 'IBMUSER' AND TRIM(NAME) = 'BOOKS';

IF SQLCODE = 1 THEN
    EXECUTE IMMEDIATE 'DROP TABLE IBMUSER.BOOKS';
END IF;
END

After executing it directly returns all kinds of error. Like the following;

[Code: -104, SQL State: 42601]  ILLEGAL SYMBOL "SQLCODE". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: SECTION. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11]

Am I correct that I cannot directly sent SQL PL code from a sql window/client tool to the database? I've got it working by creating a stored procedure and use the CALL functionality, but I would prefer not to create all kinds of stored procedures?

Or can I configure the database in such way that I can use SQL PL directly from sql scripts.

答案1

得分: 0

这在DB2 z/OS上不可能直接从SQL语句中实现。SQL PL只能作为存储过程的一部分执行。

您可以使用SQL从SQL中执行存储过程,使用CALL

英文:

This is not possible on DB2 z/OS directly from a SQL statement. SQL PL can only be executed as part of a STORED procedure.

You can execute the stored procedure from SQL using CALL <PROCEDURENAME>

huangapple
  • 本文由 发表于 2023年4月4日 16:57:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927389.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定