DB2 Z/os 本机 SQL 过程 — 已更新

发布于 2024-09-30 07:48:05 字数 1772 浏览 5 评论 0原文

我正在实现一个 DB2 Native SQL 过程。这是我们第一次在这家店尝试这种做法。我附上了下面的代码。该例程的作用是按时间跟踪添加到表中的新记录的数量。每当它触发时,它要么更新监控表中的记录,要么在表不存在时插入一条记录。

本机过程是 Z/os db2 版本 9 中的新增功能。有关

Z/os db2 v9 过程的红皮书内容如下: 图 15-15 描述了调用本机 SQL 过程时涉及的 DB2 组件 来自远程应用程序、DB2 连接程序或联合地址空间 分别。如图所示,SQL 语句不再在外部 WLM 中执行 地址空间而是本机在数据库系统服务地址空间中。为了执行, 程序包已加载到 EDM 池中。”

但是,如果我从代码中删除“WLM ENVIRONMENT FOR DEBUG MODE DSNDSPENV”行,则会收到一条错误消息,指出“必须指定 WLM 环境”。

有谁知道原因此代码可能存在 WLM 依赖性吗?我是否需要覆盖 WLM_ENVIRONMENT 默认值?如果是,我该怎么做


? -----------------------------------


看来,如果您添加选项“DISABLE DEBUG MODE”,您将不需要为 DEBUG 指定 WLM。

禁用调试模式有什么缺点?将过程保留在“允许调试模式”有什么缺点吗?


--#SET TERMINATOR !                                            
 CREATE PROCEDURE $172.VQT_QUOTE_INFO_COUNT_NEW_QUOTE(
                      IN RATING_STATE CHAR(2),
                      IN INSERT_TIMESTAMP TIMESTAMP)
 LANGUAGE SQL
 ALLOW DEBUG MODE
 WLM ENVIRONMENT FOR DEBUG MODE DSNDSPENV                 
 BEGIN
   DECLARE NO_RECORD_UPDATED INT DEFAULT 0;
   DECLARE CONTINUE HANDLER FOR SQLSTATE '02000'
      SET NO_RECORD_UPDATED = 1;
  UPDATE  $172.VKT_MONITORING_COUNTS
     SET MC_QUOTE_CNT = MC_QUOTE_CNT + 1
  WHERE MC_STATE_ABBREV = RATING_STATE AND
        MC_SAMPLE_DATE = DATE(INSERT_TIMESTAMP) AND
        MC_SAMPLE_HOUR = HOUR(INSERT_TIMESTAMP);
  IF NO_RECORD_UPDATED = 1    THEN
  INSERT INTO $172.VKT_MONITORING_COUNTS (
              MC_STATE_ABBREV, MC_SAMPLE_DATE, MC_SAMPLE_HOUR,
              MC_QUOTE_CNT, MC_NEW_POLICY_CNT)            
         VALUES.                                                
              (RATING_STATE, DATE(INSERT_TIMESTAMP),
               HOUR(INSERT_TIMESTAMP),  1, 0);               
 END IF;
 END.#
--#SET TERMINATOR ;               

I'm implementing a DB2 Native SQL procedure. It's the first we've tried this in this shop. I've attached the code below. What this routine does is keep track of the number of new records added to a table by time. Whenever it fires, it either updates a record in the monitoring table or inserts a record if the table doesn't exist.

Native procedures are new to Z/os db2 version 9.

The redbook on procedures for Z/os db2 v9 reads:
"Figure 15-15 depicts the DB2 components involved when a native SQL procedure is called
either from a remote application, a DB2 attached program, or an allied address space
respectively. As illustrated, the SQL statements are no longer executed in an external WLM
address space but natively in the database system services address space. For execution,
the procedure packages are loaded into the EDM pool."

Yet, If I remove the line "WLM ENVIRONMENT FOR DEBUG MODE DSNDSPENV" from the code, I get an error saying the "WLM Environment must be specified".

Does anyone know a reason that WLM dependency might exist with this code? Do I need to override a WLM_ENVIRONMENT default? And if so, how would I do that?


New Information--------------------------------------------------------


It appears that if you add the option "DISABLE DEBUG MODE" you are not required to specify a WLM for DEBUG.

What's the downside of disabling debug mode? Is there any downside to leaving a procedure in "ALLOW DEBUG MODE"? Is there overhead to using a procedure in which debug can be allowed?


--#SET TERMINATOR !                                            
 CREATE PROCEDURE $172.VQT_QUOTE_INFO_COUNT_NEW_QUOTE(
                      IN RATING_STATE CHAR(2),
                      IN INSERT_TIMESTAMP TIMESTAMP)
 LANGUAGE SQL
 ALLOW DEBUG MODE
 WLM ENVIRONMENT FOR DEBUG MODE DSNDSPENV                 
 BEGIN
   DECLARE NO_RECORD_UPDATED INT DEFAULT 0;
   DECLARE CONTINUE HANDLER FOR SQLSTATE '02000'
      SET NO_RECORD_UPDATED = 1;
  UPDATE  $172.VKT_MONITORING_COUNTS
     SET MC_QUOTE_CNT = MC_QUOTE_CNT + 1
  WHERE MC_STATE_ABBREV = RATING_STATE AND
        MC_SAMPLE_DATE = DATE(INSERT_TIMESTAMP) AND
        MC_SAMPLE_HOUR = HOUR(INSERT_TIMESTAMP);
  IF NO_RECORD_UPDATED = 1    THEN
  INSERT INTO $172.VKT_MONITORING_COUNTS (
              MC_STATE_ABBREV, MC_SAMPLE_DATE, MC_SAMPLE_HOUR,
              MC_QUOTE_CNT, MC_NEW_POLICY_CNT)            
         VALUES.                                                
              (RATING_STATE, DATE(INSERT_TIMESTAMP),
               HOUR(INSERT_TIMESTAMP),  1, 0);               
 END IF;
 END.#
--#SET TERMINATOR ;               

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

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

发布评论

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

评论(1

温柔一刀 2024-10-07 07:48:05

WLM 代表工作负载管理器。

工作负载管理器(它是基本 z/OS 的一部分)负责分配内存和其他资源并运行脚本。

每个 WLM 环境将以不同的优先级运行脚本,并具有自己的最长运行时间设置、最大 CPU 消耗以及自己的一组有关可以访问哪些资源的规则。

WLM stands for Work Load Manager.

The work load manager (which is part of the base z/OS) is responsable for allocating memory and other resources and running your script.

Each WLM environment will run scripts at different priorities and have its own settings for maximum time to run, maximum cpu consumption and its own set of rules about which resources can be accessed.

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