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



It's the quotes, and too much reliance on RDi telling me when syntax is incorrect. Not too sure what you mean about EXTNAME not being the last statement in the dcl-ds.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx


-----JOSE PEREZ <joseenocperez@xxxxxxxxx> wrote: -----
To: "RPG programming on the IBM i \(AS/400 and iSeries\)" <rpg400-l@xxxxxxxxxxxx>
From: JOSE PEREZ <joseenocperez@xxxxxxxxx>
Date: 07/24/2015 01:41PM
Subject: Re: RE: Host variable definition for embedded SQL

Like this for example.


Dcl-ds Emailfile Extname('EMAILFILFL') ;

End-ds ;



Dcl-ds DatefldA ;

YYYY Char(4) Pos(1) ;

YY Char(2) Pos(3) ;

MM Char(2) Pos(5) ;

DD Char(2) Pos(7) ;

Ecl-ds Emailfile Extname('EMAILFILFL') ;

End-ds ;



Dcl-ds DatefldA ;

YYYY Char(4) Pos(1) ;

YY Char(2) Pos(3) ;

MM Char(2) Pos(5) ;

DD Char(2) Pos(7) ;


Note that extname is between quotes and is not the last statement in my dcl-xx section




Sent from Yahoo Mail on Android

From:"Kurt Anderson" <Kurt.Anderson@xxxxxxxxxxxx>
Date:Fri, Jul 24, 2015 at 12:18 pm
Subject:RE: Host variable definition for embedded SQL

I believe when using freeform declarations, ExtName literals must have quotes around them (and capitalized).

So try:
// Field Reference File
dcl-ds jcfldr_t ExtName('JCFLDR') Qualified Template;
end-ds;

Instead of:
// Field Reference File
dcl-ds jcfldr_t ExtName(jcfldr) Qualified Template;
end-ds;

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

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Mark Murphy/STAR BASE Consulting Inc.
Sent: Friday, July 24, 2015 11:44 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Host variable definition for embedded SQL

I have also tried taking QUALIFIED off, and get the same issue.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx


-----"Mark Murphy/STAR BASE Consulting Inc." <mmurphy@xxxxxxxxxxxxxxx> wrote: -----
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-l@xxxxxxxxxxxx>
From: "Mark Murphy/STAR BASE Consulting Inc." <mmurphy@xxxxxxxxxxxxxxx>
Date: 07/24/2015 11:32AM
Subject: Host variable definition for embedded SQL

I am trying to avoid redefining things multiple times, but am having no luck with the SQL precompiler. I have my field reference file defined in a common definitions copy book. I also have a separate copy book to hold prototypes for my module, this copy book includes the common definitions copy book. The module contains procedures that define host variables using Like. The definitions are proper for RPG, but not sufficient for SQL. How can I do this a better way? The documentation for embedded SQL says the EXTNAME should work, as long as it doesn't use the third parameter. I am still having trouble with that though. Here are my definitions:

@DTACOM_

// Only define these once
/if defined(@DTACOM)
/eof
/endif

/define @DTACOM

...

// Field Reference File
dcl-ds jcfldr_t ExtName(jcfldr) Qualified Template;
end-ds;


@EMPCOM_

/copy qilesrc,@dtacom_

dcl-pr GetEmployeeName Like(jcfldr_t.ename);
empno Like(jcfldr_t.empno) const;
end-pr;

dcl-pr GetDefaultEmployeeForMachine Like(jcfldr_t.mdempno);
empno Like(jcfldr_t.micno) const;
end-pr;


@EMPCOM

ctl-opt Option(*SrcStmt : *NoDebugIo) DatFmt(*ISO)
NoMain;
*-------------------------------------------------------------------------------------
* Common Employee Procedures
*-------------------------------------------------------------------------------------

/copy qilesrc,@empcom_
/copy qilesrc,@msgcom_

exec sql set option sqlca = *no,
commit = *none,
datfmt = *iso;


// ---------------------------------------------------------------------
// GetEmployeeName
// Returns the employee name for the provided employee number
//
// Parameters
// empno - Input - Employee Number
// ---------------------------------------------------------------------
dcl-proc GetEmployeeName Export;
dcl-pi *n Like(jcfldr_t.ename);
empno Like(jcfldr_t.empno) const;
end-pi;

dcl-s name Like(jcfldr_t.ename) Inz('');
dcl-s message Like(@msgcom_t.SqlDiagnostics) Inz('');

exec sql
select ename
into :name
from jcempf
where empno = :empno;
if %subst(SqlState:1:2) > '02';
exec sql get diagnostics condition 1
:message = message_text;
SndSqlMsg('@EMP01: ' + message);
endif;

return name;
end-proc;


// ---------------------------------------------------------------------
// GetEmployeeName
// Returns the employee name for the provided employee number
//
// Parameters
// empno - Input - Employee Number
// ---------------------------------------------------------------------
dcl-proc GetDefaultEmployeeForMachine Export;
dcl-pi *n Like(jcfldr_t.mdempno);
micno Like(jcfldr_t.micno) const;
end-pi;

dcl-s mdempno Like(jcfldr_t.mdempno) Inz(0);
dcl-s message Like(@msgcom_t.SqlDiagnostics) Inz('');

exec sql
select mdempno
into :mdempno
from jcmcmx
where micno = :micno;
if %subst(SqlState:1:2) > '02';
exec sql get diagnostics condition 1
:message = message_text;
SndSqlMsg('@EMP02: ' + message);
endif;

return mdempno;
end-proc;


So what does the manual mean by: "The precompiler supports EXTNAME, but does not support EXTNAME(filename : fmtname : fieldtype), where fieldtype is *ALL, *INPUT, *OUTPUT, or *KEY."

It sounds pretty clear to me, but I must be missing something since I get errors on :name, :empno, :mdempno, and :micno.
Same error for each field: SQL0312: Position <20 or 29> Variable <fieldname> not defined or not usable.

When I look at the SQL Precompiler listing cross-reference the fields look like this:
CROSS REFERENCE
Data Names Define Reference
EMPNO 430 440
MDEMPNO 463 468
MICNO 460 470
NAME 433 438

The odd thing about this is that id doesn't tell how these fields were defined, just where they are defined, and jcfldr_t is not listed in the cross-reference, though I can see in the source listing that it is being included. In my compile command, RPGPPOPT(*LVL2) is set. I have tried with and without TEMPLATE.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
--
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.


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


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.