If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to assign value to a local variable in a UDF

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-09-10, 14:53
subra729 subra729 is offline
Registered User
 
Join Date: Jun 2010
Posts: 11
How to assign value to a local variable in a UDF

Hi all,

I am new to DB2 Programming.

I am required to write an UDF that takes a table name as input parameter and returns sequence number based on production or DR servername.

Questions:

How do I assign a value to a local variable within this UDF?

For Example:

Below is the query to find the server name. This query returns "DFORT001"
How do we store this value in a local variable (v_server) within UDF? What is the syntax?

SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1



SELECT v_server = CURRENT SERVER FROM SYSIBM.SYSDUMMY1; => This gives error
SELECT CURRENT SERVER INTO :v_server FROM SYSIBM.SYSDUMMY1; => This gives error
SELECT CURRENT SERVER INTO v_server FROM SYSIBM.SYSDUMMY1; => This gives error

OR CAN WE DO THIS?

SET v_server = (SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1);

What would be best approach?

Thanks,
Balu
Reply With Quote
  #2 (permalink)  
Old 06-09-10, 16:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The SET should work.

Andy
Reply With Quote
  #3 (permalink)  
Old 06-09-10, 16:27
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
You have to find the shortest way, if you are professional programmer:

SET :v_server = CURRENT SERVER;

SET :var_timestamp = CURRENT TIMESTAMP;

Lenny
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On