× 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 all,

I am having an issue compiling my module with embedded SQL inside of
procedures that reference the incoming parameter of the procedure defined
as a likeds that points to an externally described datastructure based on a
null pointer.

Confused? Ya me too, let me explain...

BTW: This is on V5R4

The procedure accepts a data structure externally described as a physical
file as its only parameter. Since I cannot do an "e ds extname" in a
prototype or parameter interface definition, you must do it as a seperate d
spec then do a likeds() on your parameter definition. However when I do
this the SQL precompiler gives messages that the subfields of the parameter
that I am referencing are not defined or not usable.

I know of the problem in the precompiler having to do with scoping (it does
not see scope at all), but this doesn't appear to be related to that. When
I look at the compile listing I see that the externally described
datastructure is being defined. Here is a snippet:

FIELD1 35 TIME(8) IN MYDS
FIELD1 **** COLUMN
142
FIELD1 **** IN PR_REC
197

If it's defined in pr_rec according to whats above, then why does it also
say that it is not defined or usable?

MSG ID SEV RECORD TEXT
SQL0312 30 103 Position 39 Variable FIELD1 not defined or not usable.
SQL0312 30 104 Position 39 Variable FIELD2 not defined or not usable
SQL0312 30 105 Position 39 Variable FIELD3 not defined or not usable.

I have pasted in a simplified version of the module that illustrates my
issue. If anyone can offer any insight into this, I would greatly
appreciate it.



Here is a generalized version of the module source:
===================================================================


/if Not Defined (CpyMyModule)

**********************************************************************
* Program name: MyModule
* Program objective:
* Creation date: 12/07/2007
* Created by: RNewton
* Project #: 0000
* Project Desc:
*
* Procedures:
* Class_WriteToFile
*
* Programming Notes:
*
* Errors:
*

**********************************************************************
* Modifications

**********************************************************************
* Mod Date...........:
* Mod By.............:
* Project #..........:
* Mod Tag............:
* Mod Description....:

**********************************************************************
/EndIf

/if Defined (CpyMyModule)
// Structs
/////////////////////////////////
d myds e ds extname(MYFILE) based(struct)

// Public Procedures
/////////////////////////////////
d Class_WriteToFile...
d pr 30s 0
d pr_rec likeds(myds)

/EOF
/EndIf

// hSpecs
/////////////////////////////////
h nomain Option(*NoDebugIO : *SrcStmt : *ShowCpy : *xRef)

// Files To Use
/////////////////////////////////
// *NONE

/Define CpyMyModule
/include *libl/qrpglesrc,MyModule

// Define Global Constants
/////////////////////////////////
d true c *on
d false c *off

// Define Global Vars
/////////////////////////////////
d programStatus...
d esds extname(pgmesdslng)







//////////////////////////////////////////////////////////////////////
// PUBLIC PROCEDURES
//

//////////////////////////////////////////////////////////////////////


*---------------------------------------------------------------
* Name : ClassName_WriteToFile
* Description : Write a record into the MYFILE table
* Argument(s) : Externally described as MYFILE
* Return value : The primary key auto incremented by the database
* Usage : value = ClassName_WriteToFile(myLocalFile_ds);
*---------------------------------------------------------------

// BEGIN PROCEDURE
p Class_WriteToFile...
p b export

// Procedure Interface
//////////////////////////////////
d Class_WriteToFile...
d pi 30s 0
d pr_rec likeds(myds)

// Define Local Vars
//////////////////////////////////
d AutoIncValue s 30s 0

//Main
/free
exec sql
insert into MYFILE
(field1,
field2,
field3)
values
(:pr_rec.field1,
:pr_rec.field2,
:pr_rec.field3);

exec sql
values IDENTITY_VAL_LOCAL() into :AutoIncValue;

return AutoIncValue;
/end-free

p Class_WriteToFile...
p e
// END PROCEDURE


===================================================================





Robert Newton
EDPS
Electronic Data Processing Services
Software Engineer
rnewton@xxxxxxxxxxxxxxxxx

This communication is confidential and is intended to be privileged. If
there is a problem with this transmission, please contact the sender. If
the reader of this message is not the intended recipient, or the employee
or agent responsible to deliver it to the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.