Re: help with tables
- From: Robert <no@xxxxxx>
- Date: Wed, 30 Jan 2008 21:25:00 -0600
On Wed, 30 Jan 2008 21:55:18 +0000, Frederico Fonseca <real-email-in-msg-spam@xxxxxxxxx>
wrote:
The following is allowed on V9, but on Z/OS.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC
EXEC SQL
BEGIN DECLARE SECTION
END-EXEC
01 table2-area.
05 table2-entry.
10 t2-name pic x(30) occurs 100.
10 t2-dept pic x(04) occurs 100.
Was that necessary? DB2, like Oracle, expands a Cobol group name into a list of host
variables by using the next lower level, which should be elementary. In other words:
05 table2-entry occurs 100.
10 t2-name pic x(30).
10 t2-dept pic x(04).
into :table2-entry
is expanded to
into :t2-name, :t2-dept
I don't know whether DB2 is smart enough to treat :t2-name as an array. Oracle is.
If not, would :table2-entry.t2-name work?
EXEC SQL
END DECLARE SECTION
END-EXEC
EXEC SQL
DECLARE CURSOR-X CURSOR FOR
select name, dept
from test.table2
where name in (select distinct name from test.table1)
END-EXEC.
A cursor need not be declared in the data division, only before the first reference to it.
I prefer to put the declaration just above the fetch, with the open and close further
down.
......
PROCEDURE....
exec sql
FETCH NEXT CURSOR-X
into :T2-NAME, :T2-DEPT
for 100 rows
end-exec
It seems that Windows/Unix versions do not allow multiple fetch/insert
rows. Pitty.
Hard to believe. I think the non-singleton select caused the error.
.
- Follow-Ups:
- Re: help with tables
- From: Frank Swarbrick
- Re: help with tables
- References:
- Re: help with tables
- From: Frank Swarbrick
- Re: help with tables
- From: Frederico Fonseca
- Re: help with tables
- Prev by Date: Re: help with tables
- Next by Date: Re: Web Cobol - Tool for web develop with AcuCobol
- Previous by thread: Re: help with tables
- Next by thread: Re: help with tables
- Index(es):
Relevant Pages
|