From: Frank Swarbrick on
>>> On 1/31/2008 at 5:12 PM, in message
<hdo4q31j0u8ecl2gj03a7onbaq4gb5j8u2(a)4ax.com>, Robert<no(a)e.mail> wrote:
> On Thu, 31 Jan 2008 11:42:31 -0700, "Frank Swarbrick"
> <Frank.Swarbrick(a)efirstbank.com>
> wrote:
>
>>>>> On 1/30/2008 at 8:25 PM, in message
>><med2q3hfb6vi8gbtvf436o07sr4k1jg0n5(a)4ax.com>, Robert<no(a)e.mail> wrote:
>>> On Wed, 30 Jan 2008 21:55:18 +0000, Frederico Fonseca
>>> <real-email-in-msg-spam(a)email.com>
>>> wrote:
>
>>>>......
>>>> 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.
>>
>>You're welcome to try it yourself, or at least provide an example that
> you
>>think would work and I could try it.
>
> Change the select to:
> EXEC SQL
> DECLARE C1 CURSOR FOR
> select name, dept
> from table2
> where name in (select distinct name from test.table1)
> END-EXEC.
> EXEC SQL OPEN C1 END-EXEC.
> EXEC SQL
> FETCH FIRST C1 INTO :TABLE2-ENTRY FOR 100 ROWS
> END-EXEC.
> EXEC SQL CLOSE C1 END-EXEC.

the FIRST clause of the FETCH statement is not supported by DB2/LUW. (Nor
is the "FOR...ROWS" clause):

51 SQL0104N An unexpected token "C1" was found following
"FETCH". Expected tokens may include: "<identifier>".

Frank

From: Frederico Fonseca on
On Thu, 31 Jan 2008 18:17:42 -0600, Robert <no(a)e.mail> wrote:

>On Thu, 31 Jan 2008 11:56:10 -0700, "Frank Swarbrick" <Frank.Swarbrick(a)efirstbank.com>
>wrote:
>
>> SQL0060W The "COBOL" precompiler is in progress.
>> 19 SQL0008N The token "occurs" found in a host variable
>> declaration is not valid.
>> 51 SQL0306N The host variable "TABLE2-ENTRY" is undefined.
>> SQL0095N No bind file was created because of previous
>> errors.
>> SQL0091W Precompilation or binding was ended with "3"
>> errors and "0" warnings.
>>
>>I also tried this and got the same error
>> 05 table2-entry occurs 100.
>>
>>Now of course you can remove the occurs, but then you're stuck with fetching
>>one row at a time.
>>
>>I see no way to do a multi row (at once) fetch using DB2/LUW.
>>
>>More thoughts would be welcome.
>
>I believe this will work for sure:
>
> 05 table2-entry.
> 10 t2-name pic x(30) occurs 100.
> 10 t2-dept pic x(04) occurs 100.
>
> fetch t2_curs
> into :t2-name, :t2-dept
Frank


STOP stating what you think should work, and download a copy of DB2
UDB (9.5) for Windows freely available from IBM.

Then using your COBOL Compiler of choice for Windows
(Fujitsu/Microfocus/RMCOBOL (you will need to pay me for the interface
though), or other, and create a fully working program that will fetch
100 rows in one single SQL FETCH statement, using only ESQL. Note that
the above is possible using CLI programming, but this is not what was
asked.

Then show us the code.



Frederico Fonseca
ema il: frederico_fonseca at syssoft-int.com
From: Anonymous on
In article <c3p4q3tji85k6tegudomp2k4f4bmtk744o(a)4ax.com>,
Robert <no(a)e.mail> wrote:

[snip]

>I believe this will work for sure:

'No doubt about it... I gotta get another hat.' - Bullwinkle Moose

DD
From: Richard on
On Feb 1, 1:43 pm, Frederico Fonseca <real-email-in-msg-
s...(a)email.com> wrote:
> On Thu, 31 Jan 2008 18:17:42 -0600, Robert <n...(a)e.mail> wrote:
> >On Thu, 31 Jan 2008 11:56:10 -0700, "Frank Swarbrick" <Frank.Swarbr...(a)efirstbank.com>
> >wrote:
>
> >> SQL0060W The "COBOL" precompiler is in progress.
> >> 19 SQL0008N The token "occurs" found in a host variable
> >> declaration is not valid.
> >> 51 SQL0306N The host variable "TABLE2-ENTRY" is undefined.
> >> SQL0095N No bind file was created because of previous
> >> errors.
> >> SQL0091W Precompilation or binding was ended with "3"
> >> errors and "0" warnings.
>
> >>I also tried this and got the same error
> >> 05 table2-entry occurs 100.
>
> >>Now of course you can remove the occurs, but then you're stuck with fetching
> >>one row at a time.
>
> >>I see no way to do a multi row (at once) fetch using DB2/LUW.
>
> >>More thoughts would be welcome.
>
> >I believe this will work for sure:
>
> > 05 table2-entry.
> > 10 t2-name pic x(30) occurs 100.
> > 10 t2-dept pic x(04) occurs 100.
>
> > fetch t2_curs
> > into :t2-name, :t2-dept
>
> Frank

Actually it was Robert that you were replying to.

> STOP stating what you think should work,

The Mine of Misinformation strikes again.

Whenever Robert says 'this will work' or similar you can be sure that
it is answering the wrong question, and/or that it will not work, and/
or he hasn't tested it at all.


> and download a copy of DB2
> UDB (9.5) for Windows freely available from IBM.
>
> Then using your COBOL Compiler of choice for Windows
> (Fujitsu/Microfocus/RMCOBOL (you will need to pay me for the interface
> though), or other, and create a fully working program that will fetch
> 100 rows in one single SQL FETCH statement, using only ESQL. Note that
> the above is possible using CLI programming, but this is not what was
> asked.
>
> Then show us the code.
>
> Frederico Fonseca
> ema il: frederico_fonseca at syssoft-int.com

From: Robert on
On Thu, 31 Jan 2008 17:27:50 -0700, "Frank Swarbrick" <Frank.Swarbrick(a)efirstbank.com>
wrote:

>>>> On 1/31/2008 at 5:17 PM, in message
><c3p4q3tji85k6tegudomp2k4f4bmtk744o(a)4ax.com>, Robert<no(a)e.mail> wrote:
>> On Thu, 31 Jan 2008 11:56:10 -0700, "Frank Swarbrick"
>> <Frank.Swarbrick(a)efirstbank.com>
>> wrote:
>>
>>> SQL0060W The "COBOL" precompiler is in progress.
>>> 19 SQL0008N The token "occurs" found in a host variable
>>> declaration is not valid.
>>> 51 SQL0306N The host variable "TABLE2-ENTRY" is undefined.
>>> SQL0095N No bind file was created because of previous
>>> errors.
>>> SQL0091W Precompilation or binding was ended with "3"
>>> errors and "0" warnings.
>>>
>>>I also tried this and got the same error
>>> 05 table2-entry occurs 100.
>>>
>>>Now of course you can remove the occurs, but then you're stuck with
>> fetching
>>>one row at a time.
>>>
>>>I see no way to do a multi row (at once) fetch using DB2/LUW.
>>>
>>>More thoughts would be welcome.
>>
>> I believe this will work for sure:
>>
>> 05 table2-entry.
>> 10 t2-name pic x(30) occurs 100.
>> 10 t2-dept pic x(04) occurs 100.
>>
>> fetch t2_curs
>> into :t2-name, :t2-dept
>
>Nope. I tried that one too.
>
>LINE MESSAGES FOR tabtest.sqb
>------
>--------------------------------------------------------------------
> SQL0060W The "COBOL" precompiler is in progress.
> 21 SQL0314N The host variable "t2-name" is incorrectly
> declared.
> 22 SQL0314N The host variable "t2-dept" is incorrectly
> declared.
> 20 SQL4007N The host structure "table2-entry" has no fields.
> 18 SQL4007N The host structure "table2-area" has no fields.
> 51 SQL0104N An unexpected token "t2_curs" was found following
> "<identifier>". Expected tokens may include: "INTO".
> SQL0095N No bind file was created because of previous
> errors.
> SQL0091W Precompilation or binding was ended with "6"
> errors and "0" warnings.

Here is an sample from the IBM DB2 manual:

EXEC SQL
FETCH NEXT ROWSET FROM EMPSET
FOR :SIZE-ROWSET ROWS
INTO :HVA-EMPNO, :HVA-LASTNAME, -- defined with occurs
:HVA-WORKDEPT, :HVA-JOB
END-EXEC.

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.apsg/db2z_xmpsfetchingrowscursor.htm

DB2 Version 9.1 for z/OS