cat > script.ff <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
	program cr1
	integer error
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION ;
        character *25 name,date *20,amount *8
        character *25 pname,pdate *20,pamnt *8
        character *25 name1,date1 *20,amnt1 *8
EXEC SQL END DECLARE SECTION ;
EXEC SQL INIT;
EXEC SQL DATABASE IS "DATABASE";
EXEC SQL DECLARE c CURSOR FOR SELECT FROM loans  FOR UPDATE;
EXEC SQL OPEN c;
	if(SQLRET.NE.0) then
	error=1
	goto 10
	endif
	print *,'open c ok'
50	continue	
	pname = 'name'
	pdate = 'date'
	pamnt = 'amount'
	EXEC SQL FETCH c :pname,:pdate,:pamnt INTO :name,:date,:amount;
	if(SQLRET.EQ.0) then
	write (*,101) name,date,amount
 101    format (' ', A25, A20, A8)
	goto 60
	endif
	if(SQLRET.EQ.100) goto 60
	if(SQLRET.EQ.1) then 
	print *,' lock busy'
	goto 60
	endif
	error=2
	goto 10
60	if(SQLRET.EQ.0) goto 50
	EXEC SQL INSERT INTO loans SET name,date,amount VALUES "DATAWARE",
		:date,:amount;
	if(SQLRET.NE.0) then
	error=3
	goto 10
	endif
        print *,'insert ok'
	EXEC SQL CLOSE c;
	print *,'close c ok'
	EXEC SQL DECLARE d CURSOR FOR SELECT FROM loans where name="DATAWARE"
	FOR UPDATE;
	EXEC SQL OPEN d;
	if(SQLRET.NE.0) then
	error=4
	goto 10
	endif
	print *,'open d ok'
	EXEC SQL FETCH d name,date,amount INTO :name,:date,:amount;
	if(SQLRET.NE.0) then
	error=5
	goto 10
	endif
	print *,'select ok'
	EXEC SQL DELETE FROM loans WHERE CURRENT OF d;
	if(SQLRET.NE.0) then
	error=6
	goto 10
	endif
	print *,'delete ok'
	EXEC SQL CLOSE d;
	if(SQLRET.NE.0) then
	error=7
	goto 10
	endif
	EXEC SQL SELECT name,date,amount FROM loans INTO :name1,:date1,:amnt1 
	   WHERE name = "DATAWARE";
	if(SQLRET.NE.100) then
	error=8
	goto 10
	endif
	print *,'select 3 ok'
	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 c ok
Mosca                    2 February  1981    $150.00 
Jones                    7 February  1981    $33.95  
Kilroy                   16 February  1981   $250.00 
Wladislaw                27 February  1981   $55.00  
Jones                    3 April     1981    $25.00  
Mosca                    4 May       1981    $200.00 
Wladislaw                12 May       1981   $25.00  
Peterson                 6 June      1981    $50.00  
Wladislaw                25 June      1981   $75.00  
Jones                    12 August    1981   $300.00 
insert ok
close c ok
open d ok
select ok
delete ok
select 3 ok
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Cursor manipulation (1)
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
