IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Update to DB2 from COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sunojsm
Warnings : 1

New User


Joined: 21 Jun 2004
Posts: 33
Location: Andorra

PostPosted: Sun Feb 18, 2007 3:07 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Feb 18, 2007 3:23 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Feb 18, 2007 4:37 am
Reply with quote

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
View user's profile Send private message
sunojsm
Warnings : 1

New User


Joined: 21 Jun 2004
Posts: 33
Location: Andorra

PostPosted: Sun Feb 18, 2007 4:23 pm
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Tue Feb 20, 2007 1:27 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 20, 2007 8:29 pm
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Wed Feb 21, 2007 2:45 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed Feb 21, 2007 3:20 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed Feb 21, 2007 3:32 pm
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Thu Feb 22, 2007 12:08 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Feb 22, 2007 1:47 am
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Thu Feb 22, 2007 11:46 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Feb 23, 2007 1:17 am
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Fri Feb 23, 2007 2:58 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 23, 2007 3:31 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Fri Feb 23, 2007 4:35 pm
Reply with quote

Hi cobolunni !

Nice to follow your discussion with Dick. I had a pleasent time, reading this. Also in consideration of the fact, that i, also a technical person (Systemprogrammer), who is hired for expensive money from a company hour for hour, could spent time on reading that and getting well payed for it. I hope this is going on, cause I still have to be here a fiew houres till it's weekend.

But let me post one humble contribution to your stable opinion about technical persons.

I get well payed for profound knowledge, but mostly for reaching quick results and quickly solving a problem.

So it's of secondary importance if i know that Cobol directly without of use of embedded SQL could not update a table.

The only fact that rules is, that with cobol you could perform an update against a db2-tabel.

And also, that one has the knowledge of how to programm that.

I hope, i could read more philosophical considerations.
There are five houres more till weekend.

@Dick: Pease don't give up. Go and let the genie out of the bottle.
I agree with you.

@Bill: Keep on !

Regards, UmeySan
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Sat Feb 24, 2007 10:29 pm
Reply with quote

William for doing something those related to hardware and file system each programming language has to depend on system specific components or other applications which accomplishes the task for them, That is a true and unaltered matter. Here i am try to tell that EXEC statement is not a standard COBOL statement
William Thompson wrote:
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.


That's i dont understand because interfacing with a data base one programming language needs a API .Even java based programming language needs JDBC as a API. So how a COBOL program will do that directly.

Consider PHP it has a statement mysql_connect(host, user name, pass) that will connect with mysql data base. Can you show me any COBOL statement for data base. For example to read a flat file or vsam data set COBOL has it's own native statement's but there is no native statement for data base manipulation that's what i told

And as you told we can write COBOL program to manipulate database without a precompiler , can u please explain it in detail, that will be a good goldmine for us
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Feb 24, 2007 10:53 pm
Reply with quote

cobolunni wrote:
Here i am try to tell that EXEC statement is not a standard COBOL statement
True, and macros are not a standard Assembler statement.
Quote:
William Thompson wrote:
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.
That's i dont understand because interfacing with a data base one programming language needs a API .Even java based programming language needs JDBC as a API. So how a COBOL program will do that directly.
Moving targets are hard to hit, but I'll try. The EXEC statements are not the API, they are shorthand for communication with the API.[/quote]
Quote:
And as you told we can write COBOL program to manipulate database without a precompiler , can u please explain it in detail, that will be a good goldmine for us
I guess you don't see what is right in front of you, the COBOL code coming out of the translator is still COBOL code, there is no magical programming language imbedded in the COBOL code. There is nothing stopping you from coding the API interface code yourself but your "goldmine" seems more like a "money pit" to me.... icon_wink.gif
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Sat Feb 24, 2007 11:11 pm
Reply with quote

William Thompson wrote:
guess you don't see what is right in front of you, the COBOL code coming out of the translator is still COBOL code, there is no magical programming language imbedded in the COBOL code. There is nothing stopping you from coding the API interface code yourself but your "goldmine" seems more like a "money pit" to me....


What are you telling . You told that there is some magical methods by which you will show the magic of making cobol update the db2 without the need of precompiler. Now you tells that cobol program comes out of translator is cobol code if u can do that without a translator or precompiler then what is the need of mensioning it. I think that gold mine is a dream that you cares, dont worry try to make it true so that we can get anoyher einstein icon_wink.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Feb 25, 2007 1:22 am
Reply with quote

Hello again cobolunni,

Bill has neither said nor implied that there is any magic!

What he has said is that when the DB2 pre-compliler processes the EXEC SQL statements, it converts them to standard COBOL source - which is both correct and is the way 1/2 million or more coders use SQL in their COBOL code.

For a bit of understanding and education, i strongly suggest that you embed some simple SQL in a COBOL program and run it through the pre-compiler in use at your location (of the 100+ data centers that i've been involved with over the last 20 years, EVERY one of them uses a pre-compiler for SQL). Then compare the coded EXEC SQL to the generated "standard COBOL" that was generated by the pre-compiler. You will see that, if you so desired, you could write the same thing by hand, but there is no good reason to do so.

This may be way off the mark, but it sounds like you and/or your organization have been awarded or taken on a task that for which you have NO background and/or expertise. If this is correct, someone needs to inform your client and/or management that before you can perform the DB2 work properly, you have to learn the basics.

A couple of times i've asked, recieved no reply, and will now ask again. . .
Quote:
What kind of CALLs did you replace the SQL with?

and
Quote:
What calls did you have to put in your code? Might these be the same thing the pre-compiler generates?

If you do not use EXEC SQL, what do you use?
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Sun Feb 25, 2007 3:27 am
Reply with quote

dick scherrer wrote:
This may be way off the mark, but it sounds like you and/or your organization have been awarded or taken on a task that for which you have NO background and/or expertise. If this is correct, someone needs to inform your client and/or management that before you can perform the DB2 work properly, you have to learn the basics.

Dear dick i am a BTECH student in electronics and communication . I am also attending a course on mainframe computer's.
You told that COBOL can update db2 tables. You are telling that in the basis of work on a mainframe computer's But mainframe is not the only machine which can use COBOL. COBOL is a programming language that can be used in any system. I am using Linux in my PC and uses opencobol to done my experiments with COBOL. That language doesn't have any native statements to deal with data base. Also as umaysen said this talk is unnecessary. As you said as a developers point of view he can do the db2 updating with COBOL
dick scherrer wrote:

A couple of times i've asked, received no reply, and will now ask again. . .
Quote:
What kind of CALLs did you replace the SQL with?

and
Quote:
What calls did you have to put in your code? Might these be the same thing the pre-compiler generates?

Dick i am using open cobol to compile cobol in Linux. Open COBOL uses gcc( a c compiler--also compiles c++ etc) . But gcc will not able to compile COBOL but open COBOL compiler converts COBOL program to C program and uses gcc to compile
now a question:
Can you say that GCC can compile COBOL?
I think the answer is no? then COBOL will not able to update db2 directly.
Precompiler extracts the code between EXEC SQL and END-SQL and compiles the SQL statements and creates a binary form of SQL and gives a name .Now the COBOL source is modified by CALL to that binary file, That is the call i mentioned:
If gcc can compile COBOL program then COBOL can update DB2?
Dick it's nice to talk with you. Actually i am interested in web application development that includes Linux Apache Php and Mysql
I am discussing here about mainframe is because i love mainframe technology. Not because i need some technical support to make money easily
Thanks
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Feb 25, 2007 4:21 am
Reply with quote

cobolunni wrote:
now a question: Can you say that GCC can compile COBOL? I think the answer is no?
cobolunni wrote:
but open COBOL compiler converts COBOL program to C program and uses gcc to compile
then COBOL will not able to update db2 directly.

icon_confused.gif
Quote:
Precompiler extracts the code between EXEC SQL and END-SQL and compiles the SQL statements and creates a binary form of SQL and gives a name
icon_confused.gif Translates, not compiles!
Quote:
Now the COBOL source is modified by CALL to that binary file
Yea, the API you mentioned so eloquently earlier
Quote:
That is the call i mentioned:
If gcc can compile COBOL program then COBOL can update DB2?
icon_confused.gif GCC, I thought this was a COBOL question?
Quote:
Actually i am interested in web application development that includes Linux Apache Php and Mysql
Good
Quote:
I am discussing here about mainframe is because i love mainframe technology.
Good
Quote:
Not because i need some technical support to make money easily
icon_confused.gif That was either very altruistic or somewhat of a personal affront. I do not know which, but I'll assume the former.
Quote:
Thanks
And thank you.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Feb 25, 2007 4:38 am
Reply with quote

Hi cobolunni,

Well, your reply surely makes things more clear.

While this thread has enjoyed many exchanges, it was not until just now that i came to the realization that we were not all talking about IBM Mainframe COBOL icon_surprised.gif

Yes, what you say is true for some situations - some others have pre-compilers. . . It is always a good idea to mention the environment you are working in if your environment is not the same as the forum where the discussion is gong on icon_smile.gif

Just an fyi, in addition to many years of mainframe support, i've also performed system/database admin on both UNIX and NT platforms (most of my sites are getting more and more into multi-platform). I've not yet ventured into Linux. . . If you are interested, MICRO-FOCUS COBOL works very well on both unix and nt. Opencobol will be good to learn with.

Good luck with your studies, be well, and come back to visit again icon_wink.gif
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Sun Feb 25, 2007 4:55 am
Reply with quote

William Thompson wrote:
Translates, not compiles!


SQL is a set of statements , Which is converted to binary format after some syntax checking-- Is that is compiling
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Feb 25, 2007 5:00 am
Reply with quote

Regarding mainframe COBOL and SQL:
SQL is a set of statements , which is converted to COBOL format after some syntax checking-- That is translating. icon_rolleyes.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top