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 > Can function return multiple values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-09, 14:57
phil72 phil72 is offline
Registered User
 
Join Date: Nov 2008
Posts: 41
Can function return multiple values

Can function return multiple values.

for example

mytable
Col1 (char) col2 (numeric) col3 Date

In my fuction I am casting all 3 columns to character seperated by delimeter and then spliting again. Is there better way

Also i have query with a subquery and i want two columns from subquery

what is best way
for example

Select col1, (select sum(Qty1) from table2) as col2, (select sum(Qty2) from table2) as col3 from table1

Here subquery runs twices

i cant write query as
Select col1, (select sum(Qty1), sum(Qty2) from table2) as col1, col2 from table1

i can write query as

Select col1, (select char(sum(Qty1)) || '--' || char(sum(Qty2)) from table2) as coltmp from table1

Then break the coltmp using delimeter '--'
Please write which is better option

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 02-25-09, 17:48
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have a look at table functions.
__________________
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