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

db2 user defined function in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Mon Jul 20, 2009 5:02 pm
Reply with quote

Hi ,

I am using the below function in my program.

EXEC SQL
VALUES :WS-TIMESTAMP-OUT = FUNCTION JTIMEZONECONVERTER
(:WS-TIMESTAMP-IN ,
:WS-ORG-TIME-ZONE ,
:WS-TARGET-TIME-ZONE
)
END-EXEC

i am getting the error as

** External Compiler Module message
** DB0100 SQL0104N An unexpected token ":WS-TIMESTAMP-OUT =
** FUNCTION" was found following "VALUES ". Expected tokens may
** include: "<space>". SQLSTATE=42601


Thanks in advance
Naga
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jul 20, 2009 5:24 pm
Reply with quote

try: VALUES <function(parms)> INTO :Host-VAR
Back to top
View user's profile Send private message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Tue Jul 21, 2009 12:40 pm
Reply with quote

Than q Dick for ur reply.
But i am getting the same error with yhe above syntax. Can we use SELECT with RETURN..




Thanks in advance
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 21, 2009 5:23 pm
Reply with quote

Quote:
EXEC SQL
VALUES :WS-TIMESTAMP-OUT = FUNCTION JTIMEZONECONVERTER
(:WS-TIMESTAMP-IN ,
:WS-ORG-TIME-ZONE ,
:WS-TARGET-TIME-ZONE
)
END-EXEC


If JTIMEZONECONVERTER is a DB2 function try this


Code:

EXEC SQL
SET :WS-TIMESTAMP-OUT = JTIMEZONECONVERTER(:WS-TIMESTAMP-IN, :WS-ORG-TIME-ZONE, :WS-TARGET-TIME-ZONE)
END-EXEC
Back to top
View user's profile Send private message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Tue Jul 21, 2009 5:42 pm
Reply with quote

Hi Craq.

I tried with this. But didnt work.

Actually we are working with cobol on AIX environment. How can we know that whether this particular db2 function is created correctly or not.

Can anybody provide sql to verify whether db2 function is created or not.



Thanks in advance
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jul 21, 2009 5:54 pm
Reply with quote

Naga Rajender.K wrote:
EXEC SQL
VALUES :WS-TIMESTAMP-OUT = FUNCTION JTIMEZONECONVERTER
(:WS-TIMESTAMP-IN ,
:WS-ORG-TIME-ZONE ,
:WS-TARGET-TIME-ZONE
)
END-EXEC

What is that? is it part of a SELECT, an UPDATE or a SET statement?
You've removed too many details...

Also, what do you mean by this:
Naga Rajender.K wrote:
Can we use SELECT with RETURN
Back to top
View user's profile Send private message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Tue Jul 21, 2009 6:05 pm
Reply with quote

can any one provide the sql query to verify whether the DB2 External Function is created or not.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 21, 2009 6:35 pm
Reply with quote

E.13 Retrieving catalog information about user-defined functions and stored procedures
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 21, 2009 7:06 pm
Reply with quote

You could try showing us the definition of the function!
Back to top
View user's profile Send private message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Tue Jul 21, 2009 8:03 pm
Reply with quote

Actually I have the create query as follows.Im trying to derive the values from the below DDL.

CREATE FUNCTION TIMEZONECON(UTCtimestamp varchar(50), originaltimezone varchar(5), targetimezone varchar(5))
RETURNS varchar(100)
EXTERNAL NAME 'TIMEZONECON.TZCON’
LANGUAGE java
PARAMETER STYLE JAVA
DETERMINISTIC
FENCED
NOT NULL CALL
NO SQL
NO EXTERNAL ACTION
NO SCRATCHPAD
ALLOW PARALLEL;

Thanks
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 21, 2009 8:08 pm
Reply with quote

What are the definitions for WS-TIMESTAMP-IN, WS-ORG-TIME-ZONE, WS-TARGET-TIME-ZONE, and WS-TIMESTAMP-OUT?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Tue Jul 21, 2009 8:09 pm
Reply with quote

just take a decision.. You posted in the cobol forum, but You say..

Quote:

Actually we are working with cobol on AIX environment.
...
Actually I have the create query as follows.Im trying to derive the values from the below DDL.
...
LANGUAGE java
PARAMETER STYLE JAVA
...


what is that You want ?? icon_evil.gif

anywhere ( MF, AIX, UNIX, LINUX, WINDOZE ) any cobol thingy must be compiled,
why not speak to Your support
and read the manual for Your environment
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts System add a USER parm when job submi... TSO/ISPF 4
No new posts Compile Sp Cobol base COBOL Programming 1
Search our Forums:

Back to Top