Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    4

    Unanswered: Selecting multiple columns into variables (in trigger)

    Hey,

    I'm starting with DB2 triggers and I'm wondering how I can make a select with multiple columns into variables. Here is what I've been doing to select one column:

    Code:
    declare myVar smallint;
    set myVar = (select colA from myTable where ....);
    Now what if I want to select the columns colA and colB from myTable into two variables? Do I have to make two selects, or is there a better way?

    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You can use this:
    Code:
    SET ( myVar1, myVar2 ) = ( SELECT colA, colB FROM myTable WHERE ... );
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Aug 2008
    Posts
    4
    Perfect, thanks!

Posting Permissions

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