|
Here is what I need:
insert into qtemp/wk_jcpordf (relid, relsq, uid)
select :relid, :relsq, a.iduid
from jcuidp a
join (select distinct idjyr, idjno, idbpth
from jcuidp
where iduid = :uid
and idstat = 'A') b
on (a.idjyr, a.idjno, a.idbpth) =
(b.idjyr, b.idjno, b.idbpth)
left exception join jcpordf c
on c.dpuid = a.iduid and c.pstat = 'A'
fetch first :qty rows only;
JCUIDP contains a map of serial numbers (iduid) with a reference to it's
location in a bill of materials (idbpth) for a job (idjyr, idjno). If a
part has a quantity of 5 at a particular location in the BOM, there will be
5 JCUIDF records with a unique serial number for each of the 5 parts.
JCPORF is a list of parts by UID that have been released for purchasing.
At any time, a partial quantity of the parts for a location in the BOM can
be released for purchasing. If I want to release 2 of these 5 parts, I want
to set qty = 2, and run this insert. This would insert two unreleased
serial numbers into the wk_ file. I can get the select to work with a
constant value, but not a variable. Unfortunately, the user needs to be
able to pick the quantity so it can't be a constant. I see the following
note in the SQL Reference:
Allowed use of variable: fetch-first-row-count can be specified as a
variable only as part of the outer fullselect of a DECLARE CURSOR statement
or a prepared select-statement.
So :qty can not be specified here in this insert. I need logic to get
around this limitation. I can do it in RLA, but the logic is complex, and I
prefer to keep it in SQL. Any ideas?
Mark Murphy
Atlas Data Systems
mmurphy@xxxxxxxxxxxxxxx
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-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 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.