如何使用rexx获得一个数组作为输出

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

How to get an array as output using rexx

问题

我正在测试 Db2 for z/OS 的一些功能,目前在尝试通过 REXX 调用存储过程时遇到了问题。

以下是我需要在存储过程中返回的数据类型的代码:

CREATE TYPE *******.ARRAY_TESTE AS VARCHAR(186) ARRAY[200];

这是我用来创建存储过程的DDL:

CREATE PROCEDURE *******.TESTE_EMP2           
  (OUT EDLEVELARR MYVARRTYPE,                 
   OUT LASTNAMEARR MYVARRTYPE)                
  VERSION MEDIAN_V1                           
  LANGUAGE SQL                                
  NOT DETERMINISTIC                           
  READS SQL DATA                              
  CALLED ON NULL INPUT                        
  DYNAMIC RESULT SETS 1                       
  DISABLE DEBUG MODE                          
  PARAMETER CCSID EBCDIC                      
  QUALIFIER *******                           
  PACKAGE OWNER ******                        
  ASUTIME NO LIMIT                            
  COMMIT ON RETURN NO                         
  INHERIT SPECIAL REGISTERS                   
  NODEFER PREPARE                              
  CURRENT DATA NO                             
  DEGREE 1                                    
  DYNAMICRULES RUN                            
  WITHOUT EXPLAIN                             
  WITHOUT IMMEDIATE WRITE                     
  ISOLATION LEVEL CS                          
  WITHOUT KEEP DYNAMIC                        
  OPTHINT ''                                  
  RELEASE AT COMMIT                           
  REOPT NONE                                   
  VALIDATE RUN                                
  ROUNDING DEC_ROUND_HALF_EVEN                
  DECIMAL(31)                                 
  BUSINESS_TIME SENSITIVE NO                  
  SYSTEM_TIME SENSITIVE NO                    
  ARCHIVE SENSITIVE NO                        
  BEGIN                                        
    SELECT  ARRAY_AGG(VARCHAR(EDLEVEL)), ARRAY_AGG(LASTNAME)    
    INTO EDLEVELARR, LASTNAMEARR                                
    FROM DSN81110.EMP ;                                         
  END

这是我用来调用存储过程的REXX代码:

LOCAL_DB2 = ****                                                  
ADDRESS DSNREXX                                                   
RC = 'SUBCOM DSNREXX'                                             
OUTTRAP TESTE_DATA.                                               
TESTE_DATA2.                                                      
IF RC <> 0 THEN DO                                                
   S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')                     
END                                                               

"CONNECT " LOCAL_DB2                                              
IF SQLCODE <> +0 THEN DO                                          
   MY_ERROR = 'ERROR CONNECTING TO DB2 ' LOCAL_DB2                
END                                                               
EXECSQL "CALL *******.TESTE_EMP2(:TESTE_DATA.,:TESTE_DATA2.)"     
IF (SQLCODE<>0) THEN                                              
CALL SQL_ERROR                                                    
                                                                  
ADDRESS DSNREXX                                             
  "DISCONNECT"                                            
   S_RC = RXSUBCOM('DELETE','DSNREXX','DSNREXX')          
 EXIT

目前我遇到了以下SQLCODE:

-301 输入变量或参数编号 position-number 的值无法按指定的方式使用,因为其数据类型不正确
英文:

I'm testing some functions of Db2 for z/OS, and right now I'm having troubles when I try to call a Stored Procedure through REXX.

Below is the code to create the Data Type that I need to return in my Stored Procedure

CREATE TYPE *******.ARRAY_TESTE AS VARCHAR(186) ARRAY[200];

This is the DDL that I used to create the Stored Procedure

CREATE PROCEDURE *******.TESTE_EMP2           
  (OUT EDLEVELARR MYVARRTYPE,                 
   OUT LASTNAMEARR MYVARRTYPE)                
  VERSION MEDIAN_V1                           
  LANGUAGE SQL                                
  NOT DETERMINISTIC                           
  READS SQL DATA                              
  CALLED ON NULL INPUT                        
  DYNAMIC RESULT SETS 1                       
  DISABLE DEBUG MODE                          
  PARAMETER CCSID EBCDIC                      
  QUALIFIER *******                           
  PACKAGE OWNER ******                       
  ASUTIME NO LIMIT                            
  COMMIT ON RETURN NO                         
  INHERIT SPECIAL REGISTERS                   
  NODEFER PREPARE                             
  CURRENT DATA NO                             
  DEGREE 1                                    
  DYNAMICRULES RUN                            
  WITHOUT EXPLAIN                             
  WITHOUT IMMEDIATE WRITE                     
  ISOLATION LEVEL CS                          
  WITHOUT KEEP DYNAMIC                        
  OPTHINT &#39;&#39;                                  
  RELEASE AT COMMIT                           
  REOPT NONE                                                    
  VALIDATE RUN                                                  
  ROUNDING DEC_ROUND_HALF_EVEN                                  
  DECIMAL(31)                                                   
  BUSINESS_TIME SENSITIVE NO                                    
  SYSTEM_TIME SENSITIVE NO                                      
  ARCHIVE SENSITIVE NO                                          
  BEGIN                                                         
    SELECT  ARRAY_AGG(VARCHAR(EDLEVEL)), ARRAY_AGG(LASTNAME)    
    INTO EDLEVELARR, LASTNAMEARR                                
    FROM DSN81110.EMP ;                                         
  END `         

And this is the REXX that I used to call the stored Procedure

LOCAL_DB2 = ****                                                  
ADDRESS DSNREXX                                                   
RC = &#39;SUBCOM DSNREXX&#39;                                             
OUTTRAP TESTE_DATA.                                               
TESTE_DATA2.                                                      
IF RC &lt;&gt; 0 THEN DO                                                
   S_RC = RXSUBCOM(&#39;ADD&#39;,&#39;DSNREXX&#39;,&#39;DSNREXX&#39;)                     
END                                                               
                                                                  
&quot;CONNECT &quot; LOCAL_DB2                                              
IF SQLCODE &lt;&gt; +0 THEN DO                                          
   MY_ERROR = &#39;ERROR CONNECTING TO DB2 &#39; LOCAL_DB2                
END                                                               
EXECSQL &quot;CALL *******.TESTE_EMP2(:TESTE_DATA.,:TESTE_DATA2.)&quot;     
IF (SQLCODE&lt;&gt;0) THEN                                              
CALL SQL_ERROR                                                    
                                                                  
       ADDRESS DSNREXX                                            
          &quot;DISCONNECT&quot;                                            
           S_RC = RXSUBCOM(&#39;DELETE&#39;,&#39;DSNREXX&#39;,&#39;DSNREXX&#39;)          
 EXIT                                                             

Right now I'm having the SQLCODE

-301 THE VALUE OF INPUT VARIABLE OR ARGUMENT NUMBER position-number CANNOT BE USED AS SPECIFIED BECAUSE OF ITS DATA TYPE 

答案1

得分: 1

这条消息是不言自明的。用户定义的数组数据类型目前不是REXX调用Db2存储过程所支持的数据类型之一。

请参考此文档页面以查看REXX支持的数据类型及其对应的SQL数据类型。

英文:

The message is self explanatory. The user-defined-array-datatype is not one of the supported data-types for REXX calling Db2 stored procedures, at current versions .

Refer to this documentation page to see the types that REXX supports and the corresponding SQL data type,

huangapple
  • 本文由 发表于 2020年1月7日 01:14:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616284.html
匿名

发表评论

匿名网友

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

确定