× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Douglas,

What SQL0305 is telling you is that you did not provide a variable for the null indicator value on your fetch statement.

C*---Fetch the Result and place into Variable
C/EXEC SQL C+ FETCH C1 INTO :ZSUM C/END-EXEC
should look like

C*---Fetch the Result and place into Variable
C/EXEC SQL C+ FETCH C1 INTO :ZSUM, :ZNULLIND
C/END-EXEC
and as Milan mentioned, define ZNULLIND as

D ZNULLIND S 5I 0


hth,
Peter Dow
Dow Software Services, Inc.
909 793-9050

**



Doug Palme wrote:
They are the same size, as is the customer number, I thought of that earlier
and double checked those.


Here is what IBM says about 305:



SQL0305


Message Text:

Indicator variable required.


Cause Text:

A FETCH, an embedded SELECT, a CALL or a SET or VALUES INTO statement has
resulted in a null value, but an indicator variable was not specified for
host variable &2. The relative position of the host variable in the INTO
clause or parameter list is &1. If the host variable name is *N, an SQLDA
was specified.


Recovery Text:

Specify an indicator variable, and precompile the program again.


SQLCODE or SQLCODEs:

-305


SQLSTATE or SQLSTATEs:

22002 22004



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Arthur.Marino@xxxxxxxxxxxxxxxx
Sent: Wednesday, August 01, 2007 3:52 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: As much as I hate showing my own stupidity more than once a day
(I am flat out stuck) Embedded SQL


Of course, it would help if I knew what the status code -305 meant but, in
any case, I would cast the retrieved field to be the same size as the
'fetch' defines.

To wit:

SELECT cast(SUM(SLEXT$) as dec (9,2)) FROM SLSTRNL5 etc.


Arthur J. Marino





"Doug Palme" <dpalme@xxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx

08/01/2007 04:44 PM

Please respond to

RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>



To

"'RPG programming on the AS400 / iSeries'" <rpg400-l@xxxxxxxxxxxx>

cc


Subject

As much as I hate showing my own stupidity more than once a day ( I am
flat out stuck) Embedded SQL







I am reading a file and using the values within that file to create an SQL

that will go out and select a sum of sales figures for a particular

customer.




Here is the relevant SQL code:




C*---Prepare SQL Statement

C/EXEC SQL

C+ DECLARE C1 CURSOR FOR

C+ SELECT SUM(SLEXT$) FROM SLSTRNL5


C+ WHERE SLACCT= :CUSTNO

C+ AND SLTDAT > :ZBDATEN

C+ AND SLTDAT <= :ZEDATEN

C+ AND SLCLAS > 1

C+ AND SLSHRT = ' '

C/END-EXEC





I then open the cursor with the following:




C*---Open the Cursor


C/EXEC SQL

C+ OPEN C1

C/END-EXEC



I then am running a fetch statement with the following:




C*---Fetch the Result and place into Variable


C/EXEC SQL

C+ FETCH C1 INTO :ZSUM

C/END-EXEC



ZSUM is defined as an 9,2 on the D spec




Everything so far, at least to my eyes looks good...




However before I process that ZSUM data (output to a report) I check the

SQLCOD and I am getting a return code of -305..I have checked the
variables

that I am passing in, such as CUSTNO (defined on the D SPEC correctly),

ZBDATEN and ZEDATEN are also defined on the D SPEC correctly...so I have
no

clue what variable the system is balking at.




Any assistance would be appreciated.




Douglas








****************************************************************************

This transmission may contain information that is privileged,

Confidential and/or exempt from disclosure under applicable law.

If you are not the intended recipient, you are hereby notified that

any disclosure, copying, distribution, or use of the information

contained herein (including any reliance thereon) is STRICTLY

PROHIBITED. If you received this transmission in error, please

immediately contact the sender and destroy the material in its

entirety, whether in electronic or hard copy format. Thank you.

****************************************************************************


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.