Alan,
That is just a test program. My actual program does something very
different. While I was working on the actual program, I've noticed that
when LIKEREC is used as PI, SQL precompiler somehow get all confuse.
That prompted me to write this test program.
This thread is actually about SQL precompiler not recognizing LIKE
keyword after seeing a LIKEREC.
There is another thread where I indicate runtime not working correctly
when using field in a LIKEREC data structure as host variable.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Campin
Sent: Monday, May 12, 2008 7:52 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL precompile not function correctly when likerec is used as
PI
<snip>
* setC1Result
D setC1Result...
D pr
D piMyFile likerec(MYFILE00) const
D piField1 like(FIELD1) const
D piField2 like(FIELD2) const
/free
setC1Result(piMyFile :'A' :'B');
*inlr = *on;
/end-free
**********************************************************************
* setC1Result
**********************************************************************
**********************************************************************
P setC1Result...
P B
D pi
D piMyFile likerec(MYFILE00) const
D piField1 like(FIELD1) const
D piField2 like(FIELD2) const
C/exec sql
C+ declare myfileC1 scroll cursor for
C+ select
C+ field1, field2
C+ from myfile
C+ where field1 = :piField1 and
C+ field2 = :piField2
C/end-exec
C/exec sql
C+ open myFileC1
C/end-exec
C/exec sql
C+ fetch from myFileC1
C+ into :C1Result
C/end-exec
</snip>
Not sure your problem has anything to do with the LikeRec and the PI.
You are passing the data structure to your procedure but never doing
anything with it. The data is being loaded into a global variable that
you declared so nothing is done with the piMyFile variable.
I think that your problem is using the Like keyword. I think what it is
getting upset about is that the fields definitions are coming from a
table.
Try just defining the fields and see if it works.
If your idea is to return the data from caller, why not use a return
value?
Also, why use a fetch when you are returning only a single record. Much
simpler to just use a Select Into.
d TD_MyFile...
d ds Qualified
d Based(StdNulPtr)
d Field1...
d Like(FIELD1)
d Field2...
d Like(FIELD2)
d MyFile...
d ds LikeDs(TD_MyFile)
/Free
MyFile = SetC1('A':'B');
/End-Free
P SetC1...
P b
D pi LikeDs(TD_MyFile)
D InField1...
D 1a
D InField2...
D 1a
D dsFileIn...
D ds LikeDs(TD_MyFile)
/Free
Exec Sql Select Field1, Field2
Into :dsFileIn
From MyFile
Where Field1 = :InField1 And
Field2 = :InField2;
Return dsFileIn;
/End-Free
p e
--
This is the RPG programming on the AS400 / 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.