First, Thank you.
I'm trying to avoid my typical use of an SQL cursor in a program to loop through
data to get document numbers for sales commissions (my project for today).
Here's a (crude) example of my goal:
-- Load Document # file using SQL Function libf/docfunc
INSERT INTO liba/doc#file
SELECT loc, petable.enddate, outlet,
SET docnum = docfunc(:loc, :outlet, :enddate)
FROM libb/sales JOIN libx/petable
ON sales.year = petable.year
AND sales.period = petable.period
GROUP BY petable.enddate,loc,outlet
ORDER BY 1,2,3
;
From what I know, SET cannot be used this way.
My read of the 7.1 SQL reference says SET is only used to set a host variable ?
SQL Function docfunc returns a Document Number given: Location, Outlet and Fiscal Period End Date
Document Number identifies a structure containing sales commission detail for a fiscal period.
petable stores fiscal period detail
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Wednesday, September 10, 2014 4:53 AM
To: Midrange Systems Technical Discussion
Subject: Re: Limits of SQL SET variable
Let's begin with the end in mind. What is it you are trying to do?
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From: Gary Thompson <gthompson@xxxxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 09/10/2014 01:40 AM
Subject: Limits of SQL SET variable
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>
My limited experience using SET and reading DB2 for i SQL Reference 7.1
leads me to conclude SET can only update the value of a 'host' variable ?
And that SET cannot be used within an SQL Select ?
But, maybe, can be used within an embedded SQL Select where SET is
in a subselect or common table expression ?
As an Amazon Associate we earn from qualifying purchases.