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 > how to create temporary table in db2 v8 in os390

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-11, 23:31
maheshabo maheshabo is offline
Registered User
 
Join Date: Mar 2011
Posts: 2
how to create temporary table in db2 v8 in os390

sno acco_no amount

1 50001 5000
2 50002 4000
3 50001 2500
4 50002 3100
5 50002 3400
6 50001 1500

inwhich i want to take 50001's last 2 records one by one.

ie is result :

sno acco_no amount
6 50001 1500-----> i want to move this record to variable1
3 50001 2500-----> i want to move this record to variable2

pl help me anyone

Last edited by maheshabo; 03-13-11 at 03:41.
Reply With Quote
  #2 (permalink)  
Old 03-12-11, 06:29
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,195
What error messages did you got?
Please copy and paste all related messages.
Reply With Quote
  #3 (permalink)  
Old 03-12-11, 22:20
maheshabo maheshabo is offline
Registered User
 
Join Date: Mar 2011
Posts: 2
sno eno salary

1 e01 50000
2 e02 6000
3 e01 400
4 e02 8000
5 e01 5000
6 e02 7500

i want to selct e02's last 3 records(transaction) & i want to display those 3 records in map(cics).

im sure thst to select more than 1 record v ve to use cursor.but if i select those records how to move those values to map.

i used following query in spufi

1.select salary from Table_name order by sno desc where eno='e02'

eventho i cudn fetch.. pl help me
Reply With Quote
  #4 (permalink)  
Old 03-15-11, 18:19
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,195
Your true issue was not clear for me.

You asked similar, but different questons on your first and second posts.

Quote:
inwhich i want to take 50001's last 2 records one by one.
Quote:
i want to selct e02's last 3 records(transaction) & i want to display those 3 records in map(cics).
Anyhow, you can select last <n> rows by combination of "ORDER BY ... DESC" and "FETCH FIRST <n> ROWS ONLY", like ...
SELECT amount FROM ... WHERE acco_no = 50001 ORDER BY sno DESC FETCH FIRST 2 ROWS ONLY;
or
SELECT salary FROM ... WHERE eno = 'e02' ORDER BY sno DESC FETCH FIRST 3 ROWS ONLY;


If you used cursor, "FETCH FIRST <n> ROWS ONLY" might be unnecessary.
Quote:
sno acco_no amount
6 50001 1500-----> i want to move this record to variable1
3 50001 2500-----> i want to move this record to variable2
Declare cursor, OPEN cursor then repeat two FETCH statements, like...
FETCH ... INTO variable1;
FETCH ... INTO variable2;
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