Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Bruce Bramhall — — source: Informix-list mailing list archive (1991-1998)
I have a table that contains a hiearchy of items where where each record
references another record as its parent.
tableA
itemid parent
A A
B A
C A
D B
E B
F C
G C
I would like to print the relationships out in the form of a tree.
A
|--B
| |--D
| \\--E
|
\\--C
|--F
\\--G
I'm trying to use a cursor in a recursive function but keep running into
an error. The program compiles ok but returns the following error when ran.
$ fglgo prog.4goA
B
Program stopped at "prog.4gl", line number 16.
SQL statement error number -400.
Fetch attempted on unopen cursor.
# prog.4gl
1 database mydata
2
3 main
4 call showitem(A)
5 end main
6
7 function showitem(itemid)
8 define itemid like tableA.itemid,
9 childid like tableA.itemid
10
11 display itemid
12
13 declare child_cur cursor for
14 select itemid from tableA where parent = itemid
15
16 foreach child_cur into childid
17 call showitem(childid)
18 end foreach
19
20 end function
Does anyone have a suggestion?
Many thanks in advance,
Bruce Bramhall
bruce@tkg.com
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.