0

Basically I have an exam coming up in Database Design, and one of our main topics is embedded SQL. This is the only example I was given, however with 0 explanation I pretty much have a hard time trying to figure out what is going on, if I knew what language it was written in I could atleast find a reference manual for help.

var
    StaffNum: string[5];
    FirstName, LastName: string[12];
    Address: string [60];
    Telephone: string[12];
EXEC SQL
    INCLUDE SQLCA
END EXEC
begin
EXEC SQL
    LOGIN localhost, 'scott' , 'tiger'
END EXEC
if SQLCODE <> 0 then
begin
    display ('Illegal login attempted - program terminating');
exit
end;

display ('Enter Staff Number of Interest');
accept (StaffNum);
EXEC SQL
    SELECT Fname, Lname, Address, Tel_No
    INTO :FirstName, :LastName, :Address, :Telephone
    FROM STAFF
    WHERE Sno = :StaffNum
END EXEC
if SQLCODE <> 0 then
begin
    display ('Invalid Staff Number Entered: ', StaffNum)
end
else
begin
    display ('Name: ', FirstName, ' ', LastName);
    display ('Home Address: ', Address);
    display ('Phone Number: ', Telephone)
end;
EXEC SQL
LOGOFF
END EXEC
end.

Any idea would be greatly appreciated!

Edit: I know what the general program does, but questions that come up are along the lines of "what is the 'Include' used for, or what are the possible values for SQLCODE etc.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
E. Young
  • 11
  • 2

2 Answers2

0

I think it may be written in Pascal.

attempt0
  • 639
  • 5
  • 14
0

COBOL

SQL Communications Area (SQLCA)

Every COBOL program containing embedded SQL must have an SQL Communications Area (SQLCA) or the field SQLCODE defined in its Working-Storage Section. This definition is normally accomplished by including the SQLCA copybook provided with your COBOL system. A complete description of the SQLCA structure is provided in the SQL Reference manual. The SQLCA holds information on the status of the SQL statement last executed. It is updated after the execution of each EXEC SQL ... END-EXEC block of code.

https://supportline.microfocus.com/documentation/books/sx40/spcesc.htm#usca

David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88