Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 procedure 1

Status
Not open for further replies.

rashi30

Technical User
Apr 6, 2005
8
US
What I need to do is
1. run a query against a table, x varies
'select * from table1 where emp=x'
2. save the data as a temp table-table2
(i use 'save data as table2' command after running the above query in QMF)
3. update emp=y (in temp table & y varies)
(i use - 'update table2 set emp=y')
4. insert data from new table2 into table1
(i use - 'select * from table2/ insert into table1)

i use so many steps & usually do it in QMF manually.

The question is can i perform the same task using procs or other utility in DB2. Writing a db2 pgm is not an option.

Please suggest!!
 
Could you not do something like:

INSERT INTO TABLE1
(SELECT FIELD1, FIELD2, 'Y', FIELD4
FROM TABLE1
WHERE EMP = 'X')

In this example the field EMP is the third field. I think that you may be restrained by keys etc. but it's worth a try

Marc
 
Hey MarcLodge,
Excellent. Thanx. Thats great & it works for me. I can use that & that will avoid a lot of manual process and chance of mistakes. Thanx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top