Create the databases and tables
Create the databases and tables before compiling the samples.
To create the databases, use the usual method for the database product, for example:DB2 CREATE DB MQBankDB DB2 CREATE DB MQFeeDB
Create the tables using SQL statements as follows:
In C:EXEC SQL CREATE TABLE MQBankT(Name VARCHAR(40) NOT NULL, Account INTEGER NOT NULL, Balance INTEGER NOT NULL, PRIMARY KEY (Account)); EXEC SQL CREATE TABLE MQBankTB(Name VARCHAR(40) NOT NULL, Account INTEGER NOT NULL, Balance INTEGER NOT NULL, Transactions INTEGER, PRIMARY KEY (Account)); EXEC SQL CREATE TABLE MQFeeTB(Account INTEGER NOT NULL, FeeDue INTEGER NOT NULL, TranFee INTEGER NOT NULL, Transactions INTEGER, PRIMARY KEY (Account));In COBOL:
EXEC SQL CREATE TABLE MQBankT(Name VARCHAR(40) NOT NULL, Account INTEGER NOT NULL, Balance INTEGER NOT NULL, PRIMARY KEY (Account)) END-EXEC. EXEC SQL CREATE TABLE MQBankTB(Name VARCHAR(40) NOT NULL, Account INTEGER NOT NULL, Balance INTEGER NOT NULL, Transactions INTEGER, PRIMARY KEY (Account)) END-EXEC. EXEC SQL CREATE TABLE MQFeeTB(Account INTEGER NOT NULL, FeeDue INTEGER NOT NULL, TranFee INTEGER NOT NULL, Transactions INTEGER, PRIMARY KEY (Account)) END-EXEC.Enter data into the tables using SQL statements as follows:
EXEC SQL INSERT INTO MQBankT VALUES ('Mr Fred Bloggs',1,0); EXEC SQL INSERT INTO MQBankT VALUES ('Mrs S Smith',2,0); EXEC SQL INSERT INTO MQBankT VALUES ('Ms Mary Brown',3,0); ⋮ EXEC SQL INSERT INTO MQBankTB VALUES ('Mr Fred Bloggs',1,0,0); EXEC SQL INSERT INTO MQBankTB VALUES ('Mrs S Smith',2,0,0); EXEC SQL INSERT INTO MQBankTB VALUES ('Ms Mary Brown',3,0,0); ⋮ EXEC SQL INSERT INTO MQFeeTB VALUES (1,0,50,0); EXEC SQL INSERT INTO MQFeeTB VALUES (2,0,50,0); EXEC SQL INSERT INTO MQFeeTB VALUES (3,0,50,0); ⋮Note: For COBOL, use the same SQL statements but add END_EXEC at the end of each line. Parent topic: Database coordination samples