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



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

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.