473,469 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ISeries DB2 UDFs and Stored Procedure

We are running into a problem with a Communication Link failure when
calling an External Stored procedure written in ILE Cobol from an SQL
UDF. When calling the stored procedure by itself and not within the
UDF it runs fine, it's only when we excute the UDF that we get the
communication link failure. I have setup EXTERNAL ACTION on the the
UDF, the COBOL program doesn't execute any SQL statements.

Here is the function and how it is defined (Yes, I know that some of
this can be written as UDFs itself). The crash is occuring when
calling the ACVBYE external stored procedure:

CREATE FUNCTION UCRCDB.GETBYE (
IN_BYE numeric(6,0))
RETURNS Date
LANGUAGE SQL
SPECIFIC UCRCDB.GETBYE
DETERMINISTIC
READS SQL DATA
FENCED
EXTERNAL ACTION
DISALLOW PARALLEL
BEGIN
-- RETURN A BYE DATE FROM A NUMERIC(6,0)
-- CREATED BY DAN HOLT, FEB 2004, COMPUNAME
-- MODIFIED BY DAVID CARVER, COMPUWARE

-- Cobol Parms

DECLARE Func CHAR(1) DEFAULT '2'; -- 1 to 1

-- function 1
DECLARE bybMmddyySun CHAR(6) DEFAULT ' '; -- 2 to 7
DECLARE bybMmddyySat CHAR(6) DEFAULT ' '; -- 8 to 13

-- function 2
DECLARE byeMmddyySun CHAR(6) DEFAULT ' '; -- 14 to 19
DECLARE byeMmddyySat CHAR(6) DEFAULT ' '; -- 20 to 25

-- function 3
DECLARE bybWwyy CHAR(4) DEFAULT ' '; -- 26 to 29

-- function 4
DECLARE byeWwyy CHAR(4) DEFAULT ' '; -- 30 to 33

-- function5
DECLARE gregorian CHAR(6) DEFAULT ' '; -- 34 to 39

-- function6
DECLARE julianNnnyy CHAR(5) DEFAULT ' '; -- 40 to 44

DECLARE basePeriod CHAR(20) DEFAULT '00000000000000000000'; -- 45 to
64

DECLARE altBasePer CHAR(20) DEFAULT '00000000000000000000'; -- 65 to
84

DECLARE bdateError CHAR(1) DEFAULT ' '; -- 85 to 85

DECLARE returnDate CHAR(10) DEFAULT '0000000000'; -- 86 to 95

DECLARE parm CHAR(95) DEFAULT ' '; -- 1 to 95

-- misc

DECLARE strBYE CHARACTER(10) DEFAULT ' ';
DECLARE strBYE8 CHARACTER(8) DEFAULT ' ';
DECLARE byeWwyyn NUMERIC(4,0) DEFAULT 0;
DECLARE chgDate CHARACTER(6) DEFAULT ' ';
DECLARE CL_byedate DATE;

Declare cnvDate Decimal(8,0);

SET byeWwyy = SUBSTR(cast(digits(IN_BYE) As Char(6)),1,2) ||
SUBSTR(cast(digits(IN_BYE) As Char(6)),5,2) ;

SET func = '4';

SET PARM = func || bybmmddyysun || bybmmddyysat || byemmddyysun ||
byemmddyysat || bybwwyy || byewwyy || gregorian || juliannnnyy ||
baseperiod || altbaseper || bdateerror || returndate;

CALL UcrcDb.callACVBYE ( PARM );

Set chgDate = SUBSTRING(PARM FROM 24 FOR 2) || SUBSTRING(PARM FROM 20
FOR 4);

--CALL UcrcDb.CcYyMmDd (chgDate);
-- Begin CcYyMmDd (chgDate) code
Set CnvDate = cast(chgDate as Decimal);

If CnvDate > 500101 Then

Set CnvDate = CnvDate + 19000000;

Else

Set CnvDate = CnvDate + 20000000;

End If;

Set strBYE8 = cast(CnvDate as VarChar(8));

Set strBYE = cast(substr(strBYE8, 1,4) || '-' || substr(strBYE8, 5, 2)
|| '-' || substr(strBYE8, 7,2) As Date);

Set CL_byeDate = cast(strBYE as Date);
-- End CcYyMmDd (chgDate) code

RETURN CL_byedate ;

END ;
Nov 12 '05 #1
3 6012
UDF invocations have a default timeout of 30 or 60 seconds. Does the Stored
Procedure run for a long time possibly?

--
Kent Milligan, DB2 & BI team
PartnerWorld for Developers, iSeries
km***@us.eye-bee-m.com (spam trick) GO HAWKEYES!!
www.iseries.ibm.com/db2

(opinions stated are not necessarily those of my employer)
Nov 12 '05 #2
I'd also suggest changing the UDF to be NOT FENCED - it has the potential for
better performance.

--
Kent Milligan, DB2 & BI team
PartnerWorld for Developers, iSeries
km***@us.eye-bee-m.com (spam trick) GO HAWKEYES!!
www.iseries.ibm.com/db2

(opinions stated are not necessarily those of my employer)
Nov 12 '05 #3
Kent Milligan <km***@us.eye-bee-m.com> wrote in message news:<40***************@us.eye-bee-m.com>...
I'd also suggest changing the UDF to be NOT FENCED - it has the potential for
better performance.


Kent, thanks for the suggestions. I think I tried it both Fenced and
Not Fenced and received the same result. Anyway, I'll mess around
with it again and see what happens.

Thanks.

Dave
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Mayo | last post by:
There is something very strange going on here. Tested with ADO 2.7 and MSDE/2000. At first, things look quite sensible. You have a simple SQL query, let's say select * from mytab where col1 =...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
7
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals...
1
by: E.T. Grey | last post by:
Hi All, Despite spending the past six to seven hours perusing the docs on the mySQl site, I still have questions unanswered, and have been unable to get any help. I am familiar with Sybase, some...
17
by: Gregor Kovač | last post by:
Hi! I have a UDFs defined in a C source file. I also have a Microsoft Visual Studio 2005. Can someone please tell me how to compile this C source with Microsoft's compiler into a DLL? I'd...
3
by: gherrell | last post by:
I know there is a lot of information already out there on this topic, but given the following scenario... ...
0
by: Johan Neidenmark | last post by:
When i try to run this SQL statements in iSeries Access for windows (against my customers db2) i get: SQL State: 42904 Vendor Code: -7032 Message: SQL procedure, function, or trigger...
0
by: sqldba20 | last post by:
Folks: I would like to get schema (with drop statements) for Stored procedures, Views and User Defined functions. I understand it can be done using SQL Enterprise Manager or Management Studio but...
2
by: jmuehe | last post by:
Hello, What are the optimal settings to use in a CREATE PROCEDURE – when creating a SQL procedure on the iSeries? To read data? To update? Here is a pretty standard one of ours. I know the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.