Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

need to replase the value in table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
george16

New User


Joined: 08 Jul 2010
Posts: 11
Location: chennai

PostPosted: Fri Jul 30, 2010 1:49 pm    Post subject: need to replase the value in table
Reply with quote

I have one table A. Table A having column A1 and A2.

Column A1 values example below...

A1
-----------

xsvaaaa
xsvbbbb
xsvhjhjh
xsvuyre
sssgtree
cdvcesd
cxdvvvv
drerttyrd
gfvrtyuer
bfvretytr

I need to change the value XSV replacing to YSV in colum A1.

colum A1 having 1 lak records , but XSV* records are 10 thousends records, i need to insert this 10 thousend records to table A.

This XSV value and YSV values are need to pass from out side the program.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 30, 2010 1:56 pm    Post subject:
Reply with quote

What have you tried so far and what were the results that caused you a problem.
Back to top
View user's profile Send private message
george16

New User


Joined: 08 Jul 2010
Posts: 11
Location: chennai

PostPosted: Fri Jul 30, 2010 2:12 pm    Post subject:
Reply with quote

i have tried, but i need to fix immed pls give me the logic... thru cobol
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 30, 2010 2:18 pm    Post subject:
Reply with quote

george16 wrote:
i have tried, but i need to fix immed pls give me the logic... thru cobol
Please do not ask for code for urgent fixes. Unfortunately the urgency is yours alone.

I assume that this is a DB2 table, but this is something that you need to state clearly. What have you tried, please post the code so that the SQL wizards can see where you are coming from and be better able to help you. Also the results of your attempt may be of value. The fact that you say that you have tried is irrelevant, because without knowing what you have tried there is always the possibility that the same suggestion could be made again which would waste everyones time.

Please give us some real detail to be able to work with to help you out.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 30, 2010 2:36 pm    Post subject:
Reply with quote

george16,
not for the first time, your requirements are confusing.

1. is column-a part of an index? if so, which type?

2. do you want to replace (UPDATE) the existing, or
do you want to add (INSERT) additional rows with a new column-a,
where ... has been changed to ---?

3. are there other columns? what is the disposition of these columns?
Back to top
View user's profile Send private message
george16

New User


Joined: 08 Jul 2010
Posts: 11
Location: chennai

PostPosted: Fri Jul 30, 2010 4:01 pm    Post subject:
Reply with quote

1. pic X(8).
2. i want to add (INSERT)
3.A1 coulmn is the key.so we can insert new name
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 30, 2010 5:53 pm    Post subject:
Reply with quote

untested code

Code:

01  parms.
  05  new-val      pic x(03).
  05  old-val       pic x(03).

read parms

exec sql
  insert into tableA
    select(concat(:new-val,substr(a1,4,5)),a2 from tableA)
  where substr(a1,1,3) = :old-val
end-exec


or
Code:


05  counter       pic s9(7) comp-3.
   88  time-to-commit  value 1000.
   88  no-work-done    value zero.

start-routine  section.

  exec sql
    declare cursor dbz with hold for select
      a1,
      a2
    from tableA
    where substr(a1,1,3) = :old-val
  end-exec

  exec sql
    open dbz
  end-exec

  perform fetch-and-insert-control
       until sqlcode <> 0

  perform commit-routine
  .
section-exit.
exit.

fetch-and-insert-control   section.

  exec sql
    fetch dbz
      into
        :host-a1,
        :host-a2
  end-exec

  if sqlcode = 0
  then
    compute counter = counter + 1
    move new-val to hold-a1(1:3)
    perform insert-routine
    if time-to-commit
      perform commit-routine
    end-if
  end-if
  .
section-exit.
exit

insert-routine section.

  exec sql
    insert into
    tablea (a1,a2)
    values(:host-a1,:host-a2)
  end-exec
.
section-exit.
exit.

commit-routine  section.

  exec sql
    commit work
  end-exec

  set no-work-done to true
  .
section-exit.
exit.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm
No new posts Getting soc4 on internal table in cobol abdulrafi COBOL Programming 13 Fri May 06, 2016 3:39 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us