View previous topic :: View next topic
|
Author |
Message |
Shivendu
New User
Joined: 20 Feb 2009 Posts: 14 Location: Workstation
|
|
|
|
I want to write a Natural query through which all the data present in a particular adabas file is read and written to a flat file. I know the copybook of the adabas file and the key field (policy number) which will be used to search for the particular record in the adabas file.
Please help as I am new to Natural. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
1. There are many many examples in Software AG's fine manuals.
2. What do you mean by "copybook of the adabas file"? Copybook is a COBOL term. In Natural, only DDM may describe the structure of a database file.
3. If you want to read "all the data present in a particular adabas file" - Why do you need a key? You can read it physically, which would be much faster.
O. |
|
Back to top |
|
|
Shivendu
New User
Joined: 20 Feb 2009 Posts: 14 Location: Workstation
|
|
|
|
Sorry, I meant DDM only.
Suppose, there are 1000 policies in the adabas file (1000 records). I have a flat file which contains 100 policy numbers. By reading this flat file, I want to query adabas and extract all the data (i.e. all the fields in the DDM) for all these 100 policies. Hope I am clear this time. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Take a look at the READ statement, with the BY operand. If you want to read 1 record at a time, use the limit notation.
O. |
|
Back to top |
|
|
Shivendu
New User
Joined: 20 Feb 2009 Posts: 14 Location: Workstation
|
|
|
|
My adabas file has 200 variables (in DDM). I want to write values contained in ALL of these variables to a flat file. Do I need to explicitly code all these (all 200) in DEFINE DATA LOCAL?
Right now what all variables I am coding in definition are getting written to the output file correctly (policy number in below case) using below code.
Code: |
DEFINE DATA LOCAL
1 NGI-POLICY VIEW OF NGI-POLICY
2 POLICY-NUMBER |
Code: |
READ WORK FILE 1 #POLICY-NUMBER
FIND NGI-POLICY WITH POLICY-NUMBER = #POLICY-NUMBER
WRITE WORK FILE 2
NGI-POLICY |
Policy number is getting written to output file, rest all is blanks.
Is there a way to have all the DB fields written to output file WORK FILE 2? |
|
Back to top |
|
|
Shivendu
New User
Joined: 20 Feb 2009 Posts: 14 Location: Workstation
|
|
|
|
Please refer to next post...not able to delete this one. Sorry! |
|
Back to top |
|
|
purushottam
New User
Joined: 26 Feb 2007 Posts: 37 Location: pune
|
|
|
|
Yes, you will need to code all these (all 200) in VIEW Definition then move those values to corresponding variables of WORK FILE 2.
I dont think there is any other way out.
Regards,
Puru |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
1. You can use pure Reporting mode to avoid the VIEW definition; However, you still have to specify each field in your WRITE statement.
2. There are tools for writing a whole record (Take a look at TreeHouse, for example).
O. |
|
Back to top |
|
|
Ralph Zbrog
New User
Joined: 21 Nov 2009 Posts: 58 Location: California
|
|
|
|
All 200 field names must exist in your view, but that does not mean that you have to type all of them manually. Natural can generate the field list for you.
. invoke the data editor
. use .V line command to insert the view: .v(viewname)
. select the 200 field names from the list
. use the GEN command, which places you in the program editor
. change the module type to Program: SET TYPE P
. use this module as the basis of your query, or save it temporarily as a separate module for inclusion in the DEFINE DATA portion of your query
You do not need to move the field values from the view to a temporary structure to be used in the WRITE WORK, as suggested by Purushottam. For performance reasons, this is frowned upon. Your example
Code: |
WRITE WORK FILE 2 NGI-POLICY |
will work. |
|
Back to top |
|
|
|