En cours

MYSQL recursive loop through 2 tables in an infinite loop

Please create the MYSQL code to combine 3 tables recursively so that we can go at least 1,000 levels deep.

Essentially, we’re expanding the Bill of Materials. So, the ProdOrderRes table has the first level materials required to build the order. Then we check the Bill of materials using MAST and STPO over and over until we get to the end of the BOM and there are no more materials, basically down to the last screw.

I would do this by doing select loops on a table and then appending to that table. But, you can do it however it works. You will end up with a long table that has the order, the material(matnr), plant(werks), the quantity needed (bdmng), and BOM level.

I would write this in ABAP as follows, but I don’t know MYSQL well enough.

Select *

Into table t_header

from ProdOrderRes.

***first lines are all level one

loop at t_header assigning <head>.

<head>-level = ‘1’.

Endloop.

loop at t_header assigning <head>.

If <head>-matnr is not initial.

Sel_matnr = <head>-matnr.

Else.

***this is only for the level one materials.

Sel_matnr = <head>-plnbez.

Endif.

Select stlnr

into bom_stlnr

from mast

where matnr = sel_matnr

and werks = <head>-werks.

Select idnrk pswrk menge

Into next_matnr, next_werks, next_menge

From stop

Where stlnr = bom_stlnr.

Wa-aufnr = <head>-aufnr.

Wa-auart = <head>-auart.

Wa-autyp = <head>-autyp.

Wa-werks = next_werks.

Wa-matnr = next_matnr.

Wa-gamng = next_menge.

Wa-level = <head>-level + 1.

Append wa to t_head.

Endselect.

Endselect.

Endloop.

MYSQL attempt:

Only do this the first level

select aufnr, auart, autyp, werks, ktext, gltrs, GSTRS, GSTRI, PLNBEZ, gamng, ReqMat, ReqPlant, ReqQty, posnr

from prodorderreq;

update td1 set reqmat = plnbez;

update td1 set reqplant = werks;

Then loop through infinite times until there is no match in MAST or STPO.

select [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view] as reqmat, [url removed, login to view] as reqplant, [url removed, login to view]

from td1 t

join mast m

on [url removed, login to view] = [url removed, login to view]

and [url removed, login to view] = [url removed, login to view]

join stpo p

on [url removed, login to view] = [url removed, login to view]

INSERT INTO td1 (reqmat,reqplant) VALUES([url removed, login to view],[url removed, login to view])

endselect;

Compétences : MySQL

Voir plus : sql query tree structure mysql recursive, webbrowser readystate infinite loop loading, appointment tables mysql, webbrowser completed infinite loop, jfoldercreate infinite loop detected warning failed move file, convert xml tables mysql, joomla easycreator problem install infinite loop, infinite loop install extensions joomla, mysql recursive table parent child, osc optimize tables mysql, move database tables mysql, basic example infinite loop, flash php mysql scroll text loop, loop tables mysql

Concernant l'employeur :
( 3 commentaires ) Woodland Hills, United States

N° du projet : #12640045

Décerné à :

nojnish

Hi, I have 15+ years experience in SQL development. in the past in one of my projects I have worked with Bill of material, explosion of bill of material for product requirement analysis in production planning of the Plus

180 $ USD en 5 jours
(0 Commentaires)
0.0

14 freelance ont fait une offre moyenne de 175 $ pour ce travail

shihan033010

A proposal has not yet been provided

222 $ USD en 5 jours
(235 Commentaires)
6.5
scriptphp87

Hello, I'm a professional programmer for web programming with php language to build the system website, Besides, I'm also expert in MySQL , HTML,HTML5,CSS, JS I'm always top in Vietnam freelancer [url removed, login to view] Plus

222 $ USD en 7 jours
(97 Commentaires)
7.2
stevecorsi

Lets do it ? Please see my profile for similar work. Thanks

210 $ USD en 2 jours
(25 Commentaires)
5.7
extreamcode

HI, I can assist you with this site. Here is a sampling of the few of my work contained at my portfolio: [url removed, login to view] I highly value professionalism and hold myself strictly accountable to Plus

246 $ USD en 11 jours
(4 Commentaires)
5.8
155 $ USD en 3 jours
(3 Commentaires)
4.9
vinaysinghh

I am mysql dba having more then 10 yrs of experience

111 $ USD en 2 jours
(23 Commentaires)
4.6
155 $ USD en 3 jours
(13 Commentaires)
3.7
davedcb

Hello, I am interested in your project. I am a software engineer and I have professional experience with MySQL. Thank you, Best regards, David

100 $ USD en 3 jours
(17 Commentaires)
3.4
222 $ USD en 2 jours
(3 Commentaires)
2.4
200 $ USD en 3 jours
(1 Commentaire)
2.6
BahadirWebMobil

hi, i have very good experience about mysql recursive queries. i can easily create query for you. i worked recursive categories before.

111 $ USD en 3 jours
(0 Commentaires)
0.0
277 $ USD en 5 jours
(0 Commentaires)
0.0
sambo2000

I have been using various databases for over 10 years, and MySQL for the last 5. Would you be able to send me a database dump? That would make it easier for me to test. It would be helpful if your field names were i Plus

150 $ USD en 7 jours
(0 Commentaires)
0.0
110 $ USD en 5 jours
(0 Commentaires)
0.0