Re: Problem with SQL UDF
- From: CRPence <crpence@xxxxxxxxxxxx>
- Date: Wed, 30 Jan 2008 09:03:43 -0600
I have not had a chance to debug this further [somehow I managed to get my process in a deadlock; which I did not yet start to debug], but I can confirm the same results on v5r3 & v5r4. I had assigned RLIB and RVAR to have non-blank defaults, for a quick review before further debug. The RVAR is reset to blanks sometime after the call to the API and before the source statement immediately following; not back to it yet.
Thus for /Why?/, it would seem reasonable to just report this as a defect.
FWiW to confirm visually that the CALL transpires to QUSROBJD for the case of /returns blanks/ versus /gives error/, can be achieved easily with debug using ADDBKP '/1' or review of trace output.
Regards, Chuck
--
All comments provided "as is" with no warranties of any kind whatsoever and may not represent positions, strategies, nor views of my employer
Dr.UgoGagliardelli wrote:
I created this simple UDF that should return the library of a file in library list:.
CREATE FUNCTION GETLIB
(RFIL VARCHAR(10)) RETURNS VARCHAR(10)
LANGUAGE SQL NOT DETERMINISTIC
SET OPTION DBGVIEW = *SOURCE, DYNUSRPRF = *OWNER, USRPRF= *OWNER,
COMMIT=*NONE, EVENTF=*NO
BEGIN
DECLARE RLIB VARCHAR(10);
DECLARE RVAR CHAR(48) DEFAULT ' ';
DECLARE RLEN INT DEFAULT 48;
DECLARE RFMT CHAR(8) DEFAULT 'OBJD0100';
DECLARE ROBJ CHAR(20) DEFAULT ' ';
DECLARE RTYP CHAR(10) DEFAULT '*FILE ';
SET ROBJ = CHAR(RFIL, 10) CONCAT CHAR('*LIBL', 10);
CALL QUSROBJD (RVAR, RLEN, RFMT, ROBJ, RTYP);
SET RLIB = TRIM(SUBSTR(RVAR, 39, 10));
RETURN RLIB;
END;
The problem is that RVAR, after the call is always empty disregarding the file was found or not. If the file is not found the function ends in error, due to the missing API error structure (with a CPF9812 in the joblog as expected), running under debug I can see in the joblog that QUSROBJD was called successfully, if I change the proc name with something that doesn't match a program or service-program name, I can see in the joblog that the program was not found in *LIBL (SQL0204), so I'm pretty sure that the call takes place.
In SQL reference, I found that, if not explicitly declared in a declare procedure statement, all arguments inside a variable will be considered of type INOUT, so I assumed that should run as is, but it's not.
Why?
- Follow-Ups:
- Re: Problem with SQL UDF
- From: Dr.UgoGagliardelli
- Re: Problem with SQL UDF
- References:
- Problem with SQL UDF
- From: Dr.UgoGagliardelli
- Problem with SQL UDF
- Prev by Date: Re: API QwpzHostPrintTransform failed : CPF3CF2 hptopt = 30
- Next by Date: Re: API QwpzHostPrintTransform failed : CPF3CF2 hptopt = 30
- Previous by thread: Re: Problem with SQL UDF
- Next by thread: Re: Problem with SQL UDF
- Index(es):
Relevant Pages
|