Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Unanswered: Can function return multiple values

    Can function return multiple values.

    for example

    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

  2. #2
    Join Date
    Jan 2007
    Jena, Germany
    Have a look at table functions.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts