× 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.



This may be OS level and/or PTF based, but if that restriction was true at one point, it's not true at v7r2 (or at least with the PTFs we have installed.

I put oBatch into another procedure as well as into the mainline, each with different definitions, and the SQL precompiler didn't have a problem with getBatchNo's oBatch. Unfortunately I don't have any other ideas as to what the problem is beyond possibly incorrect freeform specs (missing an end somewhere?)

Kurt Anderson
Sr. Programmer/Analyst - Application Development, Service Delivery Platform

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Charles Wilt
Sent: Wednesday, January 20, 2016 9:07 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: SQL0314 Error - Host Variable Not Unique

IIRC, the pre-compiler needed a unique name.

You can't re-use the same local names in multiple procedures.

Charles

On Wed, Jan 20, 2016 at 7:27 AM, Jonathan Mason <Jonathan.Mason@xxxxxxxxxxx>
wrote:

I am trying to compile an RPG program that contains the sub-procedure
shown below and am getting an SQL0314 error saying that host variable
OBATCH is not unique. Originally the variable was called wBatch which
was also defined globally, so despite the v7r2 SQL manual saying that
the pre-compiler copes with the different variable scopes correctly I
changed the name to be on the safe side. However, no matter what I
change the name to I always get the SQL0314 error.

If I move the declaration to the mainline code and make the scope
global then the pre-compiler is happy and no error is generated. It
seems to me that if I have to declare the variable globally then I may
as well either use a subroutine instead of a sub-procedure or change
the sub-procedure to use native I/O instead. I have checked with our
technical support guys and they have confirmed that we are 7.2 with
cume 115310 and latest group and HIPER PTF's applied.

Any ideas/suggestions would be most welcome.

Thanks
Jonathan



Dcl-Proc GetBatchNo;

// Procedure Interface...
Dcl-pi GetBatchNo Packed(8);
iProduct Char(3) Const;
End-pi;

// Work Variables...
Dcl-s oBatch Packed(8) Inz(*Zeros);

// Retrieve the last batch number for the current date...
Exec Sql
select max(ptbchn)
into :oBatch
from acaptrn
where ptbchn >= ((((year(current date) - 1900) * 1000) +
dayofyear(current date))
* 100)
and ptcode = :iProduct;

// If there have been no batches today then the batch number
should
// be generated in the form CYYDDDnn...
If oBatch = *Zeros;
Exec Sql
select (((year(current date) - 1900) * 1000) + dayofyear(current
date))
* 100 + 1
into :oBatch
from sysibm.sysdummy1;
Else;

// Otherwise batches exist so increment to get the next one.
Not too
// worried about there being more than 99, if there are
then the day
// number will increment as well to cater for it...
oBatch = oBatch + 1;
EndIf;

// Return the generated batch number to the calling procedure...
Return oBatch;

End-Proc;


________________________________
Proud partner of The Ageas Bowl and the Ageas Salisbury International
Arts Festival.

Registered Address: Ageas House, Hampshire Corporate Park, Templars
Way, Eastleigh, Hampshire, SO53 3YA Registered Number: 354568 England

Authorised by the Prudential Regulation Authority and regulated by the
Financial Conduct Authority and the Prudential Regulation Authority

This e-mail together with any attachments are intended for the
addressee only and may be private and confidential. If you are not the
intended recipient, or the person responsible for delivering it to the
intended recipient, you must not open any attachments, or copy,
disclose, distribute, retain or use this e-mail, including any
attachments, in any way whatsoever; please return it to us immediately
using the reply facility on e-mail.

Consider the environment and think before you print this email.
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

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.