Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!jfh From: jfh@killer.UUCP (John Haugh) Newsgroups: comp.databases Subject: Re: Informix Brain Teaser Summary: Can't be done ... ... using ACE. Message-ID: <2830@killer.UUCP> Date: 13 Jan 88 17:31:18 GMT References: <2678@slovax.UUCP> Distribution: na Organization: Big "D" Home for Wayward Hackers Lines: 53 In article <2678@slovax.UUCP>, flak@slovax.UUCP (Dan Flak) writes: > Here's a brain teaser for you folks using Informix 3.30. (I can't > validate SQL since I don't have it). > > The schema looks like: > > database foo > > file family > > field name type character 20 index primary > field parent type character 20 index dups. > > end [ stuff deleted ] > The challenge: > > Write a progam using ACE and/or C which will accept as its > first argument the name of any ancestor, and produce a list of all > descendants for as many generations as are loaded in the database. > -- > Dan Flak-R & D Associates,3625 Perkins Lane SW,Tacoma,Wa 98499,206-581-1322 This is basically impossible in ACE. You can get N generations using N read statements. Watch - database people end define param[1] person type character length 20 end read into children parent, child = name where parent = person end { now I have the first generation } read into grandchildren children, grandchild = name joining children.child = optional parent { now I have the second } sort by parent, child, grandchild end format every record end To get the third generation you need a third read. It would look similiar to the second, except, the new field would be aliased to `greatgrandchild'. Just remember the 50 character limit on field names ;-). - John. -- John F. Haugh II SNAIL: HECI Exploration Co. Inc. UUCP: ...!ihnp4!killer!jfh 11910 Greenville Ave, Suite 600 "Don't Have an Oil Well? ... Dallas, TX. 75243 ... Then Buy One!" (214) 231-0993 Ext 260