Connect to the SAMPLE database and query the FIRSTNAME information of JOHNSON. # Include <stdio. h> # include <stdlib. h> # include <string. h> # include "util. h "# include <sqlca. h> exec SQL include sqlca; (1) main () {exec SQL BEGIN DECLARE SECTION; (2) char firstname [13]; char userid [9]; char passwd [19]; exec SQL end declare section; exec SQL connect to sample; (3) exec SQL SELECT FIRSTNME INTO: firstname (4) FROM employeeWHERE LASTNAME = 'johnson '; (4) printf ("First name = % s \ n", firstname); EX Ec SQL connect reset; (5) return 0;} The above is a simple static SQL statement embedded application. It includes the main part of Embedded SQL: (1) the include SQLCA statement in defines and describes the structure of SQLCA. SQLCA is used for communication between applications and databases. The SQLCODE returns the result status after the SQL statement is executed. (2) The host variable is defined between begin declare section and end declare section. Host variables can be referenced by SQL statements or C language statements. It is used to pass data in the program to the Database Manager through SQL statements, or receive query results from the Database Manager. In SQL statements, there is a ":" mark before the main variable to show the difference. (3) CONNECT to a database before each database access. In this case, make sure that the database instance has been started. (4) is a selection statement. It identifies the FIRSTNAME of the row data whose LASTNAME is "JOHNSON" in the table employee and places it in the firstname variable. This statement returns a result. Multiple results can be returned through a cursor. Of course, it can also contain update, insert, and delete statements. (5) disconnect the database. As shown in the preceding example, each embedded SQL statement starts with exec SQL, indicating that it is an SQL statement. This also tells the pre-compiler to embed SQL statements between exec SQL and. If an embedded SQL statement occupies multiple rows, you can use the "\" extension in the C program.