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 > global tables and variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-01-06, 15:24
redwolf redwolf is offline
Registered User
 
Join Date: Apr 2004
Posts: 179
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;
Reply With Quote
  #2 (permalink)  
Old 06-01-06, 20:05
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
  #3 (permalink)  
Old 06-02-06, 07:25
redwolf redwolf is offline
Registered User
 
Join Date: Apr 2004
Posts: 179
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.
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