|
|
| Author |
Message |
sunojsm Warnings : 1 New User
Joined: 21 Jun 2004 Posts: 48 Location: Heaven
|
|
|
|
Hi,
I have one scenario with me,
I have one file with some records and using JCL I sorted that file by retreiving the required fields from that file and put the results in another file.
Now what I want is, I need a cobol code for the given condition.
I have to first read the records till end of file of the jcl output ie the sortout.
Now I have one table with me in which one column have
the same field that we retrieve from jcl.What I
want to do is to overwrite the sortout fields with the table fields.
For that I need to update the table using cobol code.
I need the complete cobol code for this from identification division onwards.
Can anyone please help me on this.I need it very quickly.
Waiting for your replies.
Thanks |
|
| Back to top |
|
 |
References
|
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 2977 Location: Tucson AZ
|
|
|
|
| sunojsm wrote: |
| I need the complete cobol code for this from identification division onwards. |
I'm sorry, but you are either a person hired as a programmer that has no clue on how to program or, you are a student looking for somebody to "crib" your homework.
Which one is it?
Where is "Heaven"?
Software Engineer? |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8724 Location: 221 B Baker St
|
|
|
|
Hello,
You have a bit of a problem with your requirement definition.
| Quote: |
Now I have one table with me in which one column have
the same field that we retrieve from jcl.What I
want to do is to overwrite the sortout fields with the table fields.
For that I need to update the table using cobol code.
|
Which do you need to do? Update a sequential file with data from the table or update the table with data from the sequential file? The above is not coear to me.
When you ask a question is it always a good idea to post what you already have (i.e. your jcl, code, data definitions, what you want the output to look like, etc). The better you define your situation, the better we can provide assistance. If you need something "very quickly" you might say why - we appreciate that sometimes there is a crisis (many of us have dealt with many of them) and it is helpful if we understand your sense of urgency. |
|
| Back to top |
|
 |
sunojsm Warnings : 1 New User
Joined: 21 Jun 2004 Posts: 48 Location: Heaven
|
|
|
|
Hi,
I have one file with so many records.I retrieved certain records that have the field value as say AB in 30th position.And I retrieved it using SORT in JCL and I loaded the records that have AB in to sortout file.
Now I have one DB2 table with so many records in which it also have the field as say CD.
Now what i need is a cobol program that will read the sortout file till end and update the table by replacing CD with AB.
I dont need any other alternative ways..
I beleive now it is more clear.Please answer me asap.
Thanks |
|
| Back to top |
|
 |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 134 Location: kerala,india
|
|
|
|
Cobol cannot update db2 tables , I think you need CICS to done your job
Is CICS is permitted in your solution.
Is permitted then write a file program to read and then update db2 that's simple. if you need more explaination or code tell me |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8724 Location: 221 B Baker St
|
|
|
|
Hello,
COBOL CAN and does update DB2 - both in CICS and in batch.
Please explain why you believe COBOL cannot update DB2.
There is NO need to process this requirement in CICS. |
|
| Back to top |
|
 |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 134 Location: kerala,india
|
|
|
|
dick can you please tell how cobol can insert a value to db2 in batch mode
, please add a piece of code if you can |
|
| Back to top |
|
 |
UmeySan
Senior Member
Joined: 22 Aug 2006 Posts: 625 Location: Germany
|
|
|
|
Hi Cobolunni !
As Dick said: Batch-Updates of DB2-Tabels are allways possible in Cobol
and Assembler without CICS. There is no difference.
Regards, UmeySan
Here's a little example-section of a Batch-Cobol.
U01-UPDATE-VEDL SECTION.
MOVE 'U01 ' TO FTEXT3
MOVE 'VE_DARL ' TO W-SQLTABL
*-----------------------------------------------------------
EXEC SQL
UPDATE VE_DARL
SET ZUSAG_EDTM = :LI-VE-DARL.ZUSAG-EDTM
WHERE VE_ID = :LI-VE-DARL.VE-ID
AND VON = :LI-VE-DARL.VON
QUERYNO 14
END-EXEC
PERFORM U90-SQL-FEHLER
PERFORM U90-SQL-ZAEHLER
*-----------------------------------------------------------
MOVE SPACES TO FTEXT3.
U01-UPDATE-VEDL-EXIT. |
|
| Back to top |
|
 |
UmeySan
Senior Member
Joined: 22 Aug 2006 Posts: 625 Location: Germany
|
|
|
|
Hi sunojsm !
Now, as you figured out your problem, i think it's almost clear to yourself.
So write this little fucking programm. In the time of waiting for response for your answer, you could have almost written it.
Otherways, I agree with Bill.
...Declare Cursor for Update
DoUntil EOF of SeqFile
...Read SeqFile
...Fetch adaquate row
...Update, where current of...
or... use direct Update / where TableKey= :KeyField
EndDo
Regards, UmeySan |
|
| Back to top |
|
 |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 134 Location: kerala,india
|
|
|
|
Thanks umaysan,
But Actually EXEC SQL is not a standard cobol statement a cobol compiler eg IGYCRCTL will not able to directly compile this statement, for that we had to replace EXEC SQL code by cobol CALL state ments.
| dick scherrer wrote: |
Please explain why you believe COBOL cannot update DB2.
|
I meen that cobol cannot be able to directly modify the DB2 tables so its needs something external to do so |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8724 Location: 221 B Baker St
|
|
|
|
Hello,
It is called embedded sql and IS placed "inside" the cobol source. I'm not sure what you mean by "external". The sql is processed by a pre-compiler much like other things (like CICS) and when the smoke clears, you have a COBOL executable with DB2 (or Datacom or IDMS) and/or CICS in the module.
COBOL cannot directly read a disk or a tapee either. It relies on an i/o interface. COBOL specifies 'read', but what "really happens" is never seen by COBOL.
| Quote: |
| we had to replace EXEC SQL code by cobol CALL state ments. |
What kind of CALLs did you replace the SQL with? It may be that the compile jcl is incomplete? |
|
| Back to top |
|
 |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 134 Location: kerala,india
|
|
|
|
Dick ,
VS COBOL 2 specification doesn't have any data base manipulation statements so for that we are using a precompiler. If EXEC SQL is a cobol statement we can directly compile it by IGYCRCTL compiler but we are using a precompiler before compiling by actual COBOL compiler. A precompiler fetches every thing inside (include) EXEC SQL and replaces every thing by a cobol CALL statement. The CALL statement calls a binary form of SQL statements which does the Data base manipulation for COBOL
Actually as a user we sense that COBOL does the data base manipulation but really that is not the case |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8724 Location: 221 B Baker St
|
|
|
|
Hello,
I believe that this is just caught up in semantics.
In effect there is no difference between having the code parsed by a pre-compiler, then the compiler and having it all done in the compiler.
The code is written from ID Division to the last statement as one unit and after a successful compile/linkedt, an executable is produced in a loadlib.
If i have one piece of code (a program) that interacts with something external (i.e. DB2) that code is written "in COBOL" and does, if so designed, insert rows in DB2 tables.
A big reason i've continued with this is so that people new to COBOL and/or DB2 do not read the thread and come away with the impression that they cannot work with DB2 via COBOL. What does it matter that EXEC SQL is not a standard cobol statement ? When compile jcl is set up it should NOT be done by each programmer and the "standard" DB2 compile will include the pre-processor - or at least it does everywhere i've supported. . .
What calls did you have to put in your code? Might these be the same thing the pre-compiler generates? If you're saying the EXEC SQL was replaced by the pre-compiler, why mention it - that is the way it is typically done?
Back to
| Quote: |
Cobol cannot update db2 tables , I think you need CICS to done your job
|
Yes, COBOL can update DB2 tables and No, CICS is not needed. |
|
| Back to top |
|
 |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 134 Location: kerala,india
|
|
|
|
| dick scherrer wrote: |
In effect there is no difference between having the code parsed by a pre-compiler, then the compiler and having it all done in the compiler. |
yes you are right, From the user point of view there is no difference instead he had to do 2 compiling process one on precompiler and other by cobol compiler. But why IGYCRCTL compiler is unable to compile the EXEC SQL code without precompiler? This itself states that it is a added feature to cobol to make COBOL more useful.
| Code: |
| A pure cobol program can compiled by IGYCRCTL without any other precompiler |
Again cobol program cannot update db2 tables but There is a method called embedded sql to add this feature to cobol
| dick scherrer wrote: |
A big reason i've continued with this is so that people new to COBOL and/or DB2 do not read the thread and come away with the impression that they cannot work with DB2 via COBOL. |
For those new to cobol and DB2 using a method called embedded sql you can update db2 using cobol but pure cobol will not be able to update db2 tables
| dick scherrer wrote: |
What does it matter that EXEC SQL is not a standard cobol statement ?
|
its matter's that's why ibm manual for cobol doesn't mention EXEC SQL as standard cobol statement's
| dick scherrer wrote: |
| If you're saying the EXEC SQL was replaced by the pre-compiler, why mention it - that is the way it is typically done? |
we had to mention because that what it does. As a technical person we had to know what happens inside, If COBOL directly updates db2 or if there any other thing which does the task for COBOL
| dick scherrer wrote: |
Back to
| Quote: |
COBOL cannot update db2 tables , I think you need CICS to done your job
|
|
i am sorry for that CICS is not necessary for db2 updating
| dick scherrer wrote: |
| Yes, COBOL can update DB2 tables |
COBOL will not be able to update db2 tables unless it go for a method -- that is embedded sql[/quote] |
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 2977 Location: Tucson AZ
|
|
|
|
| cobolunni wrote: |
Cobol cannot update db2 tables , I think you need CICS to done your job
Is CICS is permitted in your solution.
Is permitted then write a file program to read and then update db2 that's simple. if you need more explaination or code tell me |
You are just plain missing the point (or very stubborn and argumentative).
Yes, COBOL can not (yet) directly access DB2.
By your argument, COBOL can't do CICS...CICS also needs pre-compile translation.
By your argument, Assembler can't do I/O....Assembler macros need "translation" too.
COBOL does interact with native access methods, to interact with other more advanced access methods it needs to interface with those access methods; that can be a very complicated task.
CICS and DB2 provide standardized pseudo code that the programmer can use to accomplish what is needed.
That pseudo code gets translated prior to the compile. Do you know why prior? Because all that pseudo code gets converted to COBOL code which needs to be compiled.
If you were good, and understood the interfaces, you could "write a file program to read and then update db2" without need for a pre-compile translation. |
|
| Back to top |
|
 |
|
|