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 > UDFs, Stored Procedures, and External Stored Procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-09, 09:03
db2farmer db2farmer is offline
Registered User
 
Join Date: May 2009
Posts: 25
UDFs, Stored Procedures, and External Stored Procedures

The DB2 manual (version 9.5 for LUW) doesn't mention Stored Procedures and External Stored Procedures -- at least not in the index -- and only mentions UDFs once with respect to working with views. The DB2 9 Fundamentals Certification Guide talks about all three but fails to sufficiently differentiate between them. For instance, the definition for a UDF of the type Scalar or Table is nearly identical to the definition of an External Stored Procedure. Googling the keywords hasn't turned up much.

Can someone clear this up for me? What is/are the difference/s between the different routines?
Reply With Quote
  #2 (permalink)  
Old 05-19-09, 09:33
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
chk tutorials for exam 733 and 735
__________________
Rahul Singh
Certified DB2 9 DBA / Application Developer
Reply With Quote
  #3 (permalink)  
Old 05-19-09, 10:47
db2farmer db2farmer is offline
Registered User
 
Join Date: May 2009
Posts: 25
Quote:
chk tutorials for exam 733 and 735
Many thanks.

Last edited by db2farmer; 05-19-09 at 11:17.
Reply With Quote
  #4 (permalink)  
Old 05-19-09, 18:21
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by db2farmer
the definition for a UDF of the type Scalar or Table is nearly identical to the definition of an External Stored Procedure.
They differ in the way they can be used (called).
A scalar UDF can be called as any scalar built-in function, i.e., inside SQL statements where an expression is expected.
A scalar UDF takes any number of arguments of any type, but must return a single scalar.
A stored procedure can only be called by using the CALL statement.
It does not return a value -- instead, some of its arguments (again scalars of "any" datatype) will be declared as "output" and will be able to return data to the caller.

There is more to it than this, but consider this "the basics".
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/

Last edited by Peter.Vanroose; 05-20-09 at 16:54.
Reply With Quote
  #5 (permalink)  
Old 05-20-09, 09:21
db2farmer db2farmer is offline
Registered User
 
Join Date: May 2009
Posts: 25
Thanks. The references I have all seem to contradict each other on this point. One says a UDF cannot contain SQL, another says they can. One says a UDF cannot return a single row, another says they can. And Googling hasn't cleared things up either.

Last edited by db2farmer; 05-20-09 at 09:30.
Reply With Quote
  #6 (permalink)  
Old 05-20-09, 13:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
A yew years ago, UDFs couldn't contain SQL statements, that's true. But that has changed long ago.

Scalar UDFs can only return a scalar value - no row comprised of multiple columns. (Since a scalar value is just a special case of a table with a single row and a single column, I wouldn't say that those functions don't return rows.)

A table function returns a whole table.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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