IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

PROBLEM WITH EXTERNAL UDF


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
perez_a

New User


Joined: 02 Feb 2006
Posts: 25
Location: Italy

PostPosted: Tue Jun 06, 2006 4:24 pm
Reply with quote

HELLO FRIENDS,
I'M CREATING AN EXTERNAL UDF WITH HOST LANGUAGE COBOL.
I NEED TO RETURN ONLY 1 PARAMETER TO THE UDF, HOW CAN I DO?
I'VE FOUND THIS EXAMPLE:

WORKING-STORAGE SECTION.
77 EXCHANGE_RATE PIC S9(5)V9(5) PACKED-DECIMAL.
LINKAGE SECTION.
* PARAMETERS *
77 ORIGINAL_CURRENCY PIC XXX.
77 TARGET_CURRENCY PIC XXX.
77 EXCHANGE_DATE FORMAT DATE.
PROCEDURE DIVISION USING
BY REFERENCE ORIGINAL_CURRENCY
BY REFERENCE TARGET_CURRENCY
BY REFERENCE EXCHANGE_DATE
RETURNING EXCHANGE_RATE.
BUT THE STATEMENT "RETURNING" IS NOT ALLOWED.
PLEASE HELP ME!!! icon_cry.gif
BIE BIE ALEX
Back to top
View user's profile Send private message
anamikak

New User


Joined: 10 May 2006
Posts: 64
Location: Singapore

PostPosted: Wed Jun 07, 2006 11:12 am
Reply with quote

Specifying "RETURN" for UDF , that too in Procedure division is not allowed in COBOL. Always, you have only PROCEDURE DIVISION using parm1,parm2(ie, list of parameters).

Also before you start of writing external UDF, you have to define the UDF to DB2. This is done by using
CREATE FUNCTION function name(parmetr declaration with data type)
Returns (data type1, data type2...)
Parameter style SQL
Language COBOL;

so you see , The return statement is coded while defining the UDF and not in the external function that is written in host language, in this case it is COBOL.


after this, when you actually write the UDF in Cobol, you can declare the input and out partmeters in the Linkage section at 01 levels and in the the procedure division you can say "USING " pameters defined in linkage section.

hope this helps you.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
Search our Forums:

Back to Top