Who can build a select-statement for that ?
Posted in 1992
Topics: SQL Development & Query Writing
Hi SQL-Freaks, I've got a complicated problem with SQL: I've got to tables : a) article : - artnr .... b) relatedarticle -artnr -relatedartnr -factor .... The sense is: If the user writes an invoice for an article, let's say a PC, he automatically gets another position, lets say a serial-port and maybe another position, lets say a VGA-Card automatically. In this case if my tables look like: article ------------ (artno) PC .... SERIALPORT FLOPPYDRIVE relatedarticle ------------ (artno) (relatedartno) (factor) PC VGACARD 1 PC SERIALPORT 2 PC FLOPPYDRIVE 2 SERIALPORT DB25CABLE 1 If i write an invoice and simply enter PC I get the following invoice : Items article 2 PC 2 VGACARD 4 SERIALPORT 4 DB25CABLE 4 FLOPPYDRIVE This works perfectly. But: If some crazy secretary will define a 'PC' as a related article for a 'FLOPPYDRIVE', I get an endless invoice because of recursion. So what I need is an SQL-select statement that allows to detect, wether there is recursion in the definition of related articles. Has anybody an idea ? -- Origin: It's not a bug, it's a feature !