cat > script.ff <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
	program sel3
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION ;
	character *25 name,date *20,amount *6,crelim *6
	integer*SIZE_OF_C_LONG phone
EXEC SQL END DECLARE SECTION ;
	integer error
EXEC SQL INIT;
EXEC SQL DATABASE IS "DATABASE";
EXEC SQL OPEN_TABLE loans FOR READ;
	if(SQLRET.NE.0) then
	error=0
	goto 10
	endif
	print *,'open 1 ok'
EXEC SQL OPEN_TABLE personnel FOR READ;
	if(SQLRET.NE.0) then
	error=1
	goto 10
	endif
	print *,'open 2 ok'
EXEC SQL SELECT 
    loans.name,loans.date,loans.amount,personnel.phone,personnel.credit_limit 
FROM loans,personnel INTO :name,:date,:amount,:phone,:crelim
   WHERE loans.name = "Kilroy" and loans.name=personnel.name;
	if(SQLRET.NE.0) then
	error=2
	goto 10
	endif
	print *,'select ok'
	write (*,101) name,date,amount,phone,crelim
 101    format (' ', A25, A20, A8, '  ', I7, '  ', A6)
EXEC SQL CLOSE_TABLE ;
EXEC SQL EXIT ;
	stop
10	print *,'error number ',error
	print *,'SQLRET number ',SQLRET
EXEC SQL EXIT ;
	stop
	end
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script.ff
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
open 1 ok
open 2 ok
select ok
Kilroy                   16 February  1981     $250.0  4269681  $500.0
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Select statement (1 line , 2 tables)
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
