@Paul & Brian
Please find the sql hereafter:
CREATE TABLE QTEMP/DELIVER AS (
with cte_hdr as (
SELECT * FROM anaqrep JOIN anarrep ON aqvvne = arvvne WHERE aqvvne = :PACK),
cte_hdr_all as (
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 cte_hdr JOIN ama9rep ON aqvvne = a9vvne
WHERE a9elsv < 90
GROUP BY aqsjce, a9sqce, a9fhts)
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 cte_hdr_all GROUP BY aqsjce, a9sqce, a9fhts
) WITH DATA
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Brian
Parkins
Sent: dinsdag 20 februari 2018 15:27
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxx>
Subject: Re: Converting QM Query to rpg embedded SQL
Danny, the &VAR is for runtime substitution in the CL command, STRQMQRY.
Depending on where it is used in the SQL statement, it may not be valid as a
host variable when embedded in an RPG IV program.
For example, a host variable cannot be used on the ORDER BY clause.
We need to see the SQL statement to be of more help.
Brian.
On 20/02/2018 12:45, Danny Rodius wrote:
Hello,
Have a QM query and want to convert it to embedded SQL.
However the SQL has a variable in it defined as &var.
When I change this to :var it gives me the error "host variable not
permitted here".
Any idea from where this comes? Why in the QM query its accepts the
variable but no in embedded SQL.
Any ideas?
Best regards
Danny
--
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.