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



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.

This thread ...

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.