Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    190

    Unanswered: global tables and variables

    Could someone please explain why one of the insert statements below works and the other one using variables does not? I'm using db2 udb 8.2.

    Thanks

    DECLARE GLOBAL TEMPORARY TABLE session.outputtbl
    (TradeId CHAR(20)
    , Quantity DEC(28,3)
    , Mark DEC(28,3)
    , MarketValue DEC(28,3)
    )
    ON COMMIT PRESERVE ROWS
    ;

    DECLARE trd_ticket CHAR(20) DEFAULT 'abc';
    DECLARE trd_pos DEC(28,3) DEFAULT 0;
    DECLARE trd_mark DEC(28,3) DEFAULT 0;
    DECLARE trd_amount DEC(28,3) DEFAULT 0;


    INSERT INTO session.outputtbl VALUES('001', 0, 0, 0); --WORKS
    INSERT INTO session.outputtbl VALUES(trd_ticket, trd_pos, trd_mark, trd_amount); -- DOES NOT WORK

    commit;
    SELECT * FROM session.outputtbl;

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    The statement 'does not work' is ambiguous ..

    What does that mean, do you get an error message or does the statement execute successfully but the row is not inserted ?

    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Apr 2004
    Posts
    190

    global tables

    The insert statement using the variables does not give an error message, but the row is not inserted. Run the code and you will see what I mean.

Posting Permissions

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