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



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




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.