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


  • Subject: RE: Converting QM Query to rpg embedded SQL
  • From: "Danny Rodius" <danny.rodius@xxxxxxxxx>
  • Date: Thu, 22 Feb 2018 14:11:47 +0100
  • Ironport-phdr: 9a23:AhKmOBVP7WDQtjTN2xLcRpClO/3V8LGtZVwlr6E/grcLSJyIuqrYbBSEt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KptVRTmijoINyQh/W/XlMJwgqBUrg+vqRJ8zIHbfI6bOv1ifq7GYdMXR2VBUtpPWyBdHI+xaZYEAeobPeZfqonwv1UCoxWkCgmqAuPuyiJDiGPx3aIn0uQhDBrG0AI9FN8JrXvbttP1NKESUOyv1qnIyijMb/JL2Tfm84XIaRMhoPGKXb1ubcrd01IgGB3cg1iWtIfrMTSV1uEXvGia6eptTe2ui2sjqwFqpTig3N8shpPOhoIPxVDJ8zhyzoUtJdCgVUJ2ZdGpHIFSuiyZLYd6X8MvTmJytCs1zLANpIS1czIQyJs9wh7Sc/mHc4+V7R39TOuROjJ4hG59eLK4mhay7VCsyu3iWcmw11ZHtiRLncPKtnAL1x3d8NaKRuN8/kenxzmPyxje5vxALE07j6bWKZ0szqQtmpcTsknPBCD7lF3zjKCMd0Uk/uao6/7gYrXjvpKTKpV7igf4MqUugMC/G+M4PRUPX2iG4uSxz6bj/U75QbVMkPI2jrPVv4vEKsgDvK62HxdV0po/6xa4FzqmyswYnXYIIV5ZZB6LlozpNkrLIPD5EPi/mU6jkDFkx//YJLHuHpLNLn2Q2IvmKPwy0XZzgBIpyt9F7pdRC7cOaPX1ElPxuZT5JDpxMkSAg8/cT4kljssXX27HA5SUKqLfqmvJqahnd/OUa9NN4HP5A/0k6+Tni3A031QaeP/684EQbSXyMv1gJVTRW33gg8oaWy9esgM4Sv2sklqOUCNIT22xTqQx+ncxBdT1Xs/4WomxjenZj2+AFZpMazUeBw==
  • List-archive: <https://archive.midrange.com/rpg400-l/>
  • List-help: <mailto:rpg400-l-request@midrange.com?subject=help>
  • List-id: "RPG programming on the IBM i \(AS/400 and iSeries\)" <rpg400-l.midrange.com>
  • List-post: <mailto:rpg400-l@midrange.com>
  • List-subscribe: <https://lists.midrange.com/mailman/listinfo/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=subscribe>
  • List-unsubscribe: <https://lists.midrange.com/mailman/options/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=unsubscribe>

Hi all,
And special to Lynne Noll after reading your response I started on a whole
new path.

Instead of a temp file I create a cursor now and fetch the record into a
clob variable.
This is working now.
So for those who want to play, the source of a test program:

**free
ctl-opt option(*nodebugio:*srcstmt) dftactgrp(*no) debug(*yes);

dcl-s packageID packed(11:0) inz(2398066);
dcl-s xmldta sqltype(clob:1024000);


exec sql
declare c1 cursor for
select xmlserialize(xmlelement(name "SOAP:Envelope",

xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/'
as "SOAP")
,
xmlelement(name
"SOAP:Body",
xmlelement(name
"ns0:DeliveredGoodsRequest",
xmlnamespaces('http://VDW.AS400.Schemas.DeliveredGoodsRequest'
as
"ns0")
, xmlelement(name "Company",
trim(aqsjce)), xmlelement(name
"UserID", trim(a9sqce)),
xmlelement(name "Username",
trim(a9fhts)),
xmlagg(xml_scalar)))) as clob(1m)
including xmldeclaration)
as xml_doc from
(select aqsjce,
a9sqce,
a9fhts,
xmlelement(name "Lines",
xmlagg(xmlelement(name
"DeliveryGoodsLines",
xmlforest(trim(char(ARBFPR,
'.')) as "CostPrice",
trim(artnce) as
"ItemID", trim(artoce)
as "ConfigID",
trim(arzsce) as
"InventTransID",
trim(char(ardoqt, '.'))
as "Qty", trim(aqzrce)
as "SalesID"))))
as xml_scalar
from (select *
from anaqrep
join anarrep on aqvvne
= arvvne
where aqvvne = :packageID)
as a
join ama9rep on aqvvne = a9vvne
where a9elsv < 90
group by aqsjce,
a9sqce,
a9fhts)
as b
group by aqsjce,
a9sqce,
a9fhts
for fetch only;


exec sql
open c1;

exec sql
fetch c1 into :xmldta;

return;


Results in:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/";>
<SOAP:Body>
<ns0:DeliveredGoodsRequest

xmlns:ns0="http://VDW.AS400.Schemas.DeliveredGoodsRequest";>
<Company>FMX</Company>
<UserID>EVRK</UserID>
<Username>VEREECKE ERIC</Username>
<Lines>
<DeliveryGoodsLines>
<CostPrice>.0000</CostPrice>
<ItemID>8-921-10103</ItemID>
<ConfigID>-</ConfigID>

<InventTransID>LOT0019783</InventTransID>
<Qty>20.00</Qty>
<SalesID>SO0001886_cmfx</SalesID>
</DeliveryGoodsLines>
</Lines>
</ns0:DeliveredGoodsRequest>
</SOAP:Body>
</SOAP:Envelope>

So got the result what we wanted.
Again thanks to all.

Danny

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Lynne
Noll
Sent: donderdag 22 februari 2018 12:05
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxx>
Subject: Re: Converting QM Query to rpg embedded SQL

I've seen the QMQRY utilities. They sparked my imagination. Giovanni
Perotti added the substitution marker idea as part of HTML scripts-- I saw
them before QMQRY. So many things need a few substitutions in a standard
script!


However, the main purpose of the QMQRY utilities was getting around the lack
of purchased SQL tools like embedded SQL in RPG.


I suggest building a simple RPG, COBOL or C utility to run the passed in
select statement. It is very simple as long as the SQL is composed to
return one field, which can be fields concatenated together. I have a
couple--one a universal lookup window, and one that just returns a field at
a time to a caller. Beyond letting you get data back to the caller without
an output table, you can have substitution markers in your own template SQL
string.


If you are going to an output table, you can use a CREATE TABLE AS command
to run the select from RUNSQL. No substitution markers, though; you need to
create a separate command to handle them.


You can set up for multiple variable columns back in your utility as well,
but that is more work. More payback, but more work, and needs a budget.
What I've described is super easy, and can be done as part of any project it
eases.



Sent from Outlook<http://aka.ms/weboutlook>


________________________________
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxx> on behalf of Vernon Hamberg
<vhamberg@xxxxxxxxxxxxxxx>
Sent: Wednesday, February 21, 2018 8:37 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Converting QM Query to rpg embedded SQL

To expand a little on Lynne's explanation, it is possible to have a QMQRY
string like this - &Q1&Q2&Q3&Q4&Q5 - this would allow an SQL statement up to
275 characters long, since each substitution variable can be at most 55
long. This is the basis of almost all the utilities people have made (Buck
Calabro had one I made a variation of, and
others) that can run any SQL statement, including SELECTs (IBM's RUNSQL does
not directly run SELECT statements). The statement is broken up into
55-character variables and passed in the SETVAR parameter of STRQMQRY, which
combines them into the statement, as Lynne describes.

I have a presentation and lab I present at COMMON about QM - usually the lab
is all we put on the schedule these days.

Regards
Vern




--

--
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:
http://amzn.to/2dEadiD


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.