View previous topic :: View next topic
|
Author |
Message |
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
I have a COBOL/DB2 code, which has a declare statement as given below,
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC.
A cursor is defined on the table that is declared above,from which data is fetched and written to output files.
Nowhere in the code, data is inserted into this temp table, which can latter be retrieved using the cursor.
Please let me know how(usually) delcared tables are populated with data.
Thanks,
Siva |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Siva,
Quote: |
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC.
|
By any chance, are you referring to DECLARE table of DCLGEN???
Quote: |
Nowhere in the code, data is inserted into this temp table, which can latter be retrieved using the cursor.
|
Why do you want the data to be inserted into the temp table??? Cursor is usually declared which is then opened, fetched and closed. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
The Declaration statement is not for a temp table. |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hello,
Quote: |
A cursor is defined on the table that is declared above,from which data is fetched and written to output files.
Nowhere in the code, data is inserted into this temp table, which can latter be retrieved using the cursor. |
This Concept were explained many times in forum...
Anyhow here is answer for you
The
Code: |
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC. |
will execute only when fallowing statement executed
ie
Code: |
EXEC SQL
OPEN <cursor name>
END-EXEC. |
The above statement will execute the statement which was present in DECLRATION and the results will dumped to temperuary set(buffer) which is presnt in main memory.
Buffer
record 1
record 2
record 3
record 4
record 5
-------------------
To fetch information from above buffer, we will use
Code: |
EXEC SQL
FETCH <cursor>
END_EXEC |
Hope you clear |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Revel,
Quote: |
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC. |
Are you saying that the above statements are for the declaration of a cusrsor?
I am confused here |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Aaru,
Thats what he said, He mistyped the code
Please check his above post
here is his post
Code: |
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC.
A cursor is defined on the table that is declared above, |
|
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Thanks for the responses…
dbz, if this not a table(even a temp), then what else can it be, where a cursor is declared on it and data is fetched. Excuse me if the question is absurd.
The cursor is declared in the conventional way, similar to that of a normal DB2 table as following,
EXEC SQL
DECLARE CURSOR1 CURSOR FOR
SELECT
AAA_BBB_CCC.Field1
AAA_BBB_CCC.Field2
AAA_BBB_CCC.Field3
AAA_BBB_CCC.Field4
FROM
AAA_BBB_CCC AAA_BBB_CCC --> this is not a typo, but how it is actually coded ie. the name is coded twice.
If AAA_BBB_CCC is queried in SPUFI, I get a SQL -204(undefined name).
The declare statement on AAA_BBB_CCC which I had given in my first post is same as how it is coded, there is no typo in it, I didn’t really understand what Revel is talking about.
Aaru, I understand that a cursor is Opened/Fetched/Closed, but I am wondering where from the data is coming, since I am not able to retrieve records from AAA_BBB_CCC in SPUFI using a Select query.
Thanks,
Siva |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hello Siva,
tell me first, What is your requirement. I hope this is not a home work question... :o)
What did you explained in previous post...then??
Quote: |
Hi,
I have a COBOL/DB2 code, which has a declare statement as given below,
EXEC SQL
DECLARE AAA_BBB_CCC TABLE
(
Field names with their data types are defined.......
)
END-EXEC.
A cursor is defined on the table that is declared above,from which data is fetched and written to output files.
Nowhere in the code, data is inserted into this temp table, which can latter be retrieved using the cursor.
Please let me know how(usually) delcared tables are populated with data. |
Please come up with correct requirement |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Hi,
The declare table statement you are referring to is very much ismiliar to a DCLGEN. Do you have equivalent cobol variables declared right after the END-EXEC? If your answer is Yes, Then it is a DCLGEN and it reprenents a physical table in your Cobol program. The cursor which you are referring to is declared on the real table.
IF the name is coded twice, then try the same name in SPUFI. |
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
I am working on converting VSCOBOLII/OS390 modules to eCOBOL standard. We do a regression testing of the output files (files produced by executing test jobs against Prod and changed code).
When the output files are empty, we will manipulate the DB so that we get some records in the output. For one such module the files were empty and I couldn’t locate the table to manipulate the data and hence the question.
Bharath, as you said I have COBOL variables declared which is similar in structure to the declaration of AAA_BBB_CCC, but I am not able to query the table AAA_BBB_CCC(I get a SQL -204).
Thanks,
Siva |
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
I got the table name by querying SYSIBM.SYSTABLES, I gave a wrong qualifier while querying the table, thats why I was getting a -204.
Thanks for the help.
Regards,
Siva |
|
Back to top |
|
|
|