cat > script.cc <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
#include	<mscc.h>
#include <stdlib.h>
void	error	(int	i);
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION ;
char name[25],date[21],amount[9],crelim[9];
long phone;
EXEC SQL END DECLARE SECTION ;
int	main (int argc, char** argv)
{
EXEC SQL INIT;
EXEC SQL DATABASE IS "TEST_DATABASE";
EXEC SQL OPEN_TABLE loans FOR READ;
if(SQLCODE != 0) error(0);
printf("open 1 ok\n");
EXEC SQL OPEN_TABLE personnel FOR READ;
if(SQLCODE != 0) error(1);
printf("open 2 ok\n");
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(SQLCODE != 0) error(2);
printf("select ok\n");
printf ("%s  %s  %s  %ld  %s\n",name,date,amount,phone,crelim);
EXEC SQL CLOSE_TABLE ;
EXEC SQL EXIT ;
return 0;
}
void	error (int	i)
{
	printf("error number %d\n",i);
	printf("SQLCODE number %ld\n",SQLCODE);
	exit(1);
}
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script.cc
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
open 1 ok
open 2 ok
select ok
Kilroy  16 February  1981  $250.00  4269681  $500.00
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Select statement (1 line , 2 tables)
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
