View previous topic :: View next topic
|
Author |
Message |
subratarec
Active User
Joined: 22 Dec 2007 Posts: 126 Location: Bangalore
|
|
|
|
Hi,
I need to know a very basic info related to VSAM. As I haven't worked on VSAM much in past. So my understanding in VSAM is bit less. Question is...
I have created a VSAM cluster (KSDS) using IDCAMS, it created successfully. and I haven't loaded any data into the KSDS. Now can I insert valid data using application program (say PL/1 or COBOL) to that KSDS VSAM file?
IF not, can anyone through some light on why we can't (any reference to read is also ok)
Thanks in advance
Subrata |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
As long as you open the VSAM file for output (and not I-O), you can use an application program to put data into it. |
|
Back to top |
|
|
subratarec
Active User
Joined: 22 Dec 2007 Posts: 126 Location: Bangalore
|
|
|
|
Hi Robert,
Thanks for the reply. Initially I also thought the same. But someone changed my way of understanding by saying that
"Post creation of KSDS cluster if it doesn't have any data in it, we can't use application program to insert data in the KSDS. As the Index of the KSDS wasn't build (because it was blank) application pgm can't insert the data. We have to load atleast some valid data in it, then the Index will be built. After that only we will be able to use App pgm to insert data in it."
I couldn't understand why would that happen. To my understanding app pgm will treat it is as just another output ds (which is having more capabilities than normal PS file) and can write valid data in it.
Anyway thanks for clearing my doubt.
Thanks
Subrata |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Whoever made that statement to you is wrong. VSAM does make a distinction between an empty data set (which has never had any records in it) and a data set which has had records in it but does not now have any. An empty data set CANNOT be opened for input since some of the internal pointers don't get established until the first record is written to the data set.
For clarification, I quote the Enterprise COBOL Application Programming Guide manual:
Quote: |
1.10.3.2.1 Opening an empty file
To open a file that has never contained records (an empty file), use a form of the OPEN statement. Depending on the type of file that you are opening, use one of the following statements:
OPEN OUTPUT for ESDS files.
OPEN OUTPUT or OPEN EXTEND for KSDS and RRDS files. (Either coding has the same effect.) If you coded the file for random or dynamic access and the file is optional, you can use OPEN I-O.
Optional files are files that are not necessarily present each time a program is run. You can define files opened in INPUT, I-O, or OUTPUT mode as optional by defining them with the SELECT OPTIONAL clause in the FILE-CONTROL paragraph.
Initially loading a file sequentially: Initially loading a file means writing records into the file for the first time. Doing so is not the same as writing records into a file from which all previous records have been deleted. To initially load a VSAM file:
Open the file.
Use sequential processing (ACCESS IS SEQUENTIAL). (Sequential processing is faster than random or dynamic processing.)
Use WRITE to add a record to the file.
Using OPEN OUTPUT to load a VSAM file significantly improves the performance of your program. Using OPEN I-O or OPEN EXTEND has a negative effect on the performance of your program. When you load VSAM indexed files sequentially, you optimize both loading performance and subsequent processing performance, because sequential processing maintains user-defined free space. Future insertions will be more efficient. With ACCESS IS SEQUENTIAL, you must write the records in ascending RECORD KEY order. When you load VSAM relative files sequentially, the records are placed in the file in the ascending order of relative record numbers. |
So the COBOL manual specifically addresses the issue that you were told about. |
|
Back to top |
|
|
subratarec
Active User
Joined: 22 Dec 2007 Posts: 126 Location: Bangalore
|
|
|
|
Hi Robert,
Thanks for the detail clarification. Let me go through the COBOL Manual for this. I will let my guy know that his understanding is wrong. Data can be inserted/write through App Pgm to a newly created blank KSDS cluster.
Will come back if I have any doubts
Thanks
Subrata |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
The word "inserted" may actually mean something different than I think you intended.
"Inserted" actually means one or more records were added to a data set that already contains records. It does not mean one or more records were added to a data set that has no records in it. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
|