cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
parameters
	char	dbname;
end

let database = dbname;

select name, number from customers sort by number;
	for each group of number becomes context outer
		print "---", newline;
		for each record
			print name, "  ", number, newline;
			select description from jobs, worked
				where customer_no = 'var.number' and 
				      jobs.job_no = worked.job_no;
				for each record
					print "     ", description, newline;
					for each record in context outer
						print	column 30,
							name, "   ",
							number,
							newline;
					end;
				end;
			end;
		end;
	end;
end;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 755 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
---
Mr. R. Lucas  1
---
Mrs. B. Hooper  2
     Sparks & tune
                             Mrs. B. Hooper   2
---
Mr. J. Phillips  3
---
Mr. B. Wilson  4
     Bent Rear Fender
                             Mr. B. Wilson   4
---
Miss C. Marshall  5
     Replace rear wheel
                             Miss C. Marshall   5
     Wheel alignment
                             Miss C. Marshall   5
     Bent door
                             Miss C. Marshall   5
---
Mrs. H. Watson  6
     Lube and grease
                             Mrs. H. Watson   6
     Tire repair
                             Mrs. H. Watson   6
     Sparks & tune
                             Mrs. H. Watson   6






































+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
A script containing nested select statements where the context of
a for group of the outer one is used by a for each inside the inner one.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
