查询课程信息,根据用户需要修改某些元组的 TEACHER字段 EXEC SQL BEGIN DECLARE SECTION /*说明宿主变量dept, deptname,Hcno, CName, TEacher,New Teacher * EXEC SQL END DECLARE SECTION gets(dept); deptname=)” strcat(deptname, dept) strcat(deptname, 1%1) EXEC SQL DECLARE CX CURSORFOR/*定义游标* SELECT C#. CNAME TEACHER FROMC WHERE C#LIKE: deptname FOR UPDATE OF TEACHER EXEC SQLOPEN CX/打开游标* While(1) EXEC SQLFETCH cx INTO Hcno, Rename, TEacher;/读数据*/ if( sqlca. sqlcode==100 break;/*结果处理完毕* if( sqlca. sqlcode<0) break;/*出错* printf("%S, %S, %s", Hcno, Cname, HTeacher) printf(“确定要修改 Teacher属性?)查询课程信息,根据用户需要修改某些元组的 TEACHER 字段: EXEC SQL BEGIN DECLARE SECTION; /* 说明宿主变量 dept, deptname, Hcno, HCname, HTeacher, New Teacher */ EXEC SQL END DECLARE SECTION; … gets(dept); deptname = “\’”; strcat(deptname,dept); strcat(deptname, “\%\’”); EXEC SQL DECLARE cx CURSOR FOR /*定义游标*/ SELECT C#, CNAME, TEACHER FROM C WHERE C# LIKE :deptname FOR UPDATE OF TEACHER EXEC SQL OPEN cx /*打开游标*/ While(1) { EXEC SQL FETCH cx INTO :Hcno, :Hcname, :HTeacher; /*读数据*/ if ( sqlca.sqlcode = = 100) break; /*结果处理完毕*/ if ( sqlca.sqlcode < 0) break; /*出错*/ printf(“%s, %s, %s”, Hcno, Hcname, HTeacher); printf(“确定要修改 Teacher 属性?”);