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



The SQL is NOT "dynamically created"....

You're using static SQL.

And as the link Kevin posted mentions, IN (:mylist) doesn't work like that.

You could do IN (:val1, :val2, :val3,...) in static SQL.

Charles

On Tue, Dec 11, 2018 at 2:13 PM Fry, Kim <kfry@xxxxxxxxxx> wrote:

Maybe this might help with what I'm trying to accomplish and why I'm
trying to see how the SQL statement is being created.

The SQL is dynamically created using variables passed into the program.
We now want to include dwelling types which can accomplish with the IN
statement. But the dwelling types being passed into the program are
variable depending on the information needed for the selection.

I can make the SQL work just fine if I "hardcode" the line as such:
alblst in('R',T')
But where I'm running into the formatting issues is when I need to create
the IN statement using the variables passed into the program and using the
TRIM command.

When I try to use the variable along with the trim, I'm not getting the
results I need for the query.

I hope that the above information make sense.







-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dexter
Thompson
Sent: Tuesday, December 11, 2018 3:21 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Ability to see Embedded SQL Select Statement

Here's is what I do. At the beginning of the program I create a table in
QTEMP

exec sql
drop table qtemp/MySQL cascade ; // in case still there
from a previous run
exec sql
Create Table Qtemp/MySQL
(mysql_cmd char (5000) with default ' ') ;

Then when I build my statement in a work field for the Declare and Prepare
statements

Mysqlstmt = 'Select x, y, z from table1...... '

I then insert the field into my temp table.

exec sql
insert into qtemp/mysql (mysql_cmd)
values(:Mysqlstmtt ) ;

Now I have the exact statement built. The second advantage is you can copy
the statement from the qtemp file and execute it in ACS, WinSQL, etc to see
where it is failing.

Good luck.

On Tue, Dec 11, 2018 at 2:54 PM Tyler, Matt <matt.tyler@xxxxxxxxxxxxxx>
wrote:

You can start a DB monitor (best if done via Run SQL Scripts or the
performance center in ACS ), run the program and the inspect the DB
monitor. The executed statement should appear if you set up the DB
monitor
properly.

-Matt

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan
Campin
Sent: Tuesday, December 11, 2018 12:51 PM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Ability to see Embedded SQL Select Statement

Basically no. The declare statement is only an instruction to the
compiler.
It does not generate executable code. If you look at the RPG view in the
debugger you will see the code that is actually being executed.


On Tue, Dec 11, 2018 at 11:47 AM Fry, Kim <kfry@xxxxxxxxxx> wrote:

Hi everyone,

The program that I currently updating contains the following SQL
statement.

exec sql
DECLARE housesBefore CURSOR for
SELECT ALAJNB,
ALBHNB,
ALBFCD,
ALBGCD,
ALBKCD,
ALBLTX,
ALBMTX,
ALBNTX
FROM homrtv01
WHERE ((upper(ALBFCD) < :@AddrLoc) or
(upper(ALBFCD) = :@AddrLoc and
upper(ALBGCD) < :@Fraction) or
(upper(ALBFCD) = :@AddrLoc and
upper(ALBGCD) = :@Fraction and
upper(ALBKCD) <= :@Apartment)) and
upper(ALBHCD) = :@PreDirect and
upper(ALBITX) like '%' || trim(:@StrWord1) || '%' and
upper(ALBITX) like '%' || trim(:@StrWord2) || '%' and
upper(ALBITX) like '%' || trim(:@StrWord3) || '%' and
upper(ALBITX) like '%' || trim(:@StrWord4) || '%' and
upper(ALBITX) like '%' || trim(:@StrWord5) || '%' and
upper(ALBJTX) = :@City and
upper(ALBICD) = :@State and
ALBTST = ' '
ORDER BY upper(ALBFCD) desc,
upper(ALBGCD) desc,
upper(ALBKCD) desc;


exec sql open housesBefore;

dou sqlstt <> '00000';

exec sql
fetch housesBefore into :houseData;

if sqlstt = '00000';


The SQL statement works correctly, but I need to add additional
selection criteria information into it but I've been encountering
issues with the formatting of the select statement and was wondering
if there is a way through debug to see the actual SQL statement that
is being created so that I can determine where the formatting problem
is
so that I can fix it.

I'm using STRDBG command to view the variables in the program.


I've worked on SQLRPGLE programs where I've build the select statement
from scratch and then declared it to a cursor. For example:
Prepare sel from :selectStmt
Declare c1 cursor for sel


With this method I was able to debug my SQL statement that was built
by using the EVAL on the selectStmt variable.

Any help on how to display the select statement that is being built
without having to update the current program to move the select builds
into a variable would be appreciated.

Thank you

_____
Kimberly Fry


--
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:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.co
m_mailman_listinfo_rpg400-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPv
SZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9L
aPAffkNhxK79YQ2SWnU_dkdD2Zwocill7HPE&s=Dh38sRzpyJM5w40Qgv6MUR7PhQesAaA
ma3Rjqgwpk2E&e= or email: RPG400-L-request@xxxxxxxxxxxx Before
posting, please take a moment to review the archives at


https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_rpg400-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9LaPAffkNhxK79YQ2SWnU_dkdD2Zwocill7HPE&s=xRnaGYqdepCfAA2Dlz0UnZ5QuAhne9Ax5GgqOrT4a7Q&e=
.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:
https://urldefense.proofpoint.com/v2/url?u=https-3A__amazon.midrange.c
om&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8
HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9LaPAffkNhxK79YQ2SWnU_dkdD2Zw
ocill7HPE&s=QLXqhYWPoPPMBHUkoAk5kD796-o9XiwK2Udab1vtL10&e=

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

https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_rpg400-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9LaPAffkNhxK79YQ2SWnU_dkdD2Zwocill7HPE&s=Dh38sRzpyJM5w40Qgv6MUR7PhQesAaAma3Rjqgwpk2E&e=
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at

https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_rpg400-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9LaPAffkNhxK79YQ2SWnU_dkdD2Zwocill7HPE&s=xRnaGYqdepCfAA2Dlz0UnZ5QuAhne9Ax5GgqOrT4a7Q&e=
.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:

https://urldefense.proofpoint.com/v2/url?u=https-3A__amazon.midrange.com&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=nF4xh9LaPAffkNhxK79YQ2SWnU_dkdD2Zwocill7HPE&s=QLXqhYWPoPPMBHUkoAk5kD796-o9XiwK2Udab1vtL10&e=
--
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: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--

*Dexter Thompson*
Software Engineer, iSeries Applications Support and Development

[image: Inmar]
<
https://www.inmar.com/?utm_source=email%20signature&utm_medium=email&utm_campaign=Associate%20Email%20Signature&utm_content=Inmar%20Logo


dexter.thompson@xxxxxxxxx
635 Vine Street, Winston Salem, NC 27101
*p: *555-555-5555 | *c: *123-123-1234 | *f: *123-456-7890
www.inmar.com
<
https://www.inmar.com/?utm_source=email%20signature&utm_medium=email&utm_campaign=Associate%20Email%20Signature&utm_content=URL%20link

| LinkedIn <https://www.linkedin.com/company/inmar> | Facebook
<https://www.facebook.com/inmarinc> | Twitter
<https://twitter.com/inmarinc>

--


********************************************





*Inmar Confidentiality
Note*: This e-mail and any attachments are confidential and intended to
be
viewed and used solely by the intended recipient. If you are not the
intended recipient, be aware that any disclosure, dissemination,
distribution, copying or use of this e-mail or any attachment is
prohibited. If you received this e-mail in error, please notify us
immediately by returning it to the sender and delete this copy and all
attachments from your system and destroy any printed copies. Thank you
for
your cooperation.





*Notice of Protected Rights*: The removal of any
copyright, trademark, or proprietary legend contained in this e-mail or
any
attachment is prohibited without the express, written permission of Inmar,
Inc. Furthermore, the intended recipient must maintain all copyright
notices, trademarks, and proprietary legends within this e-mail and any
attachments in their original form and location if the e-mail or any
attachments are reproduced, printed or distributed.




********************************************
--
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: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
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: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


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.